rippled
Loading...
Searching...
No Matches
CredentialHelpers.h
1#ifndef XRPL_APP_MISC_CREDENTIALHELPERS_H_INCLUDED
2#define XRPL_APP_MISC_CREDENTIALHELPERS_H_INCLUDED
3
4#include <xrpl/basics/Log.h>
5#include <xrpl/basics/base_uint.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/STArray.h>
11#include <xrpl/protocol/STTx.h>
12#include <xrpl/protocol/TER.h>
13
14namespace xrpl {
15namespace credentials {
16
17// These function will be used by the code that use DepositPreauth / Credentials
18// (and any future pre-authorization modes) as part of authorization (all the
19// transfer funds transactions)
20
21// Check if credential sfExpiration field has passed ledger's parentCloseTime
22bool
24 std::shared_ptr<SLE const> const& sleCredential,
25 NetClock::time_point const& closed);
26
27// Return true if any expired credential was found in arr (and deleted)
28bool
29removeExpired(ApplyView& view, STVector256 const& arr, beast::Journal const j);
30
31// Actually remove a credentials object from the ledger
32TER
34 ApplyView& view,
35 std::shared_ptr<SLE> const& sleCredential,
37
38// Amendment and parameters checks for sfCredentialIDs field
40checkFields(STTx const& tx, beast::Journal j);
41
42// Accessing the ledger to check if provided credentials are valid. Do not use
43// in doApply (only in preclaim) since it does not remove expired credentials.
44// If you call it in preclaim, you also must call verifyDepositPreauth in
45// doApply
46TER
47valid(
48 STTx const& tx,
49 ReadView const& view,
50 AccountID const& src,
52
53// Check if subject has any credential maching the given domain. If you call it
54// in preclaim and it returns tecEXPIRED, you should call verifyValidDomain in
55// doApply. This will ensure that expired credentials are deleted.
56TER
57validDomain(ReadView const& view, uint256 domainID, AccountID const& subject);
58
59// This function is only called when we about to return tecNO_PERMISSION
60// because all the checks for the DepositPreauth authorization failed.
61TER
63 ApplyView const& view,
64 STVector256 const& ctx,
65 AccountID const& dst);
66
67// Sort credentials array, return empty set if there are duplicates
69makeSorted(STArray const& credentials);
70
71// Check credentials array passed to DepositPreauth/PermissionedDomainSet
72// transactions
74checkArray(STArray const& credentials, unsigned maxSize, beast::Journal j);
75
76} // namespace credentials
77
78// Check expired credentials and for credentials maching DomainID of the ledger
79// object
80TER
82 ApplyView& view,
83 AccountID const& account,
84 uint256 domainID,
86
87// Check expired credentials and for existing DepositPreauth ledger object
88TER
90 STTx const& tx,
91 ApplyView& view,
92 AccountID const& src,
93 AccountID const& dst,
94 std::shared_ptr<SLE> const& sleDst,
96
97} // namespace xrpl
98
99#endif
A generic endpoint for log messages.
Definition Journal.h:41
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:124
A view into a ledger.
Definition ReadView.h:32
TER validDomain(ReadView const &view, uint256 domainID, AccountID const &subject)
bool checkExpired(std::shared_ptr< SLE const > const &sleCredential, NetClock::time_point const &closed)
bool removeExpired(ApplyView &view, STVector256 const &arr, beast::Journal const j)
std::set< std::pair< AccountID, Slice > > makeSorted(STArray const &credentials)
TER authorizedDepositPreauth(ApplyView const &view, STVector256 const &ctx, AccountID const &dst)
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 deleteSLE(ApplyView &view, std::shared_ptr< SLE > const &sleCredential, beast::Journal j)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
TER verifyValidDomain(ApplyView &view, AccountID const &account, uint256 domainID, beast::Journal j)
TER verifyDepositPreauth(STTx const &tx, ApplyView &view, AccountID const &src, AccountID const &dst, std::shared_ptr< SLE > const &sleDst, beast::Journal j)