20 #include <ripple/app/tx/impl/DeleteAccount.h>
21 #include <ripple/app/tx/impl/DepositPreauth.h>
22 #include <ripple/app/tx/impl/SetSignerList.h>
23 #include <ripple/basics/FeeUnits.h>
24 #include <ripple/basics/Log.h>
25 #include <ripple/basics/mulDiv.h>
26 #include <ripple/protocol/Feature.h>
27 #include <ripple/protocol/Indexes.h>
28 #include <ripple/protocol/st.h>
29 #include <ripple/protocol/TxFlags.h>
30 #include <ripple/ledger/View.h>
64 mulDiv (fees.increment, safe_cast<FeeUnit64>(fees.units), fees.base)};
65 if (mulDivResult.first)
66 return mulDivResult.second;
98 removeDepositPreauthFromLedger (Application& app, ApplyView& view,
103 app, view, delIndex, j);
166 unsigned int uDirEntry {0};
167 uint256 dirEntry {beast::zero};
170 ctx.
view, ownerDirKeylet.key, sleDirNode, uDirEntry, dirEntry, ctx.
j))
180 auto sleItem = ctx.
view.
read (itemKeylet);
184 JLOG (ctx.
j.
fatal()) <<
"DeleteAccount: directory node in ledger "
185 << ctx.
view.
seq() <<
" has index to object that is missing: "
193 if (!nonObligationDeleter(nodeType))
202 ctx.
view, ownerDirKeylet.key, sleDirNode, uDirEntry, dirEntry, ctx.
j));
222 unsigned int uDirEntry {0};
223 uint256 dirEntry {beast::zero};
226 view(), ownerDirKeylet.key, sleDirNode, uDirEntry, dirEntry,
j_))
232 auto sleItem =
view().
peek (itemKeylet);
236 JLOG (
j_.
fatal()) <<
"DeleteAccount: Directory node in ledger "
237 <<
view().
seq() <<
" has index to object that is missing: "
243 safe_cast<LedgerEntryType>(
246 if (
auto deleter = nonObligationDeleter(nodeType))
256 assert (!
"Undeletable entry should be found in preclaim.");
258 <<
"DeleteAccount undeletable item not found in preclaim.";
278 assert (uDirEntry == 1);
282 <<
"DeleteAccount iterator re-validation failed.";
288 view(), ownerDirKeylet.key, sleDirNode, uDirEntry, dirEntry,
j_));
300 if (
view().exists(ownerDirKeylet) && !
view().emptyDirDelete(ownerDirKeylet))
302 JLOG(
j_.
error()) <<
"DeleteAccount cannot delete root dir node of "
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
A pair of SHAMap key and LedgerEntryType.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
const SF_U16 sfLedgerEntryType(access, STI_UINT16, 1, "LedgerEntryType", SField::sMD_Never)
bool cdirNext(ReadView const &view, uint256 const &uRootIndex, std::shared_ptr< SLE const > &sleNode, unsigned int &uDirEntry, uint256 &uEntryIndex, beast::Journal j)
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
const SF_U32 sfSequence(access, STI_UINT32, 4, "Sequence")
static TER removeSignersFromLedger(Application &app, ApplyView &view, Keylet const &accountKeylet, Keylet const &ownerDirKeylet, Keylet const &signerListKeylet)
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
const SF_Account sfAccount(access, STI_ACCOUNT, 1, "Account")
const SF_U32 sfFlags(access, STI_UINT32, 2, "Flags")
const uint256 featureDepositAuth
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.
static NotTEC preflight(PreflightContext const &ctx)
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
std::string to_string(ListDisposition disposition)
bool dirNext(ApplyView &view, uint256 const &uRootIndex, std::shared_ptr< SLE > &sleNode, unsigned int &uDirEntry, uint256 &uEntryIndex, beast::Journal j)
static TER preclaim(PreclaimContext const &ctx)
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
Writeable view to a ledger, for applying a transaction.
@ ltCHILD
Special type, anything not a directory This is used when the type in the Keylet is unknown,...
static const depositPreauth_t depositPreauth
const uint256 featureDeletableAccounts
const SF_U32 sfDestinationTag(access, STI_UINT32, 14, "DestinationTag")
static FeeUnit64 calculateBaseFee(ReadView const &view, STTx const &tx)
bool dirFirst(ApplyView &view, uint256 const &uRootIndex, std::shared_ptr< SLE > &sleNode, unsigned int &uDirEntry, uint256 &uEntryIndex, beast::Journal j)
static TER removeFromLedger(Application &app, ApplyView &view, uint256 const &delIndex, beast::Journal j)
Reflects the fee settings for a particular ledger.
TER offerDelete(ApplyView &view, std::shared_ptr< SLE > const &sle, beast::Journal j)
Delete an offer.
static const account_t account
Keylet ownerDir(AccountID const &id)
The root page of an account's directory.
TERSubset< CanCvtToTER > TER
static constexpr std::int32_t maxDeletableDirEntries
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
std::uint32_t getFlags() const
static FeeUnit64 calculateBaseFee(ReadView const &view, STTx const &tx)
void deliver(STAmount const &amount)
Sets the DeliveredAmount field in the metadata.
A generic endpoint for log messages.
bool enabled(uint256 const &id) const
Returns true if a feature is enabled.
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
State information when determining if a tx is likely to claim a fee.
bool dirIsEmpty(ReadView const &view, Keylet const &k)
Returns true if the directory is empty.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const SF_Amount sfBalance(access, STI_AMOUNT, 2, "Balance")
LedgerEntryType
Ledger entry types.
LedgerIndex seq() const
Returns the sequence number of the base ledger.
virtual Rules const & rules() const =0
Returns the tx processing rules.
const SF_Account sfDestination(access, STI_ACCOUNT, 3, "Destination")
std::pair< bool, Dest > mulDiv(Source1 value, Dest mul, Source2 div)
const std::uint32_t tfUniversalMask
State information when preflighting a tx.
TERSubset< CanCvtToNotTEC > NotTEC
static TER removeFromLedger(Application &app, ApplyView &view, AccountID const &account)
bool cdirFirst(ReadView const &view, uint256 const &uRootIndex, std::shared_ptr< SLE const > &sleNode, unsigned int &uDirEntry, uint256 &uEntryIndex, beast::Journal j)