20#include <xrpld/app/tx/detail/VaultDelete.h>
21#include <xrpld/ledger/View.h>
23#include <xrpl/protocol/Feature.h>
24#include <xrpl/protocol/STNumber.h>
25#include <xrpl/protocol/TER.h>
26#include <xrpl/protocol/TxFlags.h>
42 if (ctx.
tx[sfVaultID] == beast::zero)
44 JLOG(ctx.
j.
debug()) <<
"VaultDelete: zero/empty vault ID.";
58 if (vault->at(sfOwner) != ctx.
tx[sfAccount])
60 JLOG(ctx.
j.
debug()) <<
"VaultDelete: account is not an owner.";
64 if (vault->at(sfAssetsAvailable) != 0)
66 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets available.";
70 if (vault->at(sfAssetsTotal) != 0)
72 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets total.";
84 <<
"VaultDeposit: missing issuance of vault shares.";
89 if (sleMPT->at(sfIssuer) != vault->getAccountID(sfAccount))
92 JLOG(ctx.
j.
error()) <<
"VaultDeposit: invalid owner of vault shares.";
97 if (sleMPT->at(sfOutstandingAmount) != 0)
99 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero outstanding shares.";
114 auto asset = vault->at(sfAsset);
119 auto const& pseudoID = vault->at(sfAccount);
124 JLOG(
j_.
error()) <<
"VaultDelete: missing vault pseudo-account.";
135 JLOG(
j_.
error()) <<
"VaultDelete: missing issuance of vault shares.";
140 if (!
view().dirRemove(
144 JLOG(
j_.
error()) <<
"VaultDelete: failed to delete issuance object.";
160 auto const ownerID = vault->at(sfOwner);
161 if (!
view().dirRemove(
163 vault->at(sfOwnerNode),
168 JLOG(
j_.
error()) <<
"VaultDelete: failed to delete vault object.";
177 JLOG(
j_.
error()) <<
"VaultDelete: missing vault owner account.";
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.
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.
std::uint32_t getFlags() const
static NotTEC preflight(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Keylet account(AccountID const &id) noexcept
AccountID root.
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.
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
static bool adjustOwnerCount(ApplyContext &ctx, int count)
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
bool isTesSuccess(TER x) noexcept
constexpr std::uint32_t tfUniversalMask
TER removeEmptyHolding(ApplyView &view, AccountID const &accountID, Issue const &issue, beast::Journal journal)
TERSubset< CanCvtToNotTEC > NotTEC
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.