20#include <xrpld/app/misc/CredentialHelpers.h>
21#include <xrpld/app/tx/detail/DID.h>
22#include <xrpld/app/tx/detail/DelegateSet.h>
23#include <xrpld/app/tx/detail/DeleteAccount.h>
24#include <xrpld/app/tx/detail/DeleteOracle.h>
25#include <xrpld/app/tx/detail/DepositPreauth.h>
26#include <xrpld/app/tx/detail/NFTokenUtils.h>
27#include <xrpld/app/tx/detail/SetSignerList.h>
28#include <xrpld/ledger/View.h>
30#include <xrpl/basics/Log.h>
31#include <xrpl/basics/mulDiv.h>
32#include <xrpl/beast/utility/instrumentation.h>
33#include <xrpl/protocol/Feature.h>
34#include <xrpl/protocol/FeeUnits.h>
35#include <xrpl/protocol/Indexes.h>
36#include <xrpl/protocol/Protocol.h>
37#include <xrpl/protocol/TxFlags.h>
57 if (ctx.
tx[sfAccount] == ctx.
tx[sfDestination])
77using DeleterFuncPtr =
TER (*)(
111removeTicketFromLedger(
123removeDepositPreauthFromLedger(
135removeNFTokenOfferFromLedger(
162removeOracleFromLedger(
174removeCredentialFromLedger(
186removeDelegateFromLedger(
210 return removeTicketFromLedger;
211 case ltDEPOSIT_PREAUTH:
212 return removeDepositPreauthFromLedger;
213 case ltNFTOKEN_OFFER:
214 return removeNFTokenOfferFromLedger;
216 return removeDIDFromLedger;
218 return removeOracleFromLedger;
220 return removeCredentialFromLedger;
222 return removeDelegateFromLedger;
264 sleAccount,
"ripple::DeleteAccount::preclaim : non-null account");
272 if ((*sleAccount)[~sfMintedNFTokens] !=
273 (*sleAccount)[~sfBurnedNFTokens])
294 if ((*sleAccount)[sfSequence] + seqDelta > ctx.
view.
seq())
309 ((*sleAccount)[~sfFirstNFTokenSequence].value_or(0) +
310 (*sleAccount)[~sfMintedNFTokens].value_or(0) + seqDelta >
321 unsigned int uDirEntry{0};
327 ctx.
view, ownerDirKeylet.key, sleDirNode, uDirEntry, dirEntry))
340 <<
"DeleteAccount: directory node in ledger " << ctx.
view.
seq()
341 <<
" has index to object that is missing: "
347 safe_cast<LedgerEntryType>((*sleItem)[sfLedgerEntryType])};
349 if (!nonObligationDeleter(nodeType))
358 ctx.
view, ownerDirKeylet.key, sleDirNode, uDirEntry, dirEntry));
368 src,
"ripple::DeleteAccount::doApply : non-null source account");
370 auto const dstID =
ctx_.
tx[sfDestination];
373 dst,
"ripple::DeleteAccount::doApply : non-null destination account");
394 if (
auto deleter = nonObligationDeleter(nodeType))
403 "ripple::DeleteAccount::doApply : undeletable item not found "
405 JLOG(
j_.
error()) <<
"DeleteAccount undeletable item not "
406 "found in preclaim.";
420 "ripple::DeleteAccount::doApply : source balance is zero");
424 if (
view().exists(ownerDirKeylet) && !
view().emptyDirDelete(ownerDirKeylet))
426 JLOG(
j_.
error()) <<
"DeleteAccount cannot delete root dir node of "
A generic endpoint for log messages.
beast::Journal const journal
void deliver(STAmount const &amount)
Sets the DeliveredAmount field in the metadata.
Writeable view to a ledger, for applying a transaction.
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
static TER deleteSLE(ApplyContext &ctx, Keylet sleKeylet, AccountID const owner)
static TER deleteDelegate(ApplyView &view, std::shared_ptr< SLE > const &sle, AccountID const &account, beast::Journal j)
static NotTEC preflight(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
static XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
static TER deleteOracle(ApplyView &view, std::shared_ptr< SLE > const &sle, AccountID const &account, beast::Journal j)
static TER removeFromLedger(ApplyView &view, uint256 const &delIndex, beast::Journal j)
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
virtual std::optional< key_type > succ(key_type const &key, std::optional< key_type > const &last=std::nullopt) const =0
Return the key of the next state item.
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
LedgerIndex seq() const
Returns the sequence number of the base ledger.
virtual Rules const & rules() const =0
Returns the tx processing rules.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
bool isFieldPresent(SField const &field) const
std::uint32_t getFlags() const
static TER removeFromLedger(Application &app, ApplyView &view, AccountID const &account, beast::Journal j)
static TER ticketDelete(ApplyView &view, AccountID const &account, uint256 const &ticketIndex, beast::Journal j)
NotTEC checkFields(STTx const &tx, beast::Journal j)
TER deleteSLE(ApplyView &view, std::shared_ptr< SLE > const &sleCredential, beast::Journal j)
TER valid(STTx const &tx, ReadView const &view, AccountID const &src, beast::Journal j)
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet nftpage_min(AccountID const &owner)
NFT page keylets.
Keylet nftpage_max(AccountID const &owner)
A keylet for the owner's last possible NFT page.
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
bool deleteTokenOffer(ApplyView &view, std::shared_ptr< SLE > const &offer)
Deletes the given token offer.
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::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::size_t constexpr maxDeletableDirEntries
The maximum number of owner directory entries for account to be deletable.
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.
static TER removeSignersFromLedger(Application &app, ApplyView &view, Keylet const &accountKeylet, Keylet const &ownerDirKeylet, Keylet const &signerListKeylet, beast::Journal j)
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
TER offerDelete(ApplyView &view, std::shared_ptr< SLE > const &sle, beast::Journal j)
Delete an offer.
TER verifyDepositPreauth(STTx const &tx, ApplyView &view, AccountID const &src, AccountID const &dst, std::shared_ptr< SLE > const &sleDst, beast::Journal j)
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
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.
bool isTesSuccess(TER x) noexcept
std::string to_string(base_uint< Bits, Tag > const &a)
LedgerEntryType
Identifiers for on-ledger objects.
TER cleanupOnAccountDelete(ApplyView &view, Keylet const &ownerDirKeylet, EntryDeleter const &deleter, beast::Journal j, std::optional< uint16_t > maxNodesToDelete)
constexpr std::uint32_t tfUniversalMask
TERSubset< CanCvtToTER > TER
bool dirIsEmpty(ReadView const &view, Keylet const &k)
Returns true if the directory is empty.
TERSubset< CanCvtToNotTEC > NotTEC
A pair of SHAMap key and LedgerEntryType.
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.