20#include <xrpl/ledger/CredentialHelpers.h> 
   21#include <xrpl/ledger/View.h> 
   22#include <xrpl/protocol/TER.h> 
   23#include <xrpl/protocol/digest.h> 
   28namespace credentials {
 
   35    std::uint32_t const exp = (*sleCredential)[~sfExpiration].value_or(
 
 
   45    bool foundExpired = 
false;
 
   47    for (
auto const& h : arr)
 
   51        auto const sleCred = view.
peek(k);
 
   56                << 
"Credentials are expired. Cred: " << sleCred->getText();
 
 
   76        [&view, &sleCredential, j](
 
   82            JLOG(j.
fatal()) << 
"Internal error: can't retrieve Owner account.";
 
   93            JLOG(j.
fatal()) << 
"Unable to delete Credential from owner.";
 
  104    auto const issuer = sleCredential->getAccountID(sfIssuer);
 
  105    auto const subject = sleCredential->getAccountID(sfSubject);
 
  108    auto err = delSLE(issuer, sfIssuerNode, !
accepted || (subject == issuer));
 
  112    if (subject != issuer)
 
  114        err = delSLE(subject, sfSubjectNode, 
accepted);
 
  120    view.
erase(sleCredential);
 
 
  131    auto const& credentials = tx.
getFieldV256(sfCredentialIDs);
 
  135            << 
"Malformed transaction: Credentials array size is invalid: " 
  136            << credentials.size();
 
  141    for (
auto const& cred : credentials)
 
  143        auto [it, ins] = duplicates.
insert(cred);
 
  147                << 
"Malformed transaction: duplicates in credentials.";
 
 
  166    for (
auto const& h : credIDs)
 
  171            JLOG(j.
trace()) << 
"Credential doesn't exist. Cred: " << h;
 
  175        if (sleCred->getAccountID(sfSubject) != src)
 
  178                << 
"Credential doesn't belong to the source account. Cred: " 
  185            JLOG(j.
trace()) << 
"Credential isn't accepted. Cred: " << h;
 
 
  204    bool foundExpired = 
false;
 
  205    for (
auto const& h : slePD->getFieldArray(sfAcceptedCredentials))
 
  207        auto const issuer = h.getAccountID(sfIssuer);
 
  208        auto const type = h.getFieldVL(sfCredentialType);
 
  209        auto const keyletCredential =
 
  211        auto const sleCredential = view.
read(keyletCredential);
 
 
  244    for (
auto const& h : credIDs)
 
  251            sorted.
emplace((*sleCred)[sfIssuer], (*sleCred)[sfCredentialType]);
 
  254        lifeExtender.
push_back(std::move(sleCred));
 
 
  267    for (
auto const& cred : credentials)
 
  269        auto [it, ins] = 
out.
emplace(cred[sfIssuer], cred[sfCredentialType]);
 
 
  279    if (credentials.
empty() || (credentials.
size() > maxSize))
 
  281        JLOG(j.
trace()) << 
"Malformed transaction: " 
  282                           "Invalid credentials size: " 
  283                        << credentials.
size();
 
  293            JLOG(j.
trace()) << 
"Malformed transaction: " 
  294                               "Issuer account is invalid: " 
  302            JLOG(j.
trace()) << 
"Malformed transaction: " 
  303                               "Invalid credentialType size: " 
  311            JLOG(j.
trace()) << 
"Malformed transaction: " 
  312                               "duplicates in credenentials.";
 
 
  336    for (
auto const& h : slePD->getFieldArray(sfAcceptedCredentials))
 
  338        auto const issuer = h.getAccountID(sfIssuer);
 
  339        auto const type = h.getFieldVL(sfCredentialType);
 
  340        auto const keyletCredential =
 
  342        if (view.
exists(keyletCredential))
 
  343            credentials.
push_back(keyletCredential.key);
 
  347    for (
auto const& h : credentials)
 
 
  375    bool const credentialsPresent = tx.
isFieldPresent(sfCredentialIDs);
 
  377    if (credentialsPresent &&
 
  386                return !credentialsPresent
 
 
A generic endpoint for log messages.
 
Stream trace() const
Severity stream access functions.
 
Writeable view to a ledger, for applying a transaction.
 
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
 
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
 
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
 
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
 
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
 
virtual LedgerInfo const & info() const =0
Returns information about the ledger.
 
bool isFieldPresent(SField const &field) const
 
STVector256 const & getFieldV256(SField const &field) const
 
void push_back(uint256 const &v)
 
NotTEC checkFields(STTx const &tx, beast::Journal j)
 
TER deleteSLE(ApplyView &view, std::shared_ptr< SLE > const &sleCredential, beast::Journal j)
 
bool removeExpired(ApplyView &view, STVector256 const &arr, beast::Journal const j)
 
TER validDomain(ReadView const &view, uint256 domainID, AccountID const &subject)
 
TER valid(STTx const &tx, ReadView const &view, AccountID const &src, beast::Journal j)
 
NotTEC checkArray(STArray const &credentials, unsigned maxSize, beast::Journal j)
 
bool checkExpired(std::shared_ptr< SLE const > const &sleCredential, NetClock::time_point const &closed)
 
TER authorizedDepositPreauth(ApplyView const &view, STVector256 const &ctx, AccountID const &dst)
 
std::set< std::pair< AccountID, Slice > > makeSorted(STArray const &credentials)
 
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
 
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
 
Keylet account(AccountID const &id) noexcept
AccountID root.
 
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
 
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
 
TER verifyDepositPreauth(STTx const &tx, ApplyView &view, AccountID const &src, AccountID const &dst, std::shared_ptr< SLE > const &sleDst, beast::Journal j)
 
std::size_t constexpr maxCredentialsArraySize
The maximum number of credentials can be passed in array.
 
@ accepted
Manifest is valid.
 
std::size_t constexpr maxCredentialTypeLength
The maximum length of a CredentialType inside a Credential.
 
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
 
bool isTesSuccess(TER x) noexcept
 
std::string to_string(base_uint< Bits, Tag > const &a)
 
TER verifyValidDomain(ApplyView &view, AccountID const &account, uint256 domainID, beast::Journal j)
 
@ credential
Credentials signature.
 
TERSubset< CanCvtToTER > TER
 
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
 
T time_since_epoch(T... args)