rippled
Loading...
Searching...
No Matches
AccountRootHelpers.h
1#pragma once
2
3#include <xrpl/basics/Expected.h>
4#include <xrpl/beast/utility/Journal.h>
5#include <xrpl/ledger/ApplyView.h>
6#include <xrpl/ledger/ReadView.h>
7#include <xrpl/protocol/Indexes.h>
8#include <xrpl/protocol/Rate.h>
9#include <xrpl/protocol/STLedgerEntry.h>
10#include <xrpl/protocol/TER.h>
11
12#include <memory>
13#include <set>
14#include <vector>
15
16namespace xrpl {
17
22[[nodiscard]] bool
23isGlobalFrozen(ReadView const& view, AccountID const& issuer);
24
25// Calculate liquid XRP balance for an account.
26// This function may be used to calculate the amount of XRP that
27// the holder is able to freely spend. It subtracts reserve requirements.
28//
29// ownerCountAdj adjusts the owner count in case the caller calculates
30// before ledger entries are added or removed. Positive to add, negative
31// to subtract.
32//
33// @param ownerCountAdj positive to add to count, negative to reduce count.
34[[nodiscard]] XRPAmount
35xrpLiquid(ReadView const& view, AccountID const& id, std::int32_t ownerCountAdj, beast::Journal j);
36
38void
40 ApplyView& view,
41 std::shared_ptr<SLE> const& sle,
42 std::int32_t amount,
44
50[[nodiscard]] Rate
51transferRate(ReadView const& view, AccountID const& issuer);
52
58pseudoAccountAddress(ReadView const& view, uint256 const& pseudoOwnerKey);
59
67[[nodiscard]] std::vector<SField const*> const&
69
78[[nodiscard]] bool
81 std::set<SField const*> const& pseudoFieldFilter = {});
82
84[[nodiscard]] inline bool
86 ReadView const& view,
87 AccountID const& accountId,
88 std::set<SField const*> const& pseudoFieldFilter = {})
89{
90 return isPseudoAccount(view.read(keylet::account(accountId)), pseudoFieldFilter);
91}
92
101[[nodiscard]] Expected<std::shared_ptr<SLE>, TER>
102createPseudoAccount(ApplyView& view, uint256 const& pseudoOwnerKey, SField const& ownerField);
103
109[[nodiscard]] TER
110checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag);
111
112} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
A view into a ledger.
Definition ReadView.h:31
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
std::shared_ptr< STLedgerEntry const > const & const_ref
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:165
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.
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
base_uint< 256 > uint256
Definition base_uint.h:531
bool isPseudoAccount(std::shared_ptr< SLE const > sleAcct, std::set< SField const * > const &pseudoFieldFilter={})
Returns true if and only if sleAcct is a pseudo-account or specific pseudo-accounts in pseudoFieldFil...
bool isGlobalFrozen(ReadView const &view, AccountID const &issuer)
Check if the issuer has the global freeze flag set.
TERSubset< CanCvtToTER > TER
Definition TER.h:622
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
Expected< std::shared_ptr< SLE >, TER > createPseudoAccount(ApplyView &view, uint256 const &pseudoOwnerKey, SField const &ownerField)
Create pseudo-account, storing pseudoOwnerKey into ownerField.
TER checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag)
Checks the destination and tag.