rippled
Loading...
Searching...
No Matches
CredentialHelpers.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2024 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include <xrpld/app/tx/detail/Transactor.h>
23
24namespace ripple {
25namespace credentials {
26
27// These function will be used by the code that use DepositPreauth / Credentials
28// (and any future preauthorization modes) as part of authorization (all the
29// transfer funds transactions)
30
31// Check if credential sfExpiration field has passed ledger's parentCloseTime
32bool
34 std::shared_ptr<SLE const> const& sleCredential,
35 NetClock::time_point const& closed);
36
37// Return true if at least 1 expired credentials was found(and deleted)
38bool
39removeExpired(ApplyView& view, STTx const& tx, beast::Journal const j);
40
41// Actually remove a credentials object from the ledger
42TER
44 ApplyView& view,
45 std::shared_ptr<SLE> const& sleCredential,
47
48// Amendment and parameters checks for sfCredentialIDs field
50checkFields(PreflightContext const& ctx);
51
52// Accessing the ledger to check if provided credentials are valid
53TER
54valid(PreclaimContext const& ctx, AccountID const& src);
55
56// This function is only called when we about to return tecNO_PERMISSION because
57// all the checks for the DepositPreauth authorization failed.
58TER
59authorized(ApplyContext const& ctx, AccountID const& dst);
60
61// Sort credentials array, return empty set if there are duplicates
63makeSorted(STArray const& credentials);
64
65// Check credentials array passed to DepositPreauth/PermissionedDomainSet
66// transactions
68checkArray(STArray const& credentials, unsigned maxSize, beast::Journal j);
69
70} // namespace credentials
71
72// Check expired credentials and for existing DepositPreauth ledger object
73TER
75 ApplyContext& ctx,
76 AccountID const& src,
77 AccountID const& dst,
78 std::shared_ptr<SLE> const& sleDst);
79
80} // namespace ripple
A generic endpoint for log messages.
Definition: Journal.h:59
std::chrono::time_point< NetClock > time_point
Definition: chrono.h:70
NotTEC checkFields(PreflightContext const &ctx)
TER deleteSLE(ApplyView &view, std::shared_ptr< SLE > const &sleCredential, beast::Journal j)
bool removeExpired(ApplyView &view, STTx const &tx, beast::Journal const j)
TER authorized(ApplyContext const &ctx, AccountID const &dst)
TER valid(PreclaimContext const &ctx, AccountID const &src)
NotTEC checkArray(STArray const &credentials, unsigned maxSize, beast::Journal j)
bool checkExpired(std::shared_ptr< SLE const > const &sleCredential, NetClock::time_point const &closed)
std::set< std::pair< AccountID, Slice > > makeSorted(STArray const &credentials)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition: AccountID.h:49
TER verifyDepositPreauth(ApplyContext &ctx, AccountID const &src, AccountID const &dst, std::shared_ptr< SLE > const &sleDst)
TERSubset< CanCvtToTER > TER
Definition: TER.h:627
TERSubset< CanCvtToNotTEC > NotTEC
Definition: TER.h:587