1#include <xrpl/basics/Log.h>
2#include <xrpl/ledger/ApplyView.h>
3#include <xrpl/ledger/View.h>
4#include <xrpl/ledger/helpers/AccountRootHelpers.h>
5#include <xrpl/ledger/helpers/MPTokenHelpers.h>
6#include <xrpl/ledger/helpers/RippleStateHelpers.h>
7#include <xrpl/protocol/Feature.h>
8#include <xrpl/protocol/Indexes.h>
9#include <xrpl/protocol/Rate.h>
10#include <xrpl/tx/transactors/escrow/EscrowCancel.h>
12#include <libxrpl/tx/transactors/escrow/EscrowHelpers.h>
22template <Val
idIssueType T>
36 AccountID const issuer = amount.getIssuer();
38 if (issuer == account)
55 AccountID const issuer = amount.getIssuer();
57 if (issuer == account)
62 auto const sleIssuance = ctx.
view.
read(issuanceKey);
68 auto const& mptIssue = amount.get<
MPTIssue>();
86 AccountID const account = (*slep)[sfAccount];
87 STAmount const amount = (*slep)[sfAmount];
92 [&]<
typename T>(T
const&) {
93 return escrowCancelPreclaimHelper<T>(ctx, account, amount);
95 amount.asset().value());
119 if (!(*slep)[~sfCancelAfter])
123 if (!
after(now, (*slep)[sfCancelAfter]))
126 AccountID const account = (*slep)[sfAccount];
130 auto const page = (*slep)[sfOwnerNode];
134 JLOG(
j_.
fatal()) <<
"Unable to delete Escrow from owner.";
141 if (
auto const optPage = (*slep)[~sfDestinationNode]; optPage)
146 JLOG(
j_.
fatal()) <<
"Unable to delete Escrow from recipient.";
153 STAmount const amount = slep->getFieldAmount(sfAmount);
158 (*sle)[sfBalance] = (*sle)[sfBalance] + amount;
165 auto const issuer = amount.getIssuer();
166 bool const createAsset = account ==
account_;
168 [&]<
typename T>(T
const&) {
169 return escrowUnlockApplyHelper<T>(
181 amount.asset().value());
186 if (
auto const optPage = (*slep)[~sfIssuerNode]; optPage)
191 JLOG(
j_.
fatal()) <<
"Unable to delete Escrow from recipient.";
beast::Journal const journal
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
static NotTEC preflight(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
constexpr MPTID const & getMptID() const
virtual Rules const & rules() const =0
Returns the tx processing rules.
virtual LedgerHeader const & header() const =0
Returns information about the ledger.
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
Keylet escrow(AccountID const &src, std::uint32_t seq) noexcept
An escrow entry.
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Keylet account(AccountID const &id) noexcept
AccountID root.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool isXRP(AccountID const &c)
TER escrowCancelPreclaimHelper< MPTIssue >(PreclaimContext const &ctx, AccountID const &account, STAmount const &amount)
TER escrowCancelPreclaimHelper< Issue >(PreclaimContext const &ctx, AccountID const &account, STAmount const &amount)
TERSubset< CanCvtToTER > TER
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
static TER escrowCancelPreclaimHelper(PreclaimContext const &ctx, AccountID const &account, STAmount const &amount)
bool isTesSuccess(TER x) noexcept
TERSubset< CanCvtToNotTEC > NotTEC
Rate const parityRate
A transfer rate signifying a 1:1 exchange.
TER requireAuth(ReadView const &view, MPTIssue const &mptIssue, AccountID const &account, AuthType authType=AuthType::Legacy, int depth=0)
Check if the account lacks required authorization for MPT.
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.