1#include <xrpld/app/tx/applySteps.h>
2#pragma push_macro("TRANSACTION")
6#define TRANSACTION(...)
7#define TRANSACTION_INCLUDE 1
9#include <xrpl/protocol/detail/transactions.macro>
12#pragma pop_macro("TRANSACTION")
17#include <xrpl/protocol/TxFormats.h>
28 UnknownTxnType(
TxType t) : txnType{t}
37with_txn_type(Rules
const& rules,
TxType txnType, F&& f)
55 if (rules.enabled(featureSingleAssetVault) || rules.enabled(featureLendingProtocol))
59 stNumberSO.
emplace(rules.enabled(fixUniversalNumber));
70#pragma push_macro("TRANSACTION")
73#define TRANSACTION(tag, value, name, ...) \
75 return f.template operator()<name>();
77#include <xrpl/protocol/detail/transactions.macro>
80#pragma pop_macro("TRANSACTION")
82 throw UnknownTxnType(txnType);
122 return T::makeTxConsequences(ctx);
132 auto const tec = Transactor::invokePreflight<T>(ctx);
133 return std::make_pair(tec, isTesSuccess(tec) ? consequences_helper<T>(ctx) : TxConsequences{tec});
136 catch (UnknownTxnType
const& e)
140 JLOG(ctx.
j.
fatal()) <<
"Unknown transaction type in preflight: " << e.txnType;
141 UNREACHABLE(
"xrpl::invoke_preflight : unknown transaction type");
167 auto const id = ctx.tx.getAccountID(sfAccount);
169 if (id != beast::zero)
171 if (NotTEC const preSigResult = [&]() -> NotTEC {
172 if (NotTEC const result = T::checkSeqProxy(ctx.view, ctx.tx, ctx.j))
175 if (NotTEC const result = T::checkPriorTxAndLastLedger(ctx))
178 if (NotTEC const result = T::checkPermission(ctx.view, ctx.tx))
181 if (NotTEC const result = T::checkSign(ctx))
188 if (TER const result = T::checkFee(ctx, calculateBaseFee(ctx.view, ctx.tx)))
192 return T::preclaim(ctx);
195 catch (UnknownTxnType
const& e)
199 JLOG(ctx.
j.
fatal()) <<
"Unknown transaction type in preclaim: " << e.txnType;
200 UNREACHABLE(
"xrpl::invoke_preclaim : unknown transaction type");
227 return with_txn_type(
228 view.
rules(), tx.
getTxnType(), [&]<
typename T>() { return T::calculateBaseFee(view, tx); });
230 catch (UnknownTxnType
const& e)
233 UNREACHABLE(
"xrpl::invoke_calculateBaseFee : unknown transaction type");
239TxConsequences::TxConsequences(
NotTEC pfResult)
242 , potentialSpend_(
beast::zero)
244 , sequencesConsumed_(0)
246 XRPL_ASSERT(!
isTesSuccess(pfResult),
"xrpl::TxConsequences::TxConsequences : is not tesSUCCESS");
251 , fee_(tx[sfFee].native() && !tx[sfFee].negative() ? tx[sfFee].xrp() :
beast::zero)
252 , potentialSpend_(
beast::zero)
253 , seqProx_(tx.getSeqProxy())
254 , sequencesConsumed_(tx.getSeqProxy().isSeq() ? 1 : 0)
283 catch (UnknownTxnType
const& e)
287 JLOG(ctx.
journal.
fatal()) <<
"Unknown transaction type in apply: " << e.txnType;
288 UNREACHABLE(
"xrpl::invoke_apply : unknown transaction type");
304 JLOG(j.
fatal()) <<
"apply (preflight): " << e.
what();
325 JLOG(j.
fatal()) <<
"apply (preflight): " << e.
what();
336 auto secondFlight = [&]() {
343 preflightResult.
flags,
355 secondFlight.parentBatchId,
365 preflightResult.
flags,
373 return {*ctx, ctx->preflightResult};
378 JLOG(ctx->j.fatal()) <<
"apply (preclaim): " << e.
what();
407 return {preclaimResult.
ter,
false};
415 preclaimResult.
flags,
421 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.
virtual Rules const & rules() const =0
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...
TxConsequences(NotTEC pfResult)
std::uint32_t sequencesConsumed_
Number of sequences consumed.
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.
bool isBlocker_
Describes how the transaction affects subsequent transactions.
std::uint32_t sequencesConsumed() const
Sequences consumed.
XRPAmount const & potentialSpend() const
Potential Spend.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
static XRPAmount invoke_calculateBaseFee(ReadView const &view, STTx const &tx)
Calculates the base fee for a given transaction.
TxType
Transaction type identifiers.
static ApplyResult invoke_apply(ApplyContext &ctx)
PreflightResult preflight(Application &app, Rules const &rules, STTx const &tx, ApplyFlags flags, beast::Journal j)
Gate a transaction based on static information.
static std::pair< NotTEC, TxConsequences > invoke_preflight(PreflightContext const &ctx)
static TER invoke_preclaim(PreclaimContext const &ctx)
TERSubset< CanCvtToTER > TER
TxConsequences consequences_helper(PreflightContext const &ctx)
ApplyResult doApply(PreclaimResult const &preclaimResult, Application &app, OpenView &view)
Apply a prechecked transaction to an OpenView.
XRPAmount calculateDefaultBaseFee(ReadView const &view, STTx const &tx)
Return the minimum fee that an "ordinary" transaction would pay.
bool isTesSuccess(TER x) noexcept
PreclaimResult preclaim(PreflightResult const &preflightResult, Application &app, OpenView const &view)
Gate a transaction based on static ledger information.
XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
Compute only the expected base fee for a transaction.
State information when determining if a tx is likely to claim a fee.
Describes the results of the preclaim check.
ReadView const & view
From the input - the ledger view.
std::optional< uint256 const > const parentBatchId
From the input - the batch identifier, if part of a batch.
TER const ter
Intermediate transaction result.
ApplyFlags const flags
From the input - the flags.
STTx const & tx
From the input - the transaction.
beast::Journal const j
From the input - the journal.
bool const likelyToClaimFee
Success flag - whether the transaction is likely to claim a fee.
State information when preflighting a tx.
Describes the results of the preflight check.
beast::Journal const j
From the input - the journal.
ApplyFlags const flags
From the input - the flags.
Rules const rules
From the input - the rules.
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.