xrpld
Loading...
Searching...
No Matches
Batch.cpp
1#include <xrpl/tx/transactors/system/Batch.h>
2
3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/beast/utility/Zero.h>
6#include <xrpl/beast/utility/instrumentation.h>
7#include <xrpl/core/ServiceRegistry.h>
8#include <xrpl/ledger/ApplyView.h>
9#include <xrpl/ledger/ReadView.h>
10#include <xrpl/ledger/helpers/SponsorHelpers.h>
11#include <xrpl/protocol/AccountID.h>
12#include <xrpl/protocol/Feature.h>
13#include <xrpl/protocol/Protocol.h>
14#include <xrpl/protocol/SField.h>
15#include <xrpl/protocol/STAccount.h> // IWYU pragma: keep
16#include <xrpl/protocol/STLedgerEntry.h>
17#include <xrpl/protocol/STObject.h>
18#include <xrpl/protocol/STTx.h>
19#include <xrpl/protocol/TER.h>
20#include <xrpl/protocol/TxFlags.h>
21#include <xrpl/protocol/TxFormats.h>
22#include <xrpl/protocol/XRPAmount.h>
23#include <xrpl/tx/Transactor.h>
24#include <xrpl/tx/applySteps.h>
25
26#include <boost/container/small_vector.hpp>
27
28#include <algorithm>
29#include <bit>
30#include <cstddef>
31#include <cstdint>
32#include <flat_set>
33#include <functional>
34#include <limits>
35#include <optional>
36#include <utility>
37#include <vector>
38
39namespace xrpl {
40
41namespace {
42
43// A sorted set with inline storage for up to kMaxBatchTxCount keys. Because the
44// inner transaction count is enforced during STTx construction, we should never
45// exceed the inline storage during preflight, but if we do, it would be safe.
46template <class Key>
47using InlineSet =
48 std::flat_set<Key, std::less<>, boost::container::small_vector<Key, kMaxBatchTxCount>>;
49
50} // namespace
51
66std::optional<XRPAmount>
68{
70
71 // batchBase: view.fees().base for batch processing + default base fee
72 XRPAmount const baseFee = Transactor::calculateBaseFee(view, tx);
73
74 // LCOV_EXCL_START
75 if (baseFee > maxAmount - view.fees().base)
76 {
77 JLOG(debugLog().error()) << "BatchTrace: Base fee overflow detected.";
78 return std::nullopt;
79 }
80 // LCOV_EXCL_STOP
81
82 XRPAmount const batchBase = view.fees().base + baseFee;
83
84 // Calculate the Inner Txn Fees. Inners are built and validated (count,
85 // no nesting) at construction, so they are reused here directly.
86 XRPAmount txnFees{0};
87 for (auto const& stx : tx.getBatchTransactions())
88 {
89 auto const fee = xrpl::calculateBaseFee(view, *stx);
90 if (!fee)
91 {
92 JLOG(debugLog().error())
93 << "BatchTrace: base fee of inner transaction " << stx->getTransactionID()
94 << " could not be computed: " << transToken(fee.error());
95 return std::nullopt;
96 }
97
98 // LCOV_EXCL_START
99 if (txnFees > maxAmount - *fee)
100 {
101 UNREACHABLE("XRPAmount overflow in txnFees calculation");
102 JLOG(debugLog().error()) << "BatchTrace: XRPAmount overflow in txnFees calculation.";
103 return std::nullopt;
104 }
105 // LCOV_EXCL_STOP
106 txnFees += *fee;
107 }
108
109 // Calculate the Signers/BatchSigners Fees
110 std::uint32_t signerCount = 0;
111 if (tx.isFieldPresent(sfBatchSigners))
112 {
113 auto const& signers = tx.getFieldArray(sfBatchSigners);
114
115 // LCOV_EXCL_START
116 if (signers.size() > kMaxBatchSigners)
117 {
118 JLOG(debugLog().error()) << "BatchTrace: Batch Signers array exceeds max entries.";
119 return std::nullopt;
120 }
121 // LCOV_EXCL_STOP
122
123 for (STObject const& signer : signers)
124 {
125 if (signer.isFieldPresent(sfTxnSignature))
126 {
127 signerCount += 1;
128 }
129 else if (signer.isFieldPresent(sfSigners))
130 {
131 auto const& nestedSigners = signer.getFieldArray(sfSigners);
132 // LCOV_EXCL_START
133 if (nestedSigners.size() > STTx::kMaxMultiSigners)
134 {
135 JLOG(debugLog().error())
136 << "BatchTrace: Nested Signers array exceeds max entries.";
137 return std::nullopt;
138 }
139 // LCOV_EXCL_STOP
140 signerCount += nestedSigners.size();
141 }
142 }
143 }
144
145 // LCOV_EXCL_START
146 if (signerCount > 0 && view.fees().base > maxAmount / signerCount)
147 {
148 JLOG(debugLog().error()) << "BatchTrace: XRPAmount overflow in signerCount calculation.";
149 return std::nullopt;
150 }
151 // LCOV_EXCL_STOP
152
153 XRPAmount const signerFees = signerCount * view.fees().base;
154
155 // LCOV_EXCL_START
156 if (signerFees > maxAmount - txnFees)
157 {
158 JLOG(debugLog().error()) << "BatchTrace: XRPAmount overflow in signerFees calculation.";
159 return std::nullopt;
160 }
161 XRPAmount const innerFees = txnFees + signerFees;
162 if (innerFees > maxAmount - batchBase)
163 {
164 JLOG(debugLog().error()) << "BatchTrace: XRPAmount overflow in total fee calculation.";
165 return std::nullopt;
166 }
167 // LCOV_EXCL_STOP
168
169 // 10 drops per batch signature + sum of inner tx fees + batchBase
170 return innerFees + batchBase;
171}
172
175{
176 if (auto const fee = calculateBaseFeeImpl(view, tx))
177 return *fee;
178 // The fee could not be computed, so return a placeholder the account can
179 // pay; preclaim rejects the transaction with tecINSUFF_FEE.
180 return view.fees().base; // LCOV_EXCL_LINE
181}
182
183TER
185{
186 if (!calculateBaseFeeImpl(ctx.view, ctx.tx))
187 return tecINSUFF_FEE; // LCOV_EXCL_LINE
188 return tesSUCCESS;
189}
190
193{
194 return tfBatchMask;
195}
196
231NotTEC
233{
234 auto const parentBatchId = ctx.tx.getTransactionID();
235 auto const flags = ctx.tx.getFlags();
236
237 if (std::popcount(flags & (tfAllOrNothing | tfOnlyOne | tfUntilFailure | tfIndependent)) != 1)
238 {
239 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]:"
240 << "too many flags.";
241 return temINVALID_FLAG;
242 }
243
244 if (ctx.tx.isFieldPresent(sfSponsorFlags))
245 {
246 if (isReserveSponsored(ctx.tx))
247 {
248 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]:"
249 << "spfSponsorReserve is not allowed on outer Batch.";
250 return temINVALID_FLAG;
251 }
252 }
253
254 auto const& rawTxns = ctx.tx.getFieldArray(sfRawTransactions);
255 if (rawTxns.size() <= 1)
256 {
257 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]:"
258 << "txns array must have at least 2 entries.";
259 return temARRAY_EMPTY;
260 }
261
262 if (ctx.tx.isFieldPresent(sfBatchSigners) &&
263 ctx.tx.getFieldArray(sfBatchSigners).size() > kMaxBatchSigners)
264 {
265 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]:"
266 << "signers array exceeds " << kMaxBatchSigners << " entries.";
267 return temARRAY_TOO_LARGE;
268 }
269
270 // Validation Inner Batch Txns
271 auto const checkSignatureFields =
272 [&parentBatchId, &j = ctx.j](
273 STObject const& sig, UInt256 const& hash, char const* label = "") -> NotTEC {
274 if (sig.isFieldPresent(sfTxnSignature))
275 {
276 JLOG(j.debug()) << "BatchTrace[" << parentBatchId << "]: "
277 << "inner txn " << label << "cannot include TxnSignature. "
278 << "txID: " << hash;
279 return temBAD_SIGNATURE;
280 }
281
282 if (sig.isFieldPresent(sfSigners))
283 {
284 JLOG(j.debug()) << "BatchTrace[" << parentBatchId << "]: "
285 << "inner txn " << label << " cannot include Signers. "
286 << "txID: " << hash;
287 return temBAD_SIGNER;
288 }
289
290 if (!sig.getFieldVL(sfSigningPubKey).empty())
291 {
292 JLOG(j.debug()) << "BatchTrace[" << parentBatchId << "]: "
293 << "inner txn " << label << " SigningPubKey must be empty. "
294 << "txID: " << hash;
295 return temBAD_REGKEY;
296 }
297
298 return tesSUCCESS;
299 };
300
301 InlineSet<std::pair<AccountID, std::uint32_t>> accountSeqTicket;
302 InlineSet<UInt256> uniqueHashes;
303
304 for (auto const& stxPtr : ctx.tx.getBatchTransactions())
305 {
306 STTx const& stx = *stxPtr;
307
308 if (ctx.rules.enabled(fixBatchV1_2) && stx.getFName() != sfRawTransaction)
309 {
310 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]:"
311 << "txns array may contain only RawTransaction objects.";
312 return temMALFORMED;
313 }
314
315 auto const hash = stx.getTransactionID();
316
317 if (!uniqueHashes.emplace(hash).second)
318 {
319 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: "
320 << "duplicate Txn found. "
321 << "txID: " << hash;
322 return temREDUNDANT;
323 }
324
325 auto const txType = stx.getFieldU16(sfTransactionType);
326 // Pre-LendingProtocolV1_2: SAV and Lending transactions cannot be Batch inners.
327 // Post-LendingProtocolV1_2: they continue through the normal Batch checks.
328 bool const rejectedPreV12 = !ctx.rules.enabled(featureLendingProtocolV1_2) &&
330 kDisabledTxTypes, [txType](auto const& disabled) { return txType == disabled; });
331 if (rejectedPreV12)
333
334 if (!stx.isFlag(tfInnerBatchTxn))
335 {
336 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: "
337 << "inner txn must have the tfInnerBatchTxn flag. "
338 << "txID: " << hash;
339 return temINVALID_FLAG;
340 }
341
342 if (auto const ret = checkSignatureFields(stx, hash))
343 return ret;
344
345 // Note that the CounterpartySignature is optional, and should not be
346 // included, but if it is, ensure it doesn't contain a signature.
347 if (stx.isFieldPresent(sfCounterpartySignature))
348 {
349 auto const counterpartySignature = stx.getFieldObject(sfCounterpartySignature);
350 if (auto const ret =
351 checkSignatureFields(counterpartySignature, hash, "counterparty signature "))
352 {
353 return ret;
354 }
355 }
356 if (stx.isFieldPresent(sfSponsorSignature))
357 {
358 auto const sponsorSignature = stx.getFieldObject(sfSponsorSignature);
359 if (auto const ret = checkSignatureFields(sponsorSignature, hash, "sponsor signature "))
360 {
361 return ret;
362 }
363 }
364
365 // Check that the Fee is native asset (XRP) and zero
366 if (auto const fee = stx.getFieldAmount(sfFee); !fee.native() || fee.xrp() != beast::kZero)
367 {
368 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: "
369 << "inner txn must have a fee of 0. "
370 << "txID: " << hash;
371 return temBAD_FEE;
372 }
373
374 // Disallow fee sponsorship on Batch inner txs
375 if (stx.isFieldPresent(sfSponsor) && isFeeSponsored(stx))
376 return temINVALID_FLAG;
377
378 auto const innerAccount = stx.getAccountID(sfAccount);
379 // TransactionProposalCreate preflights a proposed Batch with
380 // TapDryRun | TapProposal so signature-presence checks are deferred
381 // to collection time (On-Chain Cosigner spec §5.3.1.2). Inner
382 // preflight used to pass only TapBatch, so those bits never reached
383 // the inners: an unsigned account-reserve SponsorshipTransfer then
384 // demanded sfSponsorSignature and the Create failed with
385 // temINVALID_INNER_BATCH. Spec §6.1.1 names an inner Sponsor as a
386 // collectable slot, so forward TapProposal/TapDryRun. Always OR in
387 // TapBatch — PreflightContext with a parentBatchId requires it.
388 // LoanSet already short-circuits on tfInnerBatchTxn; it is also in
389 // kDisabledTxTypes, so it never reaches this call.
390 ApplyFlags const innerFlags = TapBatch | (ctx.flags & (TapProposal | TapDryRun));
391 if (auto const preflightResult =
392 xrpl::preflight(ctx.registry, ctx.rules, parentBatchId, stx, innerFlags, ctx.j);
393 !isTesSuccess(preflightResult.ter))
394 {
395 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: "
396 << "inner txn preflight failed: " << transHuman(preflightResult.ter)
397 << " "
398 << "txID: " << hash;
400 }
401
402 // Check that Sequence and TicketSequence are not both present
403 if (stx.isFieldPresent(sfTicketSequence) && stx.getFieldU32(sfSequence) != 0)
404 {
405 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: "
406 << "inner txn must have exactly one of Sequence and "
407 "TicketSequence. "
408 << "txID: " << hash;
409 return temSEQ_AND_TICKET;
410 }
411
412 // Verify that either Sequence or TicketSequence is present
413 if (!stx.isFieldPresent(sfTicketSequence) && stx.getFieldU32(sfSequence) == 0)
414 {
415 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: "
416 << "inner txn must have either Sequence or "
417 "TicketSequence. "
418 << "txID: " << hash;
419 return temSEQ_AND_TICKET;
420 }
421
422 // Duplicate sequence and ticket checks. Note that sequences and tickets share a
423 // single key space per account for purposes of this check.
424 if ((flags & (tfAllOrNothing | tfUntilFailure)) != 0u)
425 {
426 if (auto const seq = stx.getSeqProxy();
427 !accountSeqTicket.emplace(innerAccount, seq.value()).second)
428 {
429 JLOG(ctx.j.debug())
430 << "BatchTrace[" << parentBatchId << "]: "
431 << "duplicate " << (seq.isTicket() ? "ticket" : "sequence") << " found: "
432 << "txID: " << hash;
433 return temREDUNDANT;
434 }
435 }
436 }
437
438 return tesSUCCESS;
439}
440
441NotTEC
443{
444 XRPL_ASSERT(
445 ctx.tx.getTxnType() == ttBATCH, "xrpl::Batch::preflightSigValidated : batch transaction");
446
447 // A proposed Batch is stored unsigned; its BatchSigners are collected
448 // on-ledger afterward, so the signer-presence match belongs to submission
449 // time, not proposal creation (On-Chain Cosigner spec §5.3.1.2).
450 if ((ctx.flags & TapProposal) != 0)
451 return tesSUCCESS;
452
453 auto const parentBatchId = ctx.tx.getTransactionID();
454 auto const outerAccount = ctx.tx.getAccountID(sfAccount);
455 // Accounts that must sign the batch: each inner authorizer and counterparty
456 // (excluding the outer account), sorted and de-duplicated to match against
457 // the ascending, unique batch signers.
458 std::vector<AccountID> requiredSigners;
459 requiredSigners.reserve(kMaxBatchSigners);
460 for (auto const& stxPtr : ctx.tx.getBatchTransactions())
461 {
462 STTx const& rb = *stxPtr;
463 // A delegated inner is signed by the delegate, not the account holder,
464 // so the delegate is the required signer when present.
465 AccountID const authorizer = rb.getInitiator();
466
467 // The outer account signs the batch itself, so it is never added to the
468 // required signers.
469 if (authorizer != outerAccount)
470 requiredSigners.push_back(authorizer);
471 // Some transactions have a Counterparty, who must also sign the
472 // transaction if they are not the outer account
473 if (auto const counterparty = rb[~sfCounterparty];
474 counterparty && counterparty != outerAccount)
475 requiredSigners.push_back(*counterparty);
476
477 if (auto const sponsor = rb.at(~sfSponsor);
478 sponsor && rb.isFieldPresent(sfSponsorSignature) && sponsor != outerAccount)
479 requiredSigners.push_back(*sponsor);
480 }
481 std::ranges::sort(requiredSigners);
482 auto const dupes = std::ranges::unique(requiredSigners);
483 requiredSigners.erase(dupes.begin(), dupes.end());
484
485 std::size_t numReqSignersMatched = 0;
486
487 // Validation Batch Signers
488 if (ctx.tx.isFieldPresent(sfBatchSigners))
489 {
490 STArray const& signers = ctx.tx.getFieldArray(sfBatchSigners);
491
492 // Batch signers must be strictly ascending and match the required
493 // signers exactly; since both are sorted, each must be the next
494 // required signer.
495 AccountID lastBatchSigner{beast::kZero};
496 for (auto const& signer : signers)
497 {
498 AccountID const signerAccount = signer.getAccountID(sfAccount);
499 if (signerAccount == outerAccount)
500 {
501 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: "
502 << "signer cannot be the outer account: " << signerAccount;
503 return temBAD_SIGNER;
504 }
505
506 if (lastBatchSigner == signerAccount)
507 {
508 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: "
509 << "duplicate signer found: " << signerAccount;
510 return temBAD_SIGNER;
511 }
512
513 if (lastBatchSigner > signerAccount)
514 {
515 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: "
516 << "unsorted signers array: " << signerAccount;
517 return temBAD_SIGNER;
518 }
519 lastBatchSigner = signerAccount;
520
521 if (numReqSignersMatched >= requiredSigners.size() ||
522 requiredSigners[numReqSignersMatched] != signerAccount)
523 {
524 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: "
525 << "missing signer or extra signer provided: " << signerAccount;
526 return temBAD_SIGNER;
527 }
528 ++numReqSignersMatched;
529 }
530 }
531
532 // Every required signer must be matched. Also covers sfBatchSigners being
533 // absent while inner txns require signers (numReqSignersMatched stays 0).
534 if (numReqSignersMatched != requiredSigners.size())
535 {
536 JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: "
537 << "invalid batch signers.";
538 return temBAD_SIGNER;
539 }
540
541 return tesSUCCESS;
542}
543
544NotTEC
546{
547 STArray const& signers{ctx.tx.getFieldArray(sfBatchSigners)};
548 for (auto const& signer : signers)
549 {
550 // Reuse the standard signer-authorization rules so the batch and
551 // non-batch paths cannot drift. permitUncreatedAccount allows an inner
552 // from an account that an earlier inner creates, which must be
553 // authorized by its own master key.
554 auto const idAccount = signer.getAccountID(sfAccount);
555 if (auto const ret = Transactor::checkSign(
556 ctx.view,
557 ctx.flags,
558 ctx.parentBatchId,
559 idAccount,
560 signer,
561 ctx.j,
562 /*permitUncreatedAccount=*/true);
563 !isTesSuccess(ret))
564 return ret;
565 }
566 return tesSUCCESS;
567}
568
586NotTEC
588{
589 if (auto ret = Transactor::checkSign(ctx); !isTesSuccess(ret))
590 return ret;
591
592 if (ctx.tx.isFieldPresent(sfBatchSigners))
593 {
594 if (auto ret = checkBatchSign(ctx); !isTesSuccess(ret))
595 return ret;
596 }
597
598 return tesSUCCESS;
599}
600
611TER
613{
614 return tesSUCCESS;
615}
616
617void
619{
620 // No transaction-specific invariants yet (future work).
621}
622
623bool
625{
626 // No transaction-specific invariants yet (future work).
627 return true;
628}
629
630} // namespace xrpl
T any_of(T... args)
A generic endpoint for log messages.
Definition Journal.h:44
Stream debug() const
Definition Journal.h:344
UInt size() const
Number of values in array or object.
static TER preclaim(PreclaimContext const &ctx)
Definition Batch.cpp:184
static std::optional< XRPAmount > calculateBaseFeeImpl(ReadView const &view, STTx const &tx)
Calculates the total base fee for a batch transaction.
Definition Batch.cpp:67
static XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
Definition Batch.cpp:174
static NotTEC preflight(PreflightContext const &ctx)
Performs preflight validation checks for a Batch transaction.
Definition Batch.cpp:232
void visitInvariantEntry(bool isDelete, SLE::ConstRef before, SLE::ConstRef after) override
Inspect a single ledger entry modified by this transaction.
Definition Batch.cpp:618
static NotTEC checkBatchSign(PreclaimContext const &ctx)
Definition Batch.cpp:545
static NotTEC checkSign(PreclaimContext const &ctx)
Checks the validity of signatures for a batch transaction.
Definition Batch.cpp:587
TER doApply() override
Applies the outer batch transaction.
Definition Batch.cpp:612
bool finalizeInvariants(STTx const &tx, TER result, XRPAmount fee, ReadView const &view, beast::Journal const &j) override
Check transaction-specific post-conditions after all entries have been visited.
Definition Batch.cpp:624
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
Definition Batch.cpp:192
static constexpr auto kDisabledTxTypes
Inner transaction types that preflight rejects before LendingProtocolV1_2.
static NotTEC preflightSigValidated(PreflightContext const &ctx)
Definition Batch.cpp:442
A view into a ledger.
Definition ReadView.h:41
bool enabled(UInt256 const &feature) const
Returns true if a feature is enabled.
Definition Rules.cpp:182
bool native() const noexcept
Definition STAmount.h:471
size_type size() const
Definition STArray.h:248
SField const & getFName() const
Definition STBase.cpp:120
std::shared_ptr< STLedgerEntry const > const & ConstRef
T::value_type at(TypedField< T > const &f) const
Get the value of a field.
Definition STObject.h:1077
std::uint32_t getFieldU32(SField const &field) const
Definition STObject.cpp:601
STArray const & getFieldArray(SField const &field) const
Definition STObject.cpp:688
bool isFlag(std::uint32_t) const
Definition STObject.cpp:511
bool isFieldPresent(SField const &field) const
Definition STObject.cpp:464
STObject getFieldObject(SField const &field) const
Definition STObject.cpp:678
AccountID getAccountID(SField const &field) const
Definition STObject.cpp:643
std::uint16_t getFieldU16(SField const &field) const
Definition STObject.cpp:595
STAmount const & getFieldAmount(SField const &field) const
Definition STObject.cpp:657
std::uint32_t getFlags() const
Definition STObject.cpp:517
SeqProxy getSeqProxy() const
Definition STTx.cpp:198
static constexpr std::size_t kMaxMultiSigners
Definition STTx.h:49
TxType getTxnType() const
Definition STTx.h:250
UInt256 getTransactionID() const
Definition STTx.h:262
AccountID getInitiator() const
The account responsible for the authorization: the delegate when sfDelegate is present,...
Definition STTx.cpp:659
std::vector< std::shared_ptr< STTx const > > const & getBatchTransactions() const
The inner transactions of a Batch, built and validated at construction.
Definition STTx.cpp:648
static NotTEC checkSign(PreclaimContext const &ctx)
ApplyView & view()
Definition Transactor.h:184
static XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
T erase(T... args)
T max(T... args)
constexpr Zero kZero
Definition Zero.h:30
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
constexpr FlagValue tfInnerBatchTxn
Definition TxFlags.h:44
constexpr std::size_t kMaxBatchSigners
The maximum number of batch signers.
Definition Protocol.h:487
PreflightResult preflight(ServiceRegistry &registry, Rules const &rules, STTx const &tx, ApplyFlags flags, beast::Journal j)
Gate a transaction based on static information.
std::expected< XRPAmount, TER > calculateBaseFee(ReadView const &view, STTx const &tx)
Compute only the expected base fee for a transaction.
beast::Journal debugLog()
Returns a debug journal.
Definition Log.cpp:399
std::string transHuman(TER code)
Definition TER.cpp:268
std::string transToken(TER code)
Definition TER.cpp:259
bool isReserveSponsored(STTx const &tx)
Whether the transaction's reserve is sponsored (sfSponsor present + spfSponsorReserve set).
BaseUInt< 256 > UInt256
Definition base_uint.h:581
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:617
bool isFeeSponsored(STTx const &tx)
Whether the transaction's fee is sponsored (sfSponsor present + spfSponsorFee set).
ApplyFlags
Definition ApplyView.h:27
@ TapDryRun
Definition ApplyView.h:46
@ TapProposal
Definition ApplyView.h:53
@ TapBatch
Definition ApplyView.h:42
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:34
@ temBAD_REGKEY
Definition TER.h:86
@ temARRAY_TOO_LARGE
Definition TER.h:129
@ temBAD_FEE
Definition TER.h:80
@ temINVALID_FLAG
Definition TER.h:99
@ temMALFORMED
Definition TER.h:75
@ temARRAY_EMPTY
Definition TER.h:128
@ temSEQ_AND_TICKET
Definition TER.h:114
@ temBAD_SIGNATURE
Definition TER.h:93
@ temINVALID_INNER_BATCH
Definition TER.h:131
@ temREDUNDANT
Definition TER.h:100
@ temBAD_SIGNER
Definition TER.h:103
bool isTesSuccess(TER x) noexcept
Definition TER.h:686
TERSubset< CanCvtToTER > TER
Definition TER.h:657
@ tecINSUFF_FEE
Definition TER.h:313
@ tesSUCCESS
Definition TER.h:253
T popcount(T... args)
T push_back(T... args)
T reserve(T... args)
T size(T... args)
T sort(T... args)
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:92
ReadView const & view
Definition Transactor.h:95
std::optional< UInt256 const > const parentBatchId
Definition Transactor.h:99
beast::Journal const j
Definition Transactor.h:100
State information when preflighting a tx.
Definition Transactor.h:39
beast::Journal const j
Definition Transactor.h:46
std::reference_wrapper< ServiceRegistry > registry
Definition Transactor.h:41
T unique(T... args)