3#include <xrpl/beast/utility/Journal.h>
4#include <xrpl/beast/utility/WrappedSink.h>
5#include <xrpl/protocol/Permissions.h>
6#include <xrpl/protocol/XRPAmount.h>
7#include <xrpl/tx/ApplyContext.h>
8#include <xrpl/tx/applySteps.h>
52 XRPL_ASSERT((
flags &
TapBatch) == 0,
"Batch apply flag should not be set");
89 "Parent Batch ID should be set if batch apply flag is set");
101 XRPL_ASSERT((
flags &
TapBatch) == 0,
"Batch apply flag should not be set");
286 return T::checkGranularSemantics(
view, tx, heldGranularPermissions);
345 [[nodiscard]]
virtual bool
397 template <
class T,
class Unit>
410 template <
class T,
class Unit>
413 std::optional<T> value,
414 unit::ValueUnit<Unit, T> min = unit::ValueUnit<Unit, T>{});
419 ReadView
const&
view,
421 std::unordered_set<GranularPermissionType>& heldGranularPermissions);
423 std::pair<TER, XRPAmount>
424 reset(XRPAmount fee);
432 std::tuple<TER, XRPAmount, bool>
437 ReadView
const&
view,
441 beast::Journal
const j);
445 ReadView
const&
view,
448 STObject
const& sigObject,
449 beast::Journal
const j);
461 preflight1(PreflightContext
const& ctx, std::uint32_t flagMask);
539 if (!T::checkExtraFeatures(ctx))
542 if (
auto const ret =
preflight1(ctx, T::getFlagsMask(ctx)))
548 if (
auto const ret = T::preflight(ctx))
554 return T::preflightSigValidated(ctx);
563 return value >= min && value <= max;
566template <
class T,
class Unit>
585template <
class T,
class Unit>
A generic endpoint for log messages.
static Sink & getNullSink()
Returns a Sink which does nothing.
Wraps a Journal::Sink to prefix its output with a string.
State information when applying a tx.
Writeable view to a ledger, for applying a transaction.
std::optional< std::reference_wrapper< uint256 const > > getTxFeature(TxType txType) const
static Permission const & getInstance()
Rules controlling protocol behavior.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
std::shared_ptr< STLedgerEntry > pointer
std::shared_ptr< STLedgerEntry const > const & const_ref
std::shared_ptr< STLedgerEntry const > const_pointer
TxType getTxnType() const
Service registry for dependency injection.
static NotTEC preflight1(PreflightContext const &ctx, std::uint32_t flagMask)
Performs early sanity checks on the account and fee fields.
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
TER consumeSeqProxy(SLE::pointer const &sleAccount)
static NotTEC checkPermission(ReadView const &view, STTx const &tx, std::unordered_set< GranularPermissionType > &heldGranularPermissions)
void trapTransaction(uint256) const
static TER checkFee(PreclaimContext const &ctx, XRPAmount baseFee)
static NotTEC invokePreflight(PreflightContext const &ctx)
static NotTEC checkGranularSemantics(ReadView const &view, STTx const &tx, std::unordered_set< GranularPermissionType > const &heldGranularPermissions)
This function can be overridden to introduce additional semantic constraints beyond the granular temp...
Transactor & operator=(Transactor const &)=delete
static XRPAmount minimumFee(ServiceRegistry ®istry, XRPAmount baseFee, Fees const &fees, ApplyFlags flags)
Compute the minimum fee required to process a transaction with a given baseFee based on the current s...
static NotTEC checkSign(PreclaimContext const &ctx)
static XRPAmount calculateOwnerReserveFee(ReadView const &view, STTx const &tx)
ApplyResult operator()()
Process the transaction.
static bool validNumericMinimum(std::optional< T > value, T min=T{})
Minimum will usually be zero.
static NotTEC preflightSigValidated(PreflightContext const &ctx)
static NotTEC checkBatchSign(PreclaimContext const &ctx)
static NotTEC checkSeqProxy(ReadView const &view, STTx const &tx, beast::Journal j)
static TER preclaim(PreclaimContext const &ctx)
virtual ~Transactor()=default
static NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
static bool checkExtraFeatures(PreflightContext const &ctx)
static NotTEC checkSingleSign(ReadView const &view, AccountID const &idSigner, AccountID const &idAccount, SLE::const_pointer sleAccount, beast::Journal const j)
TER checkTransactionInvariants(TER result, XRPAmount fee)
Check transaction-specific invariants only.
Transactor(Transactor const &)=delete
static NotTEC preflightUniversal(PreflightContext const &ctx)
Universal validations.
static XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
TER checkInvariants(TER result, XRPAmount fee)
Check all invariants for the current transaction.
AccountID const accountID_
static NotTEC checkPriorTxAndLastLedger(PreclaimContext const &ctx)
static NotTEC invokeCheckPermission(ReadView const &view, STTx const &tx)
Checks whether the transaction is authorized to be executed by the delegated account.
static NotTEC checkMultiSign(ReadView const &view, ApplyFlags flags, AccountID const &id, STObject const &sigObject, beast::Journal const j)
static bool validDataLength(std::optional< Slice > const &slice, std::size_t maxLength)
virtual void preCompute()
ApplyView const & view() const
virtual void visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after)=0
Inspect a single ledger entry modified by this transaction.
std::pair< TER, XRPAmount > reset(XRPAmount fee)
Reset the context, discarding any changes made and adjust the fee.
static bool validNumericRange(std::optional< T > value, T max, T min=T{})
virtual bool finalizeInvariants(STTx const &tx, TER result, XRPAmount fee, ReadView const &view, beast::Journal const &j)=0
Check transaction-specific post-conditions after all entries have been visited.
static TER ticketDelete(ApplyView &view, AccountID const &account, uint256 const &ticketIndex, beast::Journal j)
std::tuple< TER, XRPAmount, bool > processPersistentChanges(TER result, XRPAmount fee)
Class describing the consequences to the account of applying a transaction if the transaction consume...
std::optional< NotTEC > preflightCheckSimulateKeys(ApplyFlags flags, STObject const &sigObject, beast::Journal j)
Checks the special signing key state needed for simulation.
NotTEC preflightCheckSigningKey(STObject const &sigObject, beast::Journal j)
Checks the validity of the transactor signing key.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
TERSubset< CanCvtToNotTEC > NotTEC
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
bool isTesSuccess(TER x) noexcept
TERSubset< CanCvtToTER > TER
NotTEC preflight0(PreflightContext const &ctx, std::uint32_t flagMask)
Performs early sanity checks on the txid and flags.
Reflects the fee settings for a particular ledger.
State information when determining if a tx is likely to claim a fee.
PreclaimContext(ServiceRegistry ®istry, ReadView const &view, TER preflightResult, STTx const &tx, ApplyFlags flags, std::optional< uint256 > parentBatchId, beast::Journal j=beast::Journal{beast::Journal::getNullSink()})
std::reference_wrapper< ServiceRegistry > registry
PreclaimContext(ServiceRegistry ®istry, ReadView const &view, TER preflightResult, STTx const &tx, ApplyFlags flags, beast::Journal j=beast::Journal{beast::Journal::getNullSink()})
PreclaimContext & operator=(PreclaimContext const &)=delete
std::optional< uint256 const > const parentBatchId
State information when preflighting a tx.
PreflightContext(ServiceRegistry ®istry, STTx const &tx, Rules rules, ApplyFlags flags, beast::Journal j=beast::Journal{beast::Journal::getNullSink()})
PreflightContext & operator=(PreflightContext const &)=delete
std::optional< uint256 const > parentBatchId
std::reference_wrapper< ServiceRegistry > registry
PreflightContext(ServiceRegistry ®istry, STTx const &tx, uint256 parentBatchId, Rules rules, ApplyFlags flags, beast::Journal j=beast::Journal{beast::Journal::getNullSink()})
Describes the results of the preflight check.