1#include <xrpl/basics/Log.h>
2#include <xrpl/ledger/ApplyView.h>
3#include <xrpl/ledger/helpers/AccountRootHelpers.h>
4#include <xrpl/ledger/helpers/CredentialHelpers.h>
5#include <xrpl/protocol/Feature.h>
6#include <xrpl/protocol/Indexes.h>
7#include <xrpl/protocol/TxFlags.h>
8#include <xrpl/tx/transactors/credentials/CredentialAccept.h>
14using namespace credentials;
26 if (!ctx.
tx[sfIssuer])
28 JLOG(ctx.
j.
trace()) <<
"Malformed transaction: Issuer field zeroed.";
32 auto const credType = ctx.
tx[sfCredentialType];
35 JLOG(ctx.
j.
trace()) <<
"Malformed transaction: invalid size of CredentialType.";
47 auto const credType(ctx.
tx[sfCredentialType]);
63 if ((sleCred->getFieldU32(sfFlags) & lsfAccepted) != 0u)
65 JLOG(ctx.
j.
warn()) <<
"Credential already accepted: " <<
to_string(subject) <<
", "
82 if (!sleSubject || !sleIssuer)
92 auto const credType(
ctx_.
tx[sfCredentialType]);
94 auto const sleCred =
view().
peek(credentialKey);
98 JLOG(
j_.
trace()) <<
"Credential is expired: " << sleCred->getText();
104 sleCred->setFieldU32(sfFlags, lsfAccepted);
Stream trace() const
Severity stream access functions.
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
static TER preclaim(PreclaimContext const &ctx)
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
bool checkExpired(std::shared_ptr< SLE const > const &sleCredential, NetClock::time_point const &closed)
TER deleteSLE(ApplyView &view, std::shared_ptr< SLE > const &sleCredential, beast::Journal j)
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string to_string(base_uint< Bits, Tag > const &a)
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
bool isTesSuccess(TER x) noexcept
@ tecINSUFFICIENT_RESERVE
constexpr FlagValue tfUniversalMask
std::size_t constexpr maxCredentialTypeLength
The maximum length of a CredentialType inside a Credential.
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
A pair of SHAMap key and LedgerEntryType.
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.