rippled
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(std::shared_ptr<SLE const> const& sleCredential, NetClock::time_point const& closed);
23
24// Return true if any expired credential was found in arr (and deleted)
25bool
26removeExpired(ApplyView& view, STVector256 const& arr, beast::Journal const j);
27
28// Actually remove a credentials object from the ledger
29TER
30deleteSLE(ApplyView& view, std::shared_ptr<SLE> const& sleCredential, beast::Journal j);
31
32// Amendment and parameters checks for sfCredentialIDs field
34checkFields(STTx const& tx, beast::Journal j);
35
36// Accessing the ledger to check if provided credentials are valid. Do not use
37// in doApply (only in preclaim) since it does not remove expired credentials.
38// If you call it in preclaim, you also must call verifyDepositPreauth in
39// doApply
40TER
41valid(STTx const& tx, ReadView const& view, AccountID const& src, beast::Journal j);
42
43// Check if subject has any credential maching the given domain. If you call it
44// in preclaim and it returns tecEXPIRED, you should call verifyValidDomain in
45// doApply. This will ensure that expired credentials are deleted.
46TER
47validDomain(ReadView const& view, uint256 domainID, AccountID const& subject);
48
49// This function is only called when we about to return tecNO_PERMISSION
50// because all the checks for the DepositPreauth authorization failed.
51TER
52authorizedDepositPreauth(ApplyView const& view, STVector256 const& ctx, AccountID const& dst);
53
54// Sort credentials array, return empty set if there are duplicates
56makeSorted(STArray const& credentials);
57
58// Check credentials array passed to DepositPreauth/PermissionedDomainSet
59// transactions
61checkArray(STArray const& credentials, unsigned maxSize, beast::Journal j);
62
63} // namespace credentials
64
65// Check expired credentials and for credentials maching DomainID of the ledger
66// object
67TER
68verifyValidDomain(ApplyView& view, AccountID const& account, uint256 domainID, beast::Journal j);
69
70// Check expired credentials and for existing DepositPreauth ledger object
71TER
73 STTx const& tx,
74 ApplyView& view,
75 AccountID const& src,
76 AccountID const& dst,
77 std::shared_ptr<SLE> const& sleDst,
79
80} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:114
A view into a ledger.
Definition ReadView.h:31
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:5
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)