xrpld
Loading...
Searching...
No Matches
CredentialHelpers.h
1#pragma once
2
3#include <xrpl/basics/Slice.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/basics/chrono.h>
6#include <xrpl/beast/utility/Journal.h>
7#include <xrpl/ledger/ApplyView.h>
8#include <xrpl/ledger/ReadView.h>
9#include <xrpl/protocol/AccountID.h>
10#include <xrpl/protocol/Rules.h>
11#include <xrpl/protocol/STArray.h>
12#include <xrpl/protocol/STLedgerEntry.h>
13#include <xrpl/protocol/STTx.h>
14#include <xrpl/protocol/STVector256.h>
15#include <xrpl/protocol/TER.h>
16
17#include <memory>
18#include <set>
19#include <utility>
20
21namespace xrpl {
22namespace credentials {
23
24// These function will be used by the code that use DepositPreauth / Credentials
25// (and any future pre-authorization modes) as part of authorization (all the
26// transfer funds transactions)
27
28// Check if credential sfExpiration field has passed ledger's parentCloseTime
29bool
30checkExpired(SLE const& sleCredential, NetClock::time_point const& closed);
31
32// Actually remove a credentials object from the ledger
33[[nodiscard]] TER
34deleteSLE(ApplyView& view, SLE::ref sleCredential, beast::Journal j);
35
36// Amendment and parameters checks for sfCredentialIDs field
38checkFields(STTx const& tx, Rules const& rules, beast::Journal j);
39
40// Accessing the ledger to check if provided credentials are valid. Do not use
41// in doApply (only in preclaim) since it does not remove expired credentials.
42// If you call it in preclaim, you also must call verifyDepositPreauth in
43// doApply
44TER
45valid(STTx const& tx, ReadView const& view, AccountID const& src, beast::Journal j);
46
47// Check if subject has any credential matching the given domain. If you call it
48// in preclaim and it returns tecEXPIRED, you should call verifyValidDomain in
49// doApply. This will ensure that expired credentials are deleted.
50TER
51validDomain(ReadView const& view, uint256 domainID, AccountID const& subject);
52
53// This function is only called when we are about to return tecNO_PERMISSION
54// because all the checks for the DepositPreauth authorization failed.
55TER
56authorizedDepositPreauth(ReadView const& view, STVector256 const& ctx, AccountID const& dst);
57
58// Sort credentials array, return empty set if there are duplicates
61
62// Check credentials array passed to DepositPreauth/PermissionedDomainSet
63// transactions
65checkArray(STArray const& credentials, unsigned maxSize, beast::Journal j);
66
67} // namespace credentials
68
69// Check expired credentials and for credentials matching DomainID of the ledger
70// object
71TER
72verifyValidDomain(ApplyView& view, AccountID const& account, uint256 domainID, beast::Journal j);
73
86TER
88 STTx const& tx,
89 ReadView const& view,
90 AccountID const& src,
91 AccountID const& dst,
92 std::shared_ptr<SLE const> const& sleDst,
94
104TER
106
107// Check expired credentials and for existing DepositPreauth ledger object
108TER
110 STTx const& tx,
111 ApplyView& view,
112 AccountID const& src,
113 AccountID const& dst,
114 SLE::const_ref sleDst,
116
117} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:44
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:134
std::chrono::time_point< NetClock > time_point
Definition chrono.h:48
A view into a ledger.
Definition ReadView.h:41
Rules controlling protocol behavior.
Definition Rules.h:40
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, Rules const &rules, 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:607
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:34
TERSubset< CanCvtToTER > TER
Definition TER.h:647
BaseUInt< 256 > uint256
Definition base_uint.h:580
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)