1#include <xrpl/tx/Transactor.h>
3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/Slice.h>
5#include <xrpl/basics/base_uint.h>
6#include <xrpl/basics/contract.h>
7#include <xrpl/beast/utility/Zero.h>
8#include <xrpl/beast/utility/instrumentation.h>
9#include <xrpl/core/NetworkIDService.h>
10#include <xrpl/core/ServiceRegistry.h>
11#include <xrpl/json/to_string.h>
12#include <xrpl/ledger/ApplyView.h>
13#include <xrpl/ledger/ReadView.h>
14#include <xrpl/ledger/helpers/AccountRootHelpers.h>
15#include <xrpl/ledger/helpers/CredentialHelpers.h>
16#include <xrpl/ledger/helpers/DelegateHelpers.h>
17#include <xrpl/ledger/helpers/NFTokenHelpers.h>
18#include <xrpl/ledger/helpers/OfferHelpers.h>
19#include <xrpl/ledger/helpers/ProposalHelpers.h>
20#include <xrpl/ledger/helpers/RippleStateHelpers.h>
21#include <xrpl/ledger/helpers/SponsorHelpers.h>
22#include <xrpl/protocol/AccountID.h>
23#include <xrpl/protocol/Feature.h>
24#include <xrpl/protocol/Indexes.h>
25#include <xrpl/protocol/LedgerFormats.h>
26#include <xrpl/protocol/Permissions.h>
27#include <xrpl/protocol/Protocol.h>
28#include <xrpl/protocol/PublicKey.h>
29#include <xrpl/protocol/Rules.h>
30#include <xrpl/protocol/SField.h>
31#include <xrpl/protocol/STAmount.h>
32#include <xrpl/protocol/STLedgerEntry.h>
33#include <xrpl/protocol/STTx.h>
34#include <xrpl/protocol/Serializer.h>
35#include <xrpl/protocol/SystemParameters.h>
36#include <xrpl/protocol/TER.h>
37#include <xrpl/protocol/TxFlags.h>
38#include <xrpl/protocol/TxMeta.h>
39#include <xrpl/protocol/XRPAmount.h>
40#include <xrpl/server/LoadFeeTrack.h>
41#include <xrpl/tx/ApplyContext.h>
42#include <xrpl/tx/SignerEntries.h>
43#include <xrpl/tx/apply.h>
44#include <xrpl/tx/applySteps.h>
45#include <xrpl/tx/invariants/InvariantRunner.h>
69 JLOG(ctx.
j.
warn()) <<
"Pseudo transactions cannot contain the "
70 "tfInnerBatchTxn flag.";
76 uint32_t
const nodeNID = ctx.
registry.get().getNetworkIDService().getNetworkID();
93 if (*txNID != nodeNID)
102 JLOG(ctx.
j.
warn()) <<
"applyTransaction: transaction id may not be zero";
109 <<
": invalid flags.";
126 if (
auto const spk = sigObject.
getFieldVL(sfSigningPubKey);
129 JLOG(j.
debug()) <<
"preflightCheckSigningKey: invalid signing key";
141 if (signature && !signature->empty())
154 for (
auto const& signer : sigObject.
getFieldArray(sfSigners))
156 if (signer.isFieldPresent(sfTxnSignature) && !signer[sfTxnSignature].empty())
164 Slice const signingPubKey = sigObject[sfSigningPubKey];
165 if (!signingPubKey.
empty())
184 if ((hasSponsor || hasSponsorFlags || hasSponsorSig) && !ctx.
rules.
enabled(featureSponsor))
187 if (hasSponsor != hasSponsorFlags)
189 JLOG(ctx.
j.
debug()) <<
"preflight1: sponsor and sponsor flags mismatch";
192 if (hasSponsorSig && (!hasSponsor || !hasSponsorFlags))
194 JLOG(ctx.
j.
debug()) <<
"preflight1: sponsor signature without sponsor definition";
200 auto const sponsorFlags = ctx.
tx.
getFieldU32(sfSponsorFlags);
203 JLOG(ctx.
j.
debug()) <<
"preflight1: invalid sponsor flags";
214 <<
"preflight1: spfSponsorReserve not allowed for this transaction type";
222 JLOG(ctx.
j.
debug()) <<
"preflight1: Sponsor account cannot be the same as the account";
237 if (!ctx.
rules.
enabled(featurePermissionDelegationV1_1))
240 if (ctx.
tx[sfDelegate] == ctx.
tx[sfAccount])
250 !perm.hasGranularPermissions(txType))
254 if (
auto const ret =
preflight0(ctx, flagMask))
260 JLOG(ctx.
j.
warn()) <<
"preflight1: bad account id";
266 if (!fee.native() || fee.negative() || !
isLegalAmount(fee.xrp()))
268 JLOG(ctx.
j.
debug()) <<
"preflight1: invalid fee";
332 JLOG(ctx.
j.
debug()) <<
"preflight2: bad signature. " << sigValid.second;
366 return !slice->empty() && slice->length() <= maxLength;
387 auto const delegate = tx[~sfDelegate];
402 if (heldGranularPermissions.
empty())
433 auto const sponsorshipSle =
440 if (
isFeeSponsored(tx) && sponsorshipSle->isFlag(lsfSponsorshipRequireSignForFee))
443 if (
isReserveSponsored(tx) && sponsorshipSle->isFlag(lsfSponsorshipRequireSignForReserve))
469 if (sponsorObj.isFieldPresent(sfSigners))
470 sponsorSignerCount += sponsorObj.getFieldArray(sfSigners).size();
473 return baseFee + ((signerCount + sponsorSignerCount) * baseFee);
500 view.fees().increment >
view.fees().base * 100,
501 "xrpl::Transactor::calculateOwnerReserveFee : Owner reserve is "
503 return view.fees().increment;
519 if (!ctx.
tx[sfFee].native())
522 auto const feePaid = ctx.
tx[sfFee].xrp();
529 JLOG(ctx.
j.
trace()) <<
"Batch: Fee must be zero.";
541 if (feePaid < feeDue)
543 JLOG(ctx.
j.
trace()) <<
"Insufficient fee paid: " <<
to_string(feePaid) <<
"/"
553 auto const payerSle = ctx.
view.
read(feePayer.keylet);
570 if (payerSle->getType() != ltSPONSORSHIP)
573 if (payerSle->isFieldPresent(feePayer.balanceField))
574 maxSpendable = payerSle->getFieldAmount(feePayer.balanceField).xrp();
576 if (payerSle->isFieldPresent(sfMaxFee))
578 auto const cap = payerSle->getFieldAmount(sfMaxFee).xrp();
579 maxSpendable =
std::min(maxSpendable, cap);
584 if (payerSle->getType() != ltACCOUNT_ROOT)
590 maxSpendable = payerSle->getFieldAmount(sfBalance).xrp() - sponsorReserve;
594 maxSpendable = payerSle->getFieldAmount(feePayer.balanceField).xrp();
605 if (maxSpendable < feePaid)
607 JLOG(ctx.
j.
trace()) <<
"Insufficient balance:" <<
" balance=" <<
to_string(maxSpendable)
625 auto const feePaid =
ctx_.tx[sfFee].xrp();
628 auto const sle =
view().
peek(feePayer.keylet);
630 JLOG(
j_.trace()) <<
"Fee payer: " +
to_string(feePayer.id);
639 if (sle->isFieldPresent(feePayer.balanceField))
641 balance = sle->getFieldAmount(feePayer.balanceField).xrp();
643 else if (feePayer.balanceField != sfFeeAmount)
657 spendable = balance > sponsorReserve ? balance - sponsorReserve :
beast::kZero;
661 auto const cap = sle->getFieldAmount(sfMaxFee).xrp();
662 spendable =
std::min(spendable, cap);
670 if (feePaid > spendable &&
680 auto const feeAmountAfter = balance - feePaid;
682 if (feeAmountAfter ==
beast::kZero && feePayer.balanceField == sfFeeAmount)
685 sle->makeFieldAbsent(feePayer.balanceField);
689 sle->setFieldAmount(feePayer.balanceField, feeAmountAfter);
707 JLOG(j.
trace()) <<
"applyTransaction: delay: source account does not exist "
715 if (tSeqProx.
isSeq())
719 JLOG(j.
trace()) <<
"applyTransaction: has both a TicketSequence "
720 "and a non-zero Sequence number";
723 if (tSeqProx != aSeq)
727 JLOG(j.
trace()) <<
"applyTransaction: has future sequence number "
728 <<
"a_seq=" << aSeq <<
" t_seq=" << tSeqProx;
732 JLOG(j.
trace()) <<
"applyTransaction: has past sequence number "
733 <<
"a_seq=" << aSeq <<
" t_seq=" << tSeqProx;
746 JLOG(j.
trace()) <<
"applyTransaction: has future ticket id "
747 <<
"a_seq=" << aSeq <<
" t_seq=" << tSeqProx;
754 JLOG(j.
trace()) <<
"applyTransaction: ticket already used or never created "
755 <<
"a_seq=" << aSeq <<
" t_seq=" << tSeqProx;
768 JLOG(j.
trace()) <<
"applyTransaction: ticket " << tSeqProx <<
" is reserved";
785 JLOG(ctx.
j.
trace()) <<
"applyTransaction: delay: source account does not exist "
791 (sle->getFieldH256(sfAccountTxnID) != ctx.
tx.
getFieldH256(sfAccountTxnID)))
807 XRPL_ASSERT(sleAccount,
"xrpl::Transactor::consumeSeqProxy : non-null account");
809 if (seqProxy.
isSeq())
814 sleAccount->setFieldU32(sfSequence, seqProxy.
value() + 1);
835 JLOG(j.
fatal()) <<
"Ticket disappeared from ledger.";
844 JLOG(j.
fatal()) <<
"Unable to delete Ticket from owner.";
855 JLOG(j.
fatal()) <<
"Could not find Ticket owner account root.";
860 if (
auto ticketCount = (*sleAccount)[~sfTicketCount])
862 if (*ticketCount == 1)
864 sleAccount->makeFieldAbsent(sfTicketCount);
868 ticketCount = *ticketCount - 1;
874 JLOG(j.
fatal()) <<
"TicketCount field missing from account root.";
882 std::uint32_t const ticketSeq{(*sleTicket)[sfTicketSequence]};
885 view.erase(sleTicket);
895 if (
view.rules().enabled(featureCosign))
927 "xrpl::Transactor::apply : non-null SLE or zero account");
941 if (sle->isFieldPresent(sfAccountTxnID))
942 sle->setFieldH256(sfAccountTxnID,
ctx_.tx.getTransactionID());
958 bool permitUncreatedAccount)
963 if ((
view.rules().enabled(featureLendingProtocol) ||
964 view.rules().enabled(featureBatchV1_1) ||
view.rules().enabled(fixCleanup3_3_0)) &&
974 auto const pkSigner = sigObject.
getFieldVL(sfSigningPubKey);
976 if (parentBatchId &&
view.rules().enabled(featureBatchV1_1))
979 if (sigObject.
isFieldPresent(sfTxnSignature) || !pkSigner.empty() ||
1002 auto const sponsorID = sigObject.
getAccountID(sfSponsor);
1003 auto const sponsorSignature = sigObject.
getFieldObject(sfSponsorSignature);
1004 if (
auto const ret =
checkSign(
view, flags, std::nullopt, sponsorID, sponsorSignature, j);
1017 XRPL_ASSERT(!pkSigner.empty(),
"xrpl::Transactor::checkSign : non-empty signer");
1021 JLOG(j.
trace()) <<
"checkSign: signing public key type is unknown";
1033 if (!permitUncreatedAccount)
1035 if (idAccount != idSigner)
1059 bool const isMasterDisabled = sleAccount->isFlag(lsfDisableMaster);
1062 if ((*sleAccount)[~sfRegularKey] == idSigner)
1068 if (!isMasterDisabled && idAccount == idSigner)
1074 if (isMasterDisabled && idAccount == idSigner)
1094 if (!sleAccountSigners)
1096 JLOG(j.
trace()) <<
"applyTransaction: Invalid: Not a multi-signing account.";
1103 sleAccountSigners->isFieldPresent(sfSignerListID),
1104 "xrpl::Transactor::checkMultiSign : has signer list ID");
1106 sleAccountSigners->getFieldU32(sfSignerListID) == 0,
1107 "xrpl::Transactor::checkMultiSign : signer list ID is 0");
1110 if (!accountSigners)
1111 return accountSigners.error();
1123 auto iter = accountSigners->begin();
1124 for (
auto const& txSigner : txSigners)
1126 AccountID const txSignerAcctID = txSigner.getAccountID(sfAccount);
1129 while (iter->account < txSignerAcctID)
1131 if (++iter == accountSigners->end())
1133 JLOG(j.
trace()) <<
"applyTransaction: Invalid SigningAccount.Account.";
1137 if (iter->account != txSignerAcctID)
1140 JLOG(j.
trace()) <<
"applyTransaction: Invalid SigningAccount.Account.";
1147 auto const spk = txSigner.getFieldVL(sfSigningPubKey);
1153 JLOG(j.
trace()) <<
"checkMultiSign: signing public key type is unknown";
1159 "xrpl::Transactor::checkMultiSign : non-empty signer or "
1161 AccountID const signingAcctIDFromPubKey =
1191 if (signingAcctIDFromPubKey == txSignerAcctID)
1194 if (sleTxSignerRoot)
1197 std::uint32_t const signerAccountFlags = sleTxSignerRoot->getFieldU32(sfFlags);
1199 if ((signerAccountFlags & lsfDisableMaster) != 0u)
1201 JLOG(j.
trace()) <<
"applyTransaction: Signer:Account lsfDisableMaster.";
1210 if (!sleTxSignerRoot)
1212 JLOG(j.
trace()) <<
"applyTransaction: Non-phantom signer "
1213 "lacks account root.";
1217 if (!sleTxSignerRoot->isFieldPresent(sfRegularKey))
1219 JLOG(j.
trace()) <<
"applyTransaction: Account lacks RegularKey.";
1222 if (signingAcctIDFromPubKey != sleTxSignerRoot->getAccountID(sfRegularKey))
1224 JLOG(j.
trace()) <<
"applyTransaction: Account doesn't match RegularKey.";
1229 weightSum += iter->weight;
1233 if (weightSum < sleAccountSigners->getFieldU32(sfSignerQuorum))
1235 JLOG(j.
trace()) <<
"applyTransaction: Signers failed to meet quorum.";
1250 for (
auto const& index : offers)
1270 for (
auto const& index : offers)
1284 for (
auto const& index : creds)
1291 <<
"removeExpiredCredentials: failed to delete expired credential. Err: "
1306 JLOG(viewJ.
error()) <<
"removeDeletedTrustLines: deleted trustlines exceed max "
1307 << trustLines.
size();
1311 for (
auto const& index : trustLines)
1313 if (
auto const sleState = view.
peek({ltRIPPLE_STATE, index});
1316 JLOG(viewJ.
error()) <<
"removeDeletedTrustLines: failed to delete AMM trustline";
1340 auto const payerSle =
view().
peek(feePayer.keylet);
1346 if (payerSle->isFieldPresent(feePayer.balanceField))
1348 balance = payerSle->getFieldAmount(feePayer.balanceField).xrp();
1350 else if (feePayer.balanceField != sfFeeAmount)
1357 auto const cap = payerSle->getFieldAmount(sfMaxFee).xrp();
1369 spendable = balance > sponsorReserve ? balance - sponsorReserve :
beast::kZero;
1375 "xrpl::Transactor::reset : valid balance");
1380 if (fee > spendable)
1389 auto const feeAmountAfter = balance - fee;
1390 if (feeAmountAfter ==
beast::kZero && feePayer.balanceField == sfFeeAmount)
1393 payerSle->makeFieldAbsent(feePayer.balanceField);
1397 payerSle->setFieldAmount(feePayer.balanceField, feeAmountAfter);
1401 XRPL_ASSERT(
isTesSuccess(ter),
"xrpl::Transactor::reset : result is tesSUCCESS");
1406 if (payerSle != txnAcct)
1423 if (
view.exists(sponsorshipKeylet))
1428 .keylet = sponsorshipKeylet,
1429 .balanceField = sfFeeAmount,
1437 "xrpl::getFeePayer has sponsor signature without a sponsorship object");
1443 .balanceField = sfBalance,
1450 auto const payerType =
1455 .keylet = payerAccountKeylet,
1456 .balanceField = sfBalance,
1466 JLOG(
j_.debug()) <<
"Transaction trapped: " << txHash;
1472 JLOG(
j_.trace()) <<
"reapplying because of " <<
transToken(result);
1479 auto const typesForResult = [](
TER const ter) {
1487 types.
insert(ltRIPPLE_STATE);
1491 types.
insert(ltNFTOKEN_OFFER);
1492 types.
insert(ltCREDENTIAL);
1500 auto const typesToCollect = typesForResult(result);
1503 if (!typesToCollect.empty())
1506 [&typesToCollect, &deletedObjects](
1512 "xrpl::Transactor::processPersistentChanges : non-null "
1514 if (before &&
after)
1516 auto const type = before->getType();
1517 if (typesToCollect.contains(type))
1521 if (type == ltOFFER &&
1522 before->getFieldAmount(sfTakerPays) !=
1523 after->getFieldAmount(sfTakerPays))
1526 deletedObjects[type].push_back(index);
1535 auto const resetResult =
reset(fee);
1537 result = resetResult.first;
1539 fee = resetResult.second;
1544 auto const typesToApply = typesForResult(result);
1545 if (
isTecClaim(result) && !typesToApply.empty())
1547 auto const viewJ =
ctx_.registry.get().getJournal(
"View");
1548 for (
auto const& [type, ids] : deletedObjects)
1550 if (ids.empty() || !typesToApply.contains(type))
1558 case ltNFTOKEN_OFFER:
1561 case ltRIPPLE_STATE:
1570 "xrpl::Transactor::processPersistentChanges() : "
1594 JLOG(
j_.trace()) <<
"apply: " <<
ctx_.tx.getTransactionID();
1613 JLOG(
j_.fatal()) <<
"Transaction serdes mismatch";
1616 UNREACHABLE(
"xrpl::Transactor::operator() : transaction serdes mismatch");
1622 if (
auto const& trap =
ctx_.registry.get().getTrapTxID();
1623 trap && *trap ==
ctx_.tx.getTransactionID())
1628 auto result =
ctx_.preclaimResult;
1634 XRPL_ASSERT(result !=
temUNKNOWN,
"xrpl::Transactor::operator() : result is not temUNKNOWN");
1636 if (
auto const stream =
j_.trace())
1637 stream <<
"preclaim result: " <<
transToken(result);
1639 auto fee =
ctx_.tx.getFieldAmount(sfFee).xrp();
1640 bool const canApply =
std::invoke([&result, &fee,
this] {
1651 canApplyTmp =
false;
1664 auto const logger = [
this](
1668 JLOG(
j_.trace()) << (canApply ?
"applied " :
"not applied ") <<
transToken(result);
1669 return {result, canApply, std::move(metadata)};
1673 return logger(result, canApply);
1685 auto const resetResult =
reset(fee);
1687 result = resetResult.first;
1689 fee = resetResult.second;
1703 return logger(result,
false);
1721 ctx_.destroyXRP(fee);
1724 metadata =
ctx_.apply(result);
1727 return logger(result,
false, std::move(metadata));
1729 return logger(result, canApply, std::move(metadata));
A generic endpoint for log messages.
Stream trace() const
Severity stream access functions.
State information when applying a tx.
Writeable view to a ledger, for applying a transaction.
virtual SLE::pointer peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
virtual void update(SLE::Ref sle)=0
Indicate changes to a peeked SLE.
RAII class to set and restore the current transaction rules.
static uint32_t txToPermissionType(TxType type)
static Permission const & getInstance()
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
virtual bool txExists(key_type const &key) const =0
Returns true if a tx exists in the tx map.
virtual bool open() const =0
Returns true if this reflects an open ledger.
LedgerIndex seq() const
Returns the sequence number of the base ledger.
bool enabled(UInt256 const &feature) const
Returns true if a feature is enabled.
virtual std::string getFullText() const
std::shared_ptr< STLedgerEntry > pointer
std::shared_ptr< STLedgerEntry const > const & ConstRef
std::shared_ptr< STLedgerEntry const > const_pointer
Blob getFieldVL(SField const &field) const
bool isEquivalent(STBase const &t) const override
UInt256 getFieldH256(SField const &field) const
std::uint32_t getFieldU32(SField const &field) const
STArray const & getFieldArray(SField const &field) const
bool isFlag(std::uint32_t) const
bool isFieldPresent(SField const &field) const
STBase const & peekAtField(SField const &field) const
STObject getFieldObject(SField const &field) const
AccountID getAccountID(SField const &field) const
STAmount const & getFieldAmount(SField const &field) const
std::uint32_t getFlags() const
SeqProxy getSeqProxy() const
TxType getTxnType() const
UInt256 getTransactionID() const
json::Value getJson(JsonOptions options) const override
AccountID getInitiator() const
The account responsible for the authorization: the delegate when sfDelegate is present,...
A type that represents either a sequence value or a ticket value.
static constexpr SeqProxy rawSequence(std::uint32_t v)
Factory function to return a sequence-based SeqProxy.
constexpr bool isTicket() const
constexpr std::uint32_t value() const
constexpr bool isSeq() const
Slice slice() const noexcept
Service registry for dependency injection.
virtual LoadFeeTrack & getFeeTrack()=0
static std::expected< std::vector< SignerEntry >, NotTEC > deserialize(STObject const &obj, beast::Journal journal, std::string_view annotation)
An immutable linear range of bytes.
bool empty() const noexcept
Return true if the byte range is empty.
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)
static TER checkFee(PreclaimContext const &ctx, XRPAmount baseFee)
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 NotTEC checkSponsor(ReadView const &view, STTx const &tx)
static XRPAmount calculateOwnerReserveFee(ReadView const &view, STTx const &tx)
ApplyResult operator()()
Process the transaction.
TER checkInvariants(TER result, XRPAmount fee, InvariantScope scope)
Check all invariants for the current transaction.
void trapTransaction(UInt256) const
static NotTEC preflightSigValidated(PreflightContext const &ctx)
static NotTEC checkSeqProxy(ReadView const &view, STTx const &tx, beast::Journal j)
InvariantScope
Which invariant layers to check.
static FeePayer getFeePayer(ReadView const &view, STTx const &tx)
static NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
static NotTEC checkSingleSign(ReadView const &view, AccountID const &idSigner, AccountID const &idAccount, SLE::const_pointer sleAccount, beast::Journal const j)
Transactor(Transactor const &)=delete
static NotTEC preflightUniversal(PreflightContext const &ctx)
Universal validations.
static XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
AccountID const accountID_
static NotTEC checkPriorTxAndLastLedger(PreclaimContext const &ctx)
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()
std::pair< TER, XRPAmount > reset(XRPAmount fee)
Reset the context, discarding any changes made and adjust the fee.
static TER ticketDelete(ApplyView &view, AccountID const &account, UInt256 const &ticketIndex, beast::Journal j)
This method removes one Ticket ledger-object from the ledger.
std::tuple< TER, XRPAmount, bool > processPersistentChanges(TER result, XRPAmount fee)
TER deleteSLE(ApplyView &view, SLE::Ref sleCredential, beast::Journal j)
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.
Keylet computation functions.
Keylet nftokenOffer(AccountID const &owner, SeqProxy const &seq)
An offer from an account to buy or sell an NFT.
Keylet offer(AccountID const &id, SeqProxy const &seq) noexcept
An offer from an account.
Keylet signerList(AccountID const &account) noexcept
A SignerList.
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet txProposal(AccountID const &target, std::uint32_t ticketSequence) noexcept
A TransactionProposal.
Keylet ticket(AccountID const &id, SeqProxy const &ticketSeq)
A ticket belonging to an account.
Keylet delegate(AccountID const &account, AccountID const &authorizedAccount) noexcept
A keylet for Delegate object.
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet sponsorship(AccountID const &sponsor, AccountID const &sponsee) noexcept
A Sponsorship.
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
bool deleteTokenOffer(ApplyView &view, SLE::Ref offer)
Deletes the given token offer.
bool canConsumeTicket(ReadView const &view, STTx const &tx)
Whether tx may consume its Ticket.
TER deleteProposal(ApplyView &view, SLE::pointer const &sleProposal, beast::Journal j)
Delete a TransactionProposal ledger entry.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
static void removeDeletedTrustLines(ApplyView &view, std::vector< UInt256 > const &trustLines, beast::Journal viewJ)
@ telNETWORK_ID_MAKES_TX_NON_CANONICAL
@ terNO_DELEGATE_PERMISSION
constexpr FlagValue tfInnerBatchTxn
TER offerDelete(ApplyView &view, SLE::Ref sle, beast::Journal j)
Delete an offer.
bool isLegalAmount(XRPAmount const &amount)
Returns true if the amount does not exceed the initial XRP in existence.
std::unordered_set< GranularPermissionType > getGranularPermission(SLE::ConstRef delegate, TxType const &type)
Load the granular permissions granted to the delegate account for the specified transaction type.
@ SigBad
Signature is bad.
TER deleteAMMTrustLine(ApplyView &view, SLE::pointer sleState, std::optional< AccountID > const &ammAccountID, beast::Journal j)
Delete trustline to AMM.
static void removeExpiredNFTokenOffers(ApplyView &view, std::vector< UInt256 > const &offers, beast::Journal viewJ)
bool isTecClaimHardFail(TER ter, ApplyFlags flags)
Return true if the transaction can claim a fee (tec), and the ApplyFlags do not allow soft failures.
std::pair< Validity, std::string > checkValidity(HashRouter &router, STTx const &tx, Rules const &rules)
Checks transaction signature and local checks.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
NotTEC checkTxPermission(SLE::ConstRef delegate, STTx const &tx)
Check if the delegate account has permission to execute the transaction.
static void removeExpiredCredentials(ApplyView &view, std::vector< UInt256 > const &creds, beast::Journal viewJ)
constexpr std::uint16_t kMaxDeletableAmmTrustLines
The maximum number of trustlines to delete as part of AMM account deletion cleanup.
std::string transToken(TER code)
bool isReserveSponsored(STTx const &tx)
Whether the transaction's reserve is sponsored (sfSponsor present + spfSponsorReserve set).
std::string to_string(BaseUInt< Bits, Tag > const &a)
std::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
constexpr std::size_t kExpiredOfferRemoveLimit
The maximum number of expired offers to delete at once.
TER checkInvariants(ApplyContext &ctx, TER result, XRPAmount fee, std::optional< std::reference_wrapper< TxInvariantCheck > > txCheck)
Run all protocol invariant checks plus the transaction-specific check in a single pass over the modif...
Slice makeSlice(std::array< T, N > const &a)
void open(soci::session &s, BasicConfig const &config, std::string const &dbName)
Open a soci session.
bool isReserveSponsorAllowed(TxType txType)
Whether the given transaction type may use reserve sponsorship (v1).
std::string toShortString(BaseUInt< Bits, Tag > const &a)
TERSubset< CanCvtToNotTEC > NotTEC
static void removeUnfundedOffers(ApplyView &view, std::vector< UInt256 > const &offers, beast::Journal viewJ)
void decreaseOwnerCountForObject(ApplyView &view, SLE::Ref accountSle, SLE::Ref objectSle, std::uint32_t count, beast::Journal j)
Decrease owner-count fields for an existing ledger object.
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
bool isFeeSponsored(STTx const &tx)
Whether the transaction's fee is sponsored (sfSponsor present + spfSponsorFee set).
static NotTEC preflight1Sponsor(PreflightContext const &ctx)
AccountID calcAccountID(PublicKey const &pk)
bool hasInvalidAmount(STBase const &field, beast::Journal j)
bool isPseudoAccount(SLE::const_pointer sleAcct)
Returns true if and only if sleAcct is a pseudo-account of any kind (i.e.
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
constexpr FlagValue spfSponsorFlagMask
XRPAmount scaleFeeLoad(XRPAmount fee, LoadFeeTrack const &feeTrack, Fees const &fees, bool bUnlimited)
bool isTesSuccess(TER x) noexcept
TERSubset< CanCvtToTER > TER
XRPAmount accountReserve(ReadView const &view, SLE::ConstRef sle, beast::Journal j, Adjustment adj={})
Returns the account reserve, in drops.
NotTEC preflight0(PreflightContext const &ctx, std::uint32_t flagMask)
Performs early sanity checks on the txid and flags.
bool isTecClaim(TER x) noexcept
constexpr std::size_t kUnfundedOfferRemoveLimit
The maximum number of unfunded offers to delete at once.
constexpr std::size_t kOversizeMetaDataCap
The maximum number of metadata entries allowed in one transaction.
bool isPseudoTx(STObject const &tx)
Check whether a transaction is a pseudo-transaction.
constexpr FlagValue tfUniversalMask
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
Reflects the fee settings for a particular ledger.
State information when determining if a tx is likely to claim a fee.
std::reference_wrapper< ServiceRegistry > registry
std::optional< UInt256 const > const parentBatchId
State information when preflighting a tx.
std::optional< UInt256 const > parentBatchId
std::reference_wrapper< ServiceRegistry > registry