xrpld
Loading...
Searching...
No Matches
AccountRootHelpers.h
1#pragma once
2
3#include <xrpl/beast/utility/Journal.h>
4#include <xrpl/ledger/ApplyView.h>
5#include <xrpl/ledger/ReadView.h>
6#include <xrpl/protocol/Indexes.h>
7#include <xrpl/protocol/Rate.h>
8#include <xrpl/protocol/STLedgerEntry.h>
9#include <xrpl/protocol/TER.h>
10
11#include <expected>
12#include <set>
13#include <vector>
14
15namespace xrpl {
16
21[[nodiscard]] bool
22isGlobalFrozen(ReadView const& view, AccountID const& issuer);
23
24// Calculate liquid XRP balance for an account.
25// This function may be used to calculate the amount of XRP that
26// the holder is able to freely spend. It subtracts reserve requirements.
27//
28// ownerCountAdj adjusts the owner count in case the caller calculates
29// before ledger entries are added or removed. Positive to add, negative
30// to subtract.
31//
32// @param ownerCountAdj positive to add to count, negative to reduce count.
33[[nodiscard]] XRPAmount
34xrpLiquid(ReadView const& view, AccountID const& id, std::int32_t ownerCountAdj, beast::Journal j);
35
37void
38adjustOwnerCount(ApplyView& view, SLE::ref sle, std::int32_t amount, beast::Journal j);
39
45[[nodiscard]] Rate
46transferRate(ReadView const& view, AccountID const& issuer);
47
53pseudoAccountAddress(ReadView const& view, uint256 const& pseudoOwnerKey);
54
62[[nodiscard]] std::vector<SField const*> const&
64
73[[nodiscard]] bool
74isPseudoAccount(SLE::const_pointer sleAcct, std::set<SField const*> const& pseudoFieldFilter = {});
75
77[[nodiscard]] inline bool
79 ReadView const& view,
80 AccountID const& accountId,
81 std::set<SField const*> const& pseudoFieldFilter = {})
82{
83 return isPseudoAccount(view.read(keylet::account(accountId)), pseudoFieldFilter);
84}
85
94[[nodiscard]] std::expected<SLE::pointer, TER>
95createPseudoAccount(ApplyView& view, uint256 const& pseudoOwnerKey, SField const& ownerField);
96
102[[nodiscard]] TER
103checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag);
104
105} // namespace xrpl
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:118
A view into a ledger.
Definition ReadView.h:31
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
Identifies fields.
Definition SField.h:130
std::shared_ptr< STLedgerEntry > const & ref
std::shared_ptr< STLedgerEntry const > const & const_ref
std::shared_ptr< STLedgerEntry const > const_pointer
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:186
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::vector< SField const * > const & getPseudoAccountFields()
Returns the list of fields that define an ACCOUNT_ROOT as a pseudo-account if set.
XRPAmount xrpLiquid(ReadView const &view, AccountID const &id, std::int32_t ownerCountAdj, beast::Journal j)
AccountID pseudoAccountAddress(ReadView const &view, uint256 const &pseudoOwnerKey)
Generate a pseudo-account address from a pseudo owner key.
std::expected< SLE::pointer, TER > createPseudoAccount(ApplyView &view, uint256 const &pseudoOwnerKey, SField const &ownerField)
Create pseudo-account, storing pseudoOwnerKey into ownerField.
bool isGlobalFrozen(ReadView const &view, AccountID const &issuer)
Check if the issuer has the global freeze flag set.
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
void adjustOwnerCount(ApplyView &view, SLE::ref sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
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
bool isPseudoAccount(SLE::const_pointer sleAcct, std::set< SField const * > const &pseudoFieldFilter={})
Returns true if and only if sleAcct is a pseudo-account or specific pseudo-accounts in pseudoFieldFil...
TER checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag)
Checks the destination and tag.
BaseUInt< 256 > uint256
Definition base_uint.h:562
Represents a transfer rate.
Definition Rate.h:20