xrpld
Loading...
Searching...
No Matches
CredentialHelpers.h
1#pragma once
2
3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/ledger/ApplyView.h>
7#include <xrpl/ledger/ReadView.h>
8#include <xrpl/protocol/AccountID.h>
9#include <xrpl/protocol/STArray.h>
10#include <xrpl/protocol/STTx.h>
11#include <xrpl/protocol/TER.h>
12
13namespace xrpl {
14namespace credentials {
15
16// These function will be used by the code that use DepositPreauth / Credentials
17// (and any future pre-authorization modes) as part of authorization (all the
18// transfer funds transactions)
19
20// Check if credential sfExpiration field has passed ledger's parentCloseTime
21bool
22checkExpired(SLE const& sleCredential, NetClock::time_point const& closed);
23
24// Actually remove a credentials object from the ledger
25[[nodiscard]] TER
26deleteSLE(ApplyView& view, SLE::ref sleCredential, beast::Journal j);
27
28// Amendment and parameters checks for sfCredentialIDs field
30checkFields(STTx const& tx, beast::Journal j);
31
32// Accessing the ledger to check if provided credentials are valid. Do not use
33// in doApply (only in preclaim) since it does not remove expired credentials.
34// If you call it in preclaim, you also must call verifyDepositPreauth in
35// doApply
36TER
37valid(STTx const& tx, ReadView const& view, AccountID const& src, beast::Journal j);
38
39// Check if subject has any credential matching the given domain. If you call it
40// in preclaim and it returns tecEXPIRED, you should call verifyValidDomain in
41// doApply. This will ensure that expired credentials are deleted.
42TER
43validDomain(ReadView const& view, uint256 domainID, AccountID const& subject);
44
45// This function is only called when we are about to return tecNO_PERMISSION
46// because all the checks for the DepositPreauth authorization failed.
47TER
48authorizedDepositPreauth(ReadView const& view, STVector256 const& ctx, AccountID const& dst);
49
50// Sort credentials array, return empty set if there are duplicates
53
54// Check credentials array passed to DepositPreauth/PermissionedDomainSet
55// transactions
57checkArray(STArray const& credentials, unsigned maxSize, beast::Journal j);
58
59} // namespace credentials
60
61// Check expired credentials and for credentials matching DomainID of the ledger
62// object
63TER
64verifyValidDomain(ApplyView& view, AccountID const& account, uint256 domainID, beast::Journal j);
65
78TER
80 STTx const& tx,
81 ReadView const& view,
82 AccountID const& src,
83 AccountID const& dst,
84 std::shared_ptr<SLE const> const& sleDst,
86
96TER
98
99// Check expired credentials and for existing DepositPreauth ledger object
100TER
102 STTx const& tx,
103 ApplyView& view,
104 AccountID const& src,
105 AccountID const& dst,
106 SLE::const_ref sleDst,
108
109} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:38
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:118
std::chrono::time_point< NetClock > time_point
Definition chrono.h:46
A view into a ledger.
Definition ReadView.h:31
std::shared_ptr< STLedgerEntry > const & ref
std::shared_ptr< STLedgerEntry const > const & const_ref
TER validDomain(ReadView const &view, uint256 domainID, AccountID const &subject)
TER deleteSLE(ApplyView &view, SLE::ref sleCredential, beast::Journal j)
std::set< std::pair< AccountID, Slice > > makeSorted(STArray const &credentials)
NotTEC checkFields(STTx const &tx, beast::Journal j)
TER valid(STTx const &tx, ReadView const &view, AccountID const &src, beast::Journal j)
NotTEC checkArray(STArray const &credentials, unsigned maxSize, beast::Journal j)
TER authorizedDepositPreauth(ReadView const &view, STVector256 const &ctx, AccountID const &dst)
bool checkExpired(SLE const &sleCredential, NetClock::time_point const &closed)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
TER verifyValidDomain(ApplyView &view, AccountID const &account, uint256 domainID, beast::Journal j)
STLedgerEntry SLE
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:594
TER cleanupExpiredCredentials(STTx const &tx, ApplyView &view, beast::Journal j)
Remove expired credentials referenced by the transaction.
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
TERSubset< CanCvtToTER > TER
Definition TER.h:634
BaseUInt< 256 > uint256
Definition base_uint.h:562
TER checkDepositPreauth(STTx const &tx, ReadView const &view, AccountID const &src, AccountID const &dst, std::shared_ptr< SLE const > const &sleDst, beast::Journal j)
Check whether src is authorized to deposit to dst.
TER verifyDepositPreauth(STTx const &tx, ApplyView &view, AccountID const &src, AccountID const &dst, SLE::const_ref sleDst, beast::Journal j)