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/CancelCheck.h>
30#include <xrpld/app/tx/detail/CancelOffer.h>
31#include <xrpld/app/tx/detail/CashCheck.h>
32#include <xrpld/app/tx/detail/Change.h>
33#include <xrpld/app/tx/detail/Clawback.h>
34#include <xrpld/app/tx/detail/CreateCheck.h>
35#include <xrpld/app/tx/detail/CreateOffer.h>
36#include <xrpld/app/tx/detail/CreateTicket.h>
37#include <xrpld/app/tx/detail/Credentials.h>
38#include <xrpld/app/tx/detail/DID.h>
39#include <xrpld/app/tx/detail/DelegateSet.h>
40#include <xrpld/app/tx/detail/DeleteAccount.h>
41#include <xrpld/app/tx/detail/DeleteOracle.h>
42#include <xrpld/app/tx/detail/DepositPreauth.h>
43#include <xrpld/app/tx/detail/Escrow.h>
44#include <xrpld/app/tx/detail/LedgerStateFix.h>
45#include <xrpld/app/tx/detail/MPTokenAuthorize.h>
46#include <xrpld/app/tx/detail/MPTokenIssuanceCreate.h>
47#include <xrpld/app/tx/detail/MPTokenIssuanceDestroy.h>
48#include <xrpld/app/tx/detail/MPTokenIssuanceSet.h>
49#include <xrpld/app/tx/detail/NFTokenAcceptOffer.h>
50#include <xrpld/app/tx/detail/NFTokenBurn.h>
51#include <xrpld/app/tx/detail/NFTokenCancelOffer.h>
52#include <xrpld/app/tx/detail/NFTokenCreateOffer.h>
53#include <xrpld/app/tx/detail/NFTokenMint.h>
54#include <xrpld/app/tx/detail/NFTokenModify.h>
55#include <xrpld/app/tx/detail/PayChan.h>
56#include <xrpld/app/tx/detail/Payment.h>
57#include <xrpld/app/tx/detail/PermissionedDomainDelete.h>
58#include <xrpld/app/tx/detail/PermissionedDomainSet.h>
59#include <xrpld/app/tx/detail/SetAccount.h>
60#include <xrpld/app/tx/detail/SetOracle.h>
61#include <xrpld/app/tx/detail/SetRegularKey.h>
62#include <xrpld/app/tx/detail/SetSignerList.h>
63#include <xrpld/app/tx/detail/SetTrust.h>
64#include <xrpld/app/tx/detail/XChainBridge.h>
66#include <xrpl/protocol/TxFormats.h>
77 UnknownTxnType(
TxType t) : txnType{t}
86with_txn_type(
TxType txnType, F&& f)
90#pragma push_macro("TRANSACTION")
93#define TRANSACTION(tag, value, name, delegatable, fields) \
95 return f.template operator()<name>();
97#include <xrpl/protocol/detail/transactions.macro>
100#pragma pop_macro("TRANSACTION")
103 throw UnknownTxnType(txnType);
143 return T::makeTxConsequences(ctx);
152 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
153 auto const tec = T::preflight(ctx);
154 return std::make_pair(
156 isTesSuccess(tec) ? consequences_helper<T>(ctx)
157 : TxConsequences{tec});
160 catch (UnknownTxnType
const& e)
164 <<
"Unknown transaction type in preflight: " << e.txnType;
165 UNREACHABLE(
"ripple::invoke_preflight : unknown transaction type");
177 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
181 auto const id = ctx.tx.getAccountID(sfAccount);
183 if (id != beast::zero)
185 TER result = T::checkSeqProxy(ctx.view, ctx.tx, ctx.j);
187 if (result != tesSUCCESS)
190 result = T::checkPriorTxAndLastLedger(ctx);
192 if (result != tesSUCCESS)
195 result = T::checkFee(ctx, calculateBaseFee(ctx.view, ctx.tx));
197 if (result != tesSUCCESS)
200 result = T::checkPermission(ctx.view, ctx.tx);
202 if (result != tesSUCCESS)
205 result = T::checkSign(ctx);
207 if (result != tesSUCCESS)
211 return T::preclaim(ctx);
214 catch (UnknownTxnType
const& e)
218 <<
"Unknown transaction type in preclaim: " << e.txnType;
219 UNREACHABLE(
"ripple::invoke_preclaim : unknown transaction type");
229 return with_txn_type(tx.
getTxnType(), [&]<
typename T>() {
230 return T::calculateBaseFee(view, tx);
233 catch (UnknownTxnType
const& e)
236 "ripple::invoke_calculateBaseFee : unknown transaction type");
241TxConsequences::TxConsequences(
NotTEC pfresult)
244 , potentialSpend_(
beast::zero)
246 , sequencesConsumed_(0)
250 "ripple::TxConsequences::TxConsequences : is not tesSUCCESS");
256 tx[sfFee].native() && !tx[sfFee].negative() ? tx[sfFee].xrp()
258 , potentialSpend_(
beast::zero)
259 , seqProx_(tx.getSeqProxy())
260 , sequencesConsumed_(tx.getSeqProxy().isSeq() ? 1 : 0)
287 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
292 catch (UnknownTxnType
const& e)
296 <<
"Unknown transaction type in apply: " << e.txnType;
297 UNREACHABLE(
"ripple::invoke_apply : unknown transaction type");
317 JLOG(j.
fatal()) <<
"apply: " << e.
what();
335 preflightResult.
flags,
352 preflightResult.
flags,
358 return {*ctx, ctx->preflightResult};
363 JLOG(ctx->j.fatal()) <<
"apply: " << e.
what();
392 return {preclaimResult.
ter,
false};
399 preclaimResult.
flags,
405 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)
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)
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.
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.
STTx const & tx
From the input - the transaction.