20#include <xrpld/app/tx/applySteps.h>
21#pragma push_macro("TRANSACTION")
25#define TRANSACTION(...)
26#define TRANSACTION_INCLUDE 1
28#include <xrpl/protocol/detail/transactions.macro>
31#pragma pop_macro("TRANSACTION")
36#include <xrpl/protocol/TxFormats.h>
47 UnknownTxnType(
TxType t) : txnType{t}
56with_txn_type(
TxType txnType, F&& f)
60#pragma push_macro("TRANSACTION")
63#define TRANSACTION(tag, value, name, ...) \
65 return f.template operator()<name>();
67#include <xrpl/protocol/detail/transactions.macro>
70#pragma pop_macro("TRANSACTION")
72 throw UnknownTxnType(txnType);
112 return T::makeTxConsequences(ctx);
121 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
122 auto const tec = T::preflight(ctx);
123 return std::make_pair(
125 isTesSuccess(tec) ? consequences_helper<T>(ctx)
126 : TxConsequences{tec});
129 catch (UnknownTxnType
const& e)
133 <<
"Unknown transaction type in preflight: " << e.txnType;
134 UNREACHABLE(
"ripple::invoke_preflight : unknown transaction type");
146 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
150 auto const id = ctx.tx.getAccountID(sfAccount);
152 if (id != beast::zero)
154 TER result = T::checkSeqProxy(ctx.view, ctx.tx, ctx.j);
156 if (result != tesSUCCESS)
159 result = T::checkPriorTxAndLastLedger(ctx);
161 if (result != tesSUCCESS)
164 result = T::checkFee(ctx, calculateBaseFee(ctx.view, ctx.tx));
166 if (result != tesSUCCESS)
169 result = T::checkPermission(ctx.view, ctx.tx);
171 if (result != tesSUCCESS)
174 result = T::checkSign(ctx);
176 if (result != tesSUCCESS)
180 return T::preclaim(ctx);
183 catch (UnknownTxnType
const& e)
187 <<
"Unknown transaction type in preclaim: " << e.txnType;
188 UNREACHABLE(
"ripple::invoke_preclaim : unknown transaction type");
214 return with_txn_type(tx.
getTxnType(), [&]<
typename T>() {
215 return T::calculateBaseFee(view, tx);
218 catch (UnknownTxnType
const& e)
221 "ripple::invoke_calculateBaseFee : unknown transaction type");
226TxConsequences::TxConsequences(
NotTEC pfresult)
229 , potentialSpend_(
beast::zero)
231 , sequencesConsumed_(0)
235 "ripple::TxConsequences::TxConsequences : is not tesSUCCESS");
241 tx[sfFee].native() && !tx[sfFee].negative() ? tx[sfFee].xrp()
243 , potentialSpend_(
beast::zero)
244 , seqProx_(tx.getSeqProxy())
245 , sequencesConsumed_(tx.getSeqProxy().isSeq() ? 1 : 0)
272 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
277 catch (UnknownTxnType
const& e)
281 <<
"Unknown transaction type in apply: " << e.txnType;
282 UNREACHABLE(
"ripple::invoke_apply : unknown transaction type");
302 JLOG(j.
fatal()) <<
"apply (preflight): " << e.
what();
323 JLOG(j.
fatal()) <<
"apply (preflight): " << e.
what();
337 auto secondFlight = [&]() {
344 preflightResult.
flags,
351 preflightResult.
flags,
361 secondFlight.parentBatchId,
371 preflightResult.
flags,
379 return {*ctx, ctx->preflightResult};
384 JLOG(ctx->j.fatal()) <<
"apply (preclaim): " << e.
what();
413 return {preclaimResult.
ter,
false};
421 preclaimResult.
flags,
427 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.