20#include <xrpld/app/tx/applySteps.h>
21#include <xrpld/app/tx/detail/AMMBid.h>
22#include <xrpld/app/tx/detail/AMMClawback.h>
23#include <xrpld/app/tx/detail/AMMCreate.h>
24#include <xrpld/app/tx/detail/AMMDelete.h>
25#include <xrpld/app/tx/detail/AMMDeposit.h>
26#include <xrpld/app/tx/detail/AMMVote.h>
27#include <xrpld/app/tx/detail/AMMWithdraw.h>
28#include <xrpld/app/tx/detail/ApplyContext.h>
29#include <xrpld/app/tx/detail/Batch.h>
30#include <xrpld/app/tx/detail/CancelCheck.h>
31#include <xrpld/app/tx/detail/CancelOffer.h>
32#include <xrpld/app/tx/detail/CashCheck.h>
33#include <xrpld/app/tx/detail/Change.h>
34#include <xrpld/app/tx/detail/Clawback.h>
35#include <xrpld/app/tx/detail/CreateCheck.h>
36#include <xrpld/app/tx/detail/CreateOffer.h>
37#include <xrpld/app/tx/detail/CreateTicket.h>
38#include <xrpld/app/tx/detail/Credentials.h>
39#include <xrpld/app/tx/detail/DID.h>
40#include <xrpld/app/tx/detail/DelegateSet.h>
41#include <xrpld/app/tx/detail/DeleteAccount.h>
42#include <xrpld/app/tx/detail/DeleteOracle.h>
43#include <xrpld/app/tx/detail/DepositPreauth.h>
44#include <xrpld/app/tx/detail/Escrow.h>
45#include <xrpld/app/tx/detail/LedgerStateFix.h>
46#include <xrpld/app/tx/detail/MPTokenAuthorize.h>
47#include <xrpld/app/tx/detail/MPTokenIssuanceCreate.h>
48#include <xrpld/app/tx/detail/MPTokenIssuanceDestroy.h>
49#include <xrpld/app/tx/detail/MPTokenIssuanceSet.h>
50#include <xrpld/app/tx/detail/NFTokenAcceptOffer.h>
51#include <xrpld/app/tx/detail/NFTokenBurn.h>
52#include <xrpld/app/tx/detail/NFTokenCancelOffer.h>
53#include <xrpld/app/tx/detail/NFTokenCreateOffer.h>
54#include <xrpld/app/tx/detail/NFTokenMint.h>
55#include <xrpld/app/tx/detail/NFTokenModify.h>
56#include <xrpld/app/tx/detail/PayChan.h>
57#include <xrpld/app/tx/detail/Payment.h>
58#include <xrpld/app/tx/detail/PermissionedDomainDelete.h>
59#include <xrpld/app/tx/detail/PermissionedDomainSet.h>
60#include <xrpld/app/tx/detail/SetAccount.h>
61#include <xrpld/app/tx/detail/SetOracle.h>
62#include <xrpld/app/tx/detail/SetRegularKey.h>
63#include <xrpld/app/tx/detail/SetSignerList.h>
64#include <xrpld/app/tx/detail/SetTrust.h>
65#include <xrpld/app/tx/detail/VaultClawback.h>
66#include <xrpld/app/tx/detail/VaultCreate.h>
67#include <xrpld/app/tx/detail/VaultDelete.h>
68#include <xrpld/app/tx/detail/VaultDeposit.h>
69#include <xrpld/app/tx/detail/VaultSet.h>
70#include <xrpld/app/tx/detail/VaultWithdraw.h>
71#include <xrpld/app/tx/detail/XChainBridge.h>
73#include <xrpl/protocol/TxFormats.h>
84 UnknownTxnType(
TxType t) : txnType{t}
93with_txn_type(
TxType txnType, F&& f)
97#pragma push_macro("TRANSACTION")
100#define TRANSACTION(tag, value, name, ...) \
102 return f.template operator()<name>();
104#include <xrpl/protocol/detail/transactions.macro>
107#pragma pop_macro("TRANSACTION")
109 throw UnknownTxnType(txnType);
149 return T::makeTxConsequences(ctx);
158 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
159 auto const tec = T::preflight(ctx);
160 return std::make_pair(
162 isTesSuccess(tec) ? consequences_helper<T>(ctx)
163 : TxConsequences{tec});
166 catch (UnknownTxnType
const& e)
170 <<
"Unknown transaction type in preflight: " << e.txnType;
171 UNREACHABLE(
"ripple::invoke_preflight : unknown transaction type");
183 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
187 auto const id = ctx.tx.getAccountID(sfAccount);
189 if (id != beast::zero)
191 TER result = T::checkSeqProxy(ctx.view, ctx.tx, ctx.j);
193 if (result != tesSUCCESS)
196 result = T::checkPriorTxAndLastLedger(ctx);
198 if (result != tesSUCCESS)
201 result = T::checkFee(ctx, calculateBaseFee(ctx.view, ctx.tx));
203 if (result != tesSUCCESS)
206 result = T::checkPermission(ctx.view, ctx.tx);
208 if (result != tesSUCCESS)
211 result = T::checkSign(ctx);
213 if (result != tesSUCCESS)
217 return T::preclaim(ctx);
220 catch (UnknownTxnType
const& e)
224 <<
"Unknown transaction type in preclaim: " << e.txnType;
225 UNREACHABLE(
"ripple::invoke_preclaim : unknown transaction type");
251 return with_txn_type(tx.
getTxnType(), [&]<
typename T>() {
252 return T::calculateBaseFee(view, tx);
255 catch (UnknownTxnType
const& e)
258 "ripple::invoke_calculateBaseFee : unknown transaction type");
263TxConsequences::TxConsequences(
NotTEC pfresult)
266 , potentialSpend_(
beast::zero)
268 , sequencesConsumed_(0)
272 "ripple::TxConsequences::TxConsequences : is not tesSUCCESS");
278 tx[sfFee].native() && !tx[sfFee].negative() ? tx[sfFee].xrp()
280 , potentialSpend_(
beast::zero)
281 , seqProx_(tx.getSeqProxy())
282 , sequencesConsumed_(tx.getSeqProxy().isSeq() ? 1 : 0)
309 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
314 catch (UnknownTxnType
const& e)
318 <<
"Unknown transaction type in apply: " << e.txnType;
319 UNREACHABLE(
"ripple::invoke_apply : unknown transaction type");
339 JLOG(j.
fatal()) <<
"apply (preflight): " << e.
what();
360 JLOG(j.
fatal()) <<
"apply (preflight): " << e.
what();
374 auto secondFlight = [&]() {
381 preflightResult.
flags,
388 preflightResult.
flags,
398 secondFlight.parentBatchId,
408 preflightResult.
flags,
416 return {*ctx, ctx->preflightResult};
421 JLOG(ctx->j.fatal()) <<
"apply (preclaim): " << e.
what();
450 return {preclaimResult.
ter,
false};
458 preclaimResult.
flags,
464 JLOG(preclaimResult.
j.
fatal()) <<
"apply: " << e.
what();
A generic endpoint for log messages.
State information when applying a tx.
beast::Journal const journal
Writable ledger view that accumulates state and tx changes.
Rules const & rules() const override
Returns the tx processing rules.
LedgerIndex seq() const
Returns the sequence number of the base ledger.
Rules controlling protocol behavior.
TxType getTxnType() const
A type that represents either a sequence value or a ticket value.
static XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
Class describing the consequences to the account of applying a transaction if the transaction consume...
std::uint32_t sequencesConsumed() const
Sequences consumed.
TxConsequences(NotTEC pfresult)
std::uint32_t sequencesConsumed_
Number of sequences consumed.
XRPAmount const & potentialSpend() const
Potential Spend.
bool isBlocker_
Describes how the transaction affects subsequent transactions.
Category
Describes how the transaction affects subsequent transactions.
@ blocker
Affects the ability of subsequent transactions to claim a fee.
XRPAmount potentialSpend_
Does NOT include the fee.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
PreflightResult preflight(Application &app, Rules const &rules, STTx const &tx, ApplyFlags flags, beast::Journal j)
Gate a transaction based on static information.
ApplyResult doApply(PreclaimResult const &preclaimResult, Application &app, OpenView &view)
Apply a prechecked transaction to an OpenView.
TxType
Transaction type identifiers.
XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
Compute only the expected base fee for a transaction.
static XRPAmount invoke_calculateBaseFee(ReadView const &view, STTx const &tx)
Calculates the base fee for a given transaction.
PreclaimResult preclaim(PreflightResult const &preflightResult, Application &app, OpenView const &view)
Gate a transaction based on static ledger information.
static std::pair< NotTEC, TxConsequences > invoke_preflight(PreflightContext const &ctx)
static TER invoke_preclaim(PreclaimContext const &ctx)
bool isTesSuccess(TER x) noexcept
static ApplyResult invoke_apply(ApplyContext &ctx)
TERSubset< CanCvtToTER > TER
TxConsequences consequences_helper(PreflightContext const &ctx)
XRPAmount calculateDefaultBaseFee(ReadView const &view, STTx const &tx)
Return the minimum fee that an "ordinary" transaction would pay.
State information when determining if a tx is likely to claim a fee.
Describes the results of the preclaim check.
ApplyFlags const flags
From the input - the flags.
TER const ter
Intermediate transaction result.
bool const likelyToClaimFee
Success flag - whether the transaction is likely to claim a fee.
ReadView const & view
From the input - the ledger view.
beast::Journal const j
From the input - the journal.
std::optional< uint256 const > const parentBatchId
From the input - the batch identifier, if part of a batch.
STTx const & tx
From the input - the transaction.
State information when preflighting a tx.
Describes the results of the preflight check.
Rules const rules
From the input - the rules.
ApplyFlags const flags
From the input - the flags.
beast::Journal const j
From the input - the journal.
NotTEC const ter
Intermediate transaction result.
std::optional< uint256 const > const parentBatchId
From the input - the batch identifier, if part of a batch.
STTx const & tx
From the input - the transaction.