20 #include <ripple/app/tx/applySteps.h>
21 #include <ripple/app/tx/impl/AMMBid.h>
22 #include <ripple/app/tx/impl/AMMCreate.h>
23 #include <ripple/app/tx/impl/AMMDelete.h>
24 #include <ripple/app/tx/impl/AMMDeposit.h>
25 #include <ripple/app/tx/impl/AMMVote.h>
26 #include <ripple/app/tx/impl/AMMWithdraw.h>
27 #include <ripple/app/tx/impl/ApplyContext.h>
28 #include <ripple/app/tx/impl/CancelCheck.h>
29 #include <ripple/app/tx/impl/CancelOffer.h>
30 #include <ripple/app/tx/impl/CashCheck.h>
31 #include <ripple/app/tx/impl/Change.h>
32 #include <ripple/app/tx/impl/Clawback.h>
33 #include <ripple/app/tx/impl/CreateCheck.h>
34 #include <ripple/app/tx/impl/CreateOffer.h>
35 #include <ripple/app/tx/impl/CreateTicket.h>
36 #include <ripple/app/tx/impl/DID.h>
37 #include <ripple/app/tx/impl/DeleteAccount.h>
38 #include <ripple/app/tx/impl/DepositPreauth.h>
39 #include <ripple/app/tx/impl/Escrow.h>
40 #include <ripple/app/tx/impl/NFTokenAcceptOffer.h>
41 #include <ripple/app/tx/impl/NFTokenBurn.h>
42 #include <ripple/app/tx/impl/NFTokenCancelOffer.h>
43 #include <ripple/app/tx/impl/NFTokenCreateOffer.h>
44 #include <ripple/app/tx/impl/NFTokenMint.h>
45 #include <ripple/app/tx/impl/PayChan.h>
46 #include <ripple/app/tx/impl/Payment.h>
47 #include <ripple/app/tx/impl/SetAccount.h>
48 #include <ripple/app/tx/impl/SetRegularKey.h>
49 #include <ripple/app/tx/impl/SetSignerList.h>
50 #include <ripple/app/tx/impl/SetTrust.h>
51 #include <ripple/app/tx/impl/XChainBridge.h>
52 #include <ripple/protocol/TxFormats.h>
63 UnknownTxnType(
TxType t) : txnType{t}
72 with_txn_type(
TxType txnType, F&& f)
77 return f.template operator()<DeleteAccount>();
79 return f.template operator()<SetAccount>();
81 return f.template operator()<CancelCheck>();
83 return f.template operator()<CashCheck>();
85 return f.template operator()<CreateCheck>();
87 return f.template operator()<DepositPreauth>();
89 return f.template operator()<CancelOffer>();
91 return f.template operator()<CreateOffer>();
93 return f.template operator()<EscrowCreate>();
95 return f.template operator()<EscrowFinish>();
97 return f.template operator()<EscrowCancel>();
99 return f.template operator()<PayChanClaim>();
101 return f.template operator()<PayChanCreate>();
103 return f.template operator()<PayChanFund>();
105 return f.template operator()<Payment>();
107 return f.template operator()<SetRegularKey>();
109 return f.template operator()<SetSignerList>();
111 return f.template operator()<CreateTicket>();
113 return f.template operator()<SetTrust>();
117 return f.template operator()<Change>();
119 return f.template operator()<NFTokenMint>();
121 return f.template operator()<NFTokenBurn>();
123 return f.template operator()<NFTokenCreateOffer>();
125 return f.template operator()<NFTokenCancelOffer>();
127 return f.template operator()<NFTokenAcceptOffer>();
129 return f.template operator()<Clawback>();
131 return f.template operator()<AMMCreate>();
133 return f.template operator()<AMMDeposit>();
135 return f.template operator()<AMMWithdraw>();
137 return f.template operator()<AMMVote>();
139 return f.template operator()<AMMBid>();
141 return f.template operator()<AMMDelete>();
143 return f.template operator()<XChainCreateBridge>();
145 return f.template operator()<BridgeModify>();
147 return f.template operator()<XChainCreateClaimID>();
149 return f.template operator()<XChainCommit>();
151 return f.template operator()<XChainClaim>();
153 return f.template operator()<XChainAddClaimAttestation>();
155 return f.template operator()<XChainAddAccountCreateAttestation>();
157 return f.template operator()<XChainCreateAccountCommit>();
159 return f.template operator()<DIDSet>();
161 return f.template operator()<DIDDelete>();
163 throw UnknownTxnType(txnType);
192 consequences_helper(PreflightContext
const& ctx)
201 consequences_helper(PreflightContext
const& ctx)
203 return T::makeTxConsequences(ctx);
212 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
213 auto const tec = T::preflight(ctx);
214 return std::make_pair(
216 isTesSuccess(tec) ? consequences_helper<T>(ctx)
217 : TxConsequences{tec});
220 catch (UnknownTxnType
const& e)
224 <<
"Unknown transaction type in preflight: " << e.txnType;
237 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
241 auto const id = ctx.tx.getAccountID(sfAccount);
243 if (id != beast::zero)
245 TER result = T::checkSeqProxy(ctx.view, ctx.tx, ctx.j);
247 if (result != tesSUCCESS)
250 result = T::checkPriorTxAndLastLedger(ctx);
252 if (result != tesSUCCESS)
255 result = T::checkFee(ctx, calculateBaseFee(ctx.view, ctx.tx));
257 if (result != tesSUCCESS)
260 result = T::checkSign(ctx);
262 if (result != tesSUCCESS)
266 return T::preclaim(ctx);
269 catch (UnknownTxnType
const& e)
273 <<
"Unknown transaction type in preclaim: " << e.txnType;
284 return with_txn_type(tx.
getTxnType(), [&]<
typename T>() {
285 return T::calculateBaseFee(view, tx);
288 catch (UnknownTxnType
const& e)
295 TxConsequences::TxConsequences(
NotTEC pfresult)
298 , potentialSpend_(
beast::zero)
300 , sequencesConsumed_(0)
310 , potentialSpend_(
beast::zero)
311 , seqProx_(tx.getSeqProxy())
312 , sequencesConsumed_(tx.getSeqProxy().isSeq() ? 1 : 0)
339 return with_txn_type(ctx.
tx.
getTxnType(), [&]<
typename T>() {
344 catch (UnknownTxnType
const& e)
348 <<
"Unknown transaction type in apply: " << e.txnType;
369 JLOG(j.
fatal()) <<
"apply: " << e.
what();
387 preflightResult.
flags,
404 preflightResult.
flags,
410 return {*ctx, ctx->preflightResult};
415 JLOG(ctx->j.fatal()) <<
"apply: " << e.
what();
444 return {preclaimResult.
ter,
false};
451 preclaimResult.
flags,
457 JLOG(preclaimResult.
j.
fatal()) <<
"apply: " << e.
what();
TxType getTxnType() const
@ ttNFTOKEN_CREATE_OFFER
This transaction creates a new offer to buy or sell an NFT.
ReadView const & view
From the input - the ledger view.
@ ttACCOUNT_DELETE
This transaction type deletes an existing account.
@ ttAMM_DELETE
This transaction type deletes AMM in the empty state.
const beast::Journal j
From the input - the journal.
TxConsequences(NotTEC pfresult)
@ ttREGULAR_KEY_SET
This transaction type sets or clears an account's "regular key".
@ ttCLAWBACK
This transaction claws back issued tokens.
@ ttSIGNER_LIST_SET
This transaction type modifies the signer list associated with an account.
@ ttXCHAIN_CLAIM
This transaction completes a crosschain transaction.
@ ttESCROW_CANCEL
This transaction type cancels an existing escrow.
Writable ledger view that accumulates state and tx changes.
@ ttXCHAIN_CREATE_BRIDGE
This transactions creates a sidechain.
@ ttFEE
This system-generated transaction type is used to update the network's fee settings.
@ ttAMM_DEPOSIT
This transaction type deposits into an AMM instance.
Category
Describes how the transaction affects subsequent transactions.
@ ttOFFER_CANCEL
This transaction type cancels existing offers to trade one asset for another.
@ ttPAYCHAN_CREATE
This transaction type creates a new unidirectional XRP payment channel.
TxType
Transaction type identifiers.
static XRPAmount invoke_calculateBaseFee(ReadView const &view, STTx const &tx)
const beast::Journal journal
@ ttXCHAIN_CREATE_CLAIM_ID
This transactions creates a crosschain sequence number.
STTx const & tx
From the input - the transaction.
PreflightResult preflight(Application &app, Rules const &rules, STTx const &tx, ApplyFlags flags, beast::Journal j)
Gate a transaction based on static information.
@ ttDID_SET
This transaction type creates or updates a DID.
@ ttNFTOKEN_ACCEPT_OFFER
This transaction accepts an existing offer to buy or sell an existing NFT.
@ ttAMENDMENT
This system-generated transaction type is used to update the status of the various amendments.
const bool likelyToClaimFee
Success flag - whether the transaction is likely to claim a fee.
const TER ter
Intermediate transaction result.
requires(T::ConsequencesFactory==Transactor::Normal) TxConsequences consequences_helper(PreflightContext const &ctx)
static TER invoke_preclaim(PreclaimContext const &ctx)
@ ttCHECK_CANCEL
This transaction type cancels an existing check.
@ ttPAYMENT
This transaction type executes a payment.
static XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
@ ttUNL_MODIFY
This system-generated transaction type is used to update the network's negative UNL.
std::pair< TER, bool > doApply(PreclaimResult const &preclaimResult, Application &app, OpenView &view)
Apply a prechecked transaction to an OpenView.
@ ttCHECK_CREATE
This transaction type creates a new check.
Describes the results of the preflight check.
@ ttXCHAIN_COMMIT
This transactions initiates a crosschain transaction.
@ ttAMM_CREATE
This transaction type creates an AMM instance.
XRPAmount const & potentialSpend() const
Potential Spend.
const Rules rules
From the input - the rules.
@ ttTRUST_SET
This transaction type modifies a trustline between two accounts.
@ blocker
Affects the ability of subsequent transactions to claim a fee.
const NotTEC ter
Intermediate transaction result.
@ ttNFTOKEN_MINT
This transaction mints a new NFT.
@ ttESCROW_CREATE
This transaction type creates an escrow object.
TERSubset< CanCvtToTER > TER
@ ttXCHAIN_MODIFY_BRIDGE
This transaction modifies a sidechain.
@ ttAMM_WITHDRAW
This transaction type withdraws from an AMM instance.
@ ttESCROW_FINISH
This transaction type completes an existing escrow.
State information when applying a tx.
A generic endpoint for log messages.
@ ttXCHAIN_ACCOUNT_CREATE_COMMIT
This transaction initiates a crosschain account create transaction.
@ ttDID_DELETE
This transaction type deletes a DID.
bool isBlocker_
Describes how the transaction affects subsequent transactions.
@ ttNFTOKEN_CANCEL_OFFER
This transaction cancels an existing offer to buy or sell an existing NFT.
@ ttOFFER_CREATE
This transaction type creates an offer to trade one asset for another.
static std::pair< TER, bool > invoke_apply(ApplyContext &ctx)
State information when determining if a tx is likely to claim a fee.
XRPAmount calculateDefaultBaseFee(ReadView const &view, STTx const &tx)
Return the minimum fee that an "ordinary" transaction would pay.
@ ttACCOUNT_SET
This transaction type adjusts various account settings.
PreclaimResult preclaim(PreflightResult const &preflightResult, Application &app, OpenView const &view)
Gate a transaction based on static ledger information.
std::uint32_t sequencesConsumed() const
Sequences consumed.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
LedgerIndex seq() const
Returns the sequence number of the base ledger.
@ ttDEPOSIT_PREAUTH
This transaction type grants or revokes authorization to transfer funds.
@ ttCHECK_CASH
This transaction type cashes an existing check.
Describes the results of the preclaim check.
@ ttPAYCHAN_FUND
This transaction type funds an existing unidirectional XRP payment channel.
A type that represents either a sequence value or a ticket value.
XRPAmount potentialSpend_
Does NOT include the fee.
@ ttAMM_VOTE
This transaction type votes for the trading fee.
@ ttPAYCHAN_CLAIM
This transaction type submits a claim against an existing unidirectional payment channel.
Rules controlling protocol behavior.
XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
Compute only the expected base fee for a transaction.
@ ttNFTOKEN_BURN
This transaction burns (i.e.
const ApplyFlags flags
From the input - the flags.
const ApplyFlags flags
From the input - the flags.
std::uint32_t sequencesConsumed_
Number of sequences consumed.
State information when preflighting a tx.
Class describing the consequences to the account of applying a transaction if the transaction consume...
Rules const & rules() const override
Returns the tx processing rules.
static std::pair< NotTEC, TxConsequences > invoke_preflight(PreflightContext const &ctx)
@ ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION
This transaction adds an attestation to a claimid.
@ ttTICKET_CREATE
This transaction type creates a new set of tickets.
STTx const & tx
From the input - the transaction.
@ ttAMM_BID
This transaction type bids for the auction slot.
const beast::Journal j
From the input - the journal.
@ ttXCHAIN_ADD_CLAIM_ATTESTATION
This transaction adds an attestation to a claimid.