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(
TxType txnType, F&& f)
41#pragma push_macro("TRANSACTION")
44#define TRANSACTION(tag, value, name, ...) \
46 return f.template operator()<name>();
48#include <xrpl/protocol/detail/transactions.macro>
51#pragma pop_macro("TRANSACTION")
53 throw UnknownTxnType(txnType);
93 return T::makeTxConsequences(ctx);
102 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
103 auto const tec = Transactor::invokePreflight<T>(ctx);
104 return std::make_pair(
106 isTesSuccess(tec) ? consequences_helper<T>(ctx)
107 : TxConsequences{tec});
110 catch (UnknownTxnType
const& e)
115 <<
"Unknown transaction type in preflight: " << e.txnType;
116 UNREACHABLE(
"ripple::invoke_preflight : unknown transaction type");
142 auto const id = ctx.tx.getAccountID(sfAccount);
144 if (id != beast::zero)
146 if (NotTEC const preSigResult = [&]() -> NotTEC {
147 if (NotTEC const result =
148 T::checkSeqProxy(ctx.view, ctx.tx, ctx.j))
151 if (NotTEC const result =
152 T::checkPriorTxAndLastLedger(ctx))
155 if (NotTEC const result =
156 T::checkPermission(ctx.view, ctx.tx))
159 if (NotTEC const result = T::checkSign(ctx))
166 if (TER const result =
167 T::checkFee(ctx, calculateBaseFee(ctx.view, ctx.tx)))
171 return T::preclaim(ctx);
174 catch (UnknownTxnType
const& e)
179 <<
"Unknown transaction type in preclaim: " << e.txnType;
180 UNREACHABLE(
"ripple::invoke_preclaim : unknown transaction type");
207 return with_txn_type(tx.
getTxnType(), [&]<
typename T>() {
208 return T::calculateBaseFee(view, tx);
211 catch (UnknownTxnType
const& e)
215 "ripple::invoke_calculateBaseFee : unknown transaction type");
221TxConsequences::TxConsequences(
NotTEC pfresult)
224 , potentialSpend_(
beast::zero)
226 , sequencesConsumed_(0)
230 "ripple::TxConsequences::TxConsequences : is not tesSUCCESS");
236 tx[sfFee].native() && !tx[sfFee].negative() ? tx[sfFee].xrp()
238 , potentialSpend_(
beast::zero)
239 , seqProx_(tx.getSeqProxy())
240 , sequencesConsumed_(tx.getSeqProxy().isSeq() ? 1 : 0)
267 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
272 catch (UnknownTxnType
const& e)
277 <<
"Unknown transaction type in apply: " << e.txnType;
278 UNREACHABLE(
"ripple::invoke_apply : unknown transaction type");
299 JLOG(j.
fatal()) <<
"apply (preflight): " << e.
what();
320 JLOG(j.
fatal()) <<
"apply (preflight): " << e.
what();
334 auto secondFlight = [&]() {
341 preflightResult.
flags,
348 preflightResult.
flags,
358 secondFlight.parentBatchId,
368 preflightResult.
flags,
376 return {*ctx, ctx->preflightResult};
381 JLOG(ctx->j.fatal()) <<
"apply (preclaim): " << e.
what();
410 return {preclaimResult.
ter,
false};
418 preclaimResult.
flags,
424 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.