20#ifndef RIPPLE_LEDGER_VIEW_H_INCLUDED
21#define RIPPLE_LEDGER_VIEW_H_INCLUDED
23#include <xrpld/core/Config.h>
24#include <xrpld/ledger/ApplyView.h>
25#include <xrpld/ledger/OpenView.h>
26#include <xrpld/ledger/RawView.h>
27#include <xrpld/ledger/ReadView.h>
28#include <xrpl/beast/utility/Journal.h>
29#include <xrpl/protocol/MPTIssue.h>
30#include <xrpl/protocol/Protocol.h>
31#include <xrpl/protocol/Rate.h>
32#include <xrpl/protocol/STLedgerEntry.h>
33#include <xrpl/protocol/STObject.h>
34#include <xrpl/protocol/STTx.h>
35#include <xrpl/protocol/Serializer.h>
36#include <xrpl/protocol/TER.h>
101[[nodiscard]]
inline bool
112 ReadView
const& view,
114 MPTIssue
const& mptIssue);
116[[nodiscard]]
inline bool
123 [&](
auto const& issue) {
131 ReadView
const& view,
136[[nodiscard]]
inline bool
144 ReadView
const& view,
146 MPTIssue
const& mptIssue);
148[[nodiscard]]
inline bool
152 [&](
auto const& issue) {
return isFrozen(view, account, issue); },
158 ReadView
const& view,
165 ReadView
const& view,
168 Issue
const& asset2);
173[[nodiscard]] STAmount
175 ReadView
const& view,
182[[nodiscard]] STAmount
184 ReadView
const& view,
190[[nodiscard]] STAmount
192 ReadView
const& view,
194 MPTIssue
const& mptIssue,
204[[nodiscard]] STAmount
206 ReadView
const& view,
208 STAmount
const& saDefault,
218[[nodiscard]] XRPAmount
220 ReadView
const& view,
228 ReadView
const& view,
240 ReadView
const& view,
295dirIsEmpty(ReadView
const& view, Keylet
const& k);
333 return (requested + 255) & (~255);
343 ReadView
const& validLedger,
344 ReadView
const& testLedger,
352 ReadView
const& testLedger,
387 ReadView
const& view,
419 ReadView
const& view,
453 const bool bNoRipple,
456 STAmount
const& saBalance,
458 STAmount
const& saLimit,
502 STAmount
const& saAmount,
514 STAmount
const& saAmount,
522 STAmount
const& amount,
530 STAmount
const& amount,
539 STAmount
const& amount,
550 ReadView
const& view,
551 MPTIssue
const& mptIssue,
560 ReadView
const& view,
561 MPTIssue
const& mptIssue,
583 Keylet const& ownerDirKeylet,
Provide a light-weight way to check active() before string formatting.
A generic endpoint for log messages.
Writeable view to a ledger, for applying a transaction.
constexpr value_type const & value() const
A currency issued by an account.
const std::shared_ptr< STLedgerEntry > & ref
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
std::uint32_t LedgerIndex
A ledger index.
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
FreezeHandling
Controls the treatment of frozen account balances.
bool cdirFirst(ReadView const &view, uint256 const &root, std::shared_ptr< SLE const > &page, unsigned int &index, uint256 &entry)
Returns the first entry in the directory, advancing the index.
LedgerIndex getCandidateLedger(LedgerIndex requested)
Find a ledger index from which we could easily get the requested ledger.
bool isIndividualFrozen(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer)
TER deleteAMMTrustLine(ApplyView &view, std::shared_ptr< SLE > sleState, std::optional< AccountID > const &ammAccountID, beast::Journal j)
Delete trustline to AMM.
bool dirFirst(ApplyView &view, uint256 const &root, std::shared_ptr< SLE > &page, unsigned int &index, uint256 &entry)
bool dirNext(ApplyView &view, uint256 const &root, std::shared_ptr< SLE > &page, unsigned int &index, uint256 &entry)
TER requireAuth(ReadView const &view, Issue const &issue, AccountID const &account)
Check if the account lacks required authorization.
bool isDeepFrozen(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer)
std::optional< uint256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
TER redeemIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
base_uint< 192 > MPTID
MPTID is a 192-bit value representing MPT Issuance ID, which is a concatenation of a 32-bit sequence ...
AuthHandling
Controls the treatment of unauthorized MPT balances.
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
TER transferXRP(ApplyView &view, AccountID const &from, AccountID const &to, STAmount const &amount, beast::Journal j)
TER offerDelete(ApplyView &view, std::shared_ptr< SLE > const &sle, beast::Journal j)
Delete an offer.
bool isFrozen(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer)
std::set< uint256 > getEnabledAmendments(ReadView const &view)
TER canTransfer(ReadView const &view, MPTIssue const &mptIssue, AccountID const &from, AccountID const &to)
Check if the destination account is allowed to receive MPT.
AccountID ammAccountID(std::uint16_t prefix, uint256 const &parentHash, uint256 const &ammID)
Calculate AMM account ID.
static bool adjustOwnerCount(ApplyContext &ctx, int count)
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
TER issueIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
TER trustCreate(ApplyView &view, const bool bSrcHigh, AccountID const &uSrcAccountID, AccountID const &uDstAccountID, uint256 const &uIndex, SLE::ref sleAccount, const bool bAuth, const bool bNoRipple, const bool bFreeze, bool bDeepFreeze, STAmount const &saBalance, STAmount const &saLimit, std::uint32_t uQualityIn, std::uint32_t uQualityOut, beast::Journal j)
Create a trust line.
bool cdirNext(ReadView const &view, uint256 const &root, std::shared_ptr< SLE const > &page, unsigned int &index, uint256 &entry)
Returns the next entry in the directory, advancing the index.
TER trustDelete(ApplyView &view, std::shared_ptr< SLE > const &sleRippleState, AccountID const &uLowAccountID, AccountID const &uHighAccountID, beast::Journal j)
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j)
bool isLPTokenFrozen(ReadView const &view, AccountID const &account, Issue const &asset, Issue const &asset2)
majorityAmendments_t getMajorityAmendments(ReadView const &view)
LedgerEntryType
Identifiers for on-ledger objects.
bool forEachItemAfter(ReadView const &view, Keylet const &root, uint256 const &after, std::uint64_t const hint, unsigned int limit, std::function< bool(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items after an item in the given directory.
TER cleanupOnAccountDelete(ApplyView &view, Keylet const &ownerDirKeylet, EntryDeleter const &deleter, beast::Journal j, std::optional< uint16_t > maxNodesToDelete)
void forEachItem(ReadView const &view, Keylet const &root, std::function< void(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items in the given directory.
Number root(Number f, unsigned d)
bool hasExpired(ReadView const &view, std::optional< std::uint32_t > const &exp)
Determines whether the given expiration time has passed.
TER rippleCredit(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, bool bCheckIssuer, beast::Journal j)
Calls static rippleCreditIOU if saAmount represents Issue.
TERSubset< CanCvtToTER > TER
bool areCompatible(ReadView const &validLedger, ReadView const &testLedger, beast::Journal::Stream &s, const char *reason)
Return false if the test ledger is provably incompatible with the valid ledger, that is,...
static bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
bool dirIsEmpty(ReadView const &view, Keylet const &k)
Returns true if the directory is empty.
TER accountSend(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, beast::Journal j, WaiveTransferFee waiveFee)
Calls static accountSendIOU if saAmount represents Issue.
XRPAmount xrpLiquid(ReadView const &view, AccountID const &id, std::int32_t ownerCountAdj, beast::Journal j)
bool isGlobalFrozen(ReadView const &view, AccountID const &issuer)
A pair of SHAMap key and LedgerEntryType.