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/RippleStateHelpers.h>
20#include <xrpl/ledger/helpers/SponsorHelpers.h>
21#include <xrpl/protocol/AccountID.h>
22#include <xrpl/protocol/Feature.h>
23#include <xrpl/protocol/Indexes.h>
24#include <xrpl/protocol/LedgerFormats.h>
25#include <xrpl/protocol/Permissions.h>
26#include <xrpl/protocol/Protocol.h>
27#include <xrpl/protocol/PublicKey.h>
28#include <xrpl/protocol/Rules.h>
29#include <xrpl/protocol/SField.h>
30#include <xrpl/protocol/STAmount.h>
31#include <xrpl/protocol/STLedgerEntry.h>
32#include <xrpl/protocol/STTx.h>
33#include <xrpl/protocol/Serializer.h>
34#include <xrpl/protocol/SystemParameters.h>
35#include <xrpl/protocol/TER.h>
36#include <xrpl/protocol/TxFlags.h>
37#include <xrpl/protocol/TxMeta.h>
38#include <xrpl/protocol/XRPAmount.h>
39#include <xrpl/server/LoadFeeTrack.h>
40#include <xrpl/tx/ApplyContext.h>
41#include <xrpl/tx/SignerEntries.h>
42#include <xrpl/tx/apply.h>
43#include <xrpl/tx/applySteps.h>
44#include <xrpl/tx/invariants/InvariantRunner.h>
68 JLOG(ctx.
j.
warn()) <<
"Pseudo transactions cannot contain the "
69 "tfInnerBatchTxn flag.";
75 uint32_t
const nodeNID = ctx.
registry.get().getNetworkIDService().getNetworkID();
92 if (*txNID != nodeNID)
101 JLOG(ctx.
j.
warn()) <<
"applyTransaction: transaction id may not be zero";
108 <<
": invalid flags.";
125 if (
auto const spk = sigObject.
getFieldVL(sfSigningPubKey);
128 JLOG(j.
debug()) <<
"preflightCheckSigningKey: invalid signing key";
140 if (signature && !signature->empty())
153 for (
auto const& signer : sigObject.
getFieldArray(sfSigners))
155 if (signer.isFieldPresent(sfTxnSignature) && !signer[sfTxnSignature].empty())
163 Slice const signingPubKey = sigObject[sfSigningPubKey];
164 if (!signingPubKey.
empty())
183 if ((hasSponsor || hasSponsorFlags || hasSponsorSig) && !ctx.
rules.
enabled(featureSponsor))
186 if (hasSponsor != hasSponsorFlags)
188 JLOG(ctx.
j.
debug()) <<
"preflight1: sponsor and sponsor flags mismatch";
191 if (hasSponsorSig && (!hasSponsor || !hasSponsorFlags))
193 JLOG(ctx.
j.
debug()) <<
"preflight1: sponsor signature without sponsor definition";
199 auto const sponsorFlags = ctx.
tx.
getFieldU32(sfSponsorFlags);
202 JLOG(ctx.
j.
debug()) <<
"preflight1: invalid sponsor flags";
213 <<
"preflight1: spfSponsorReserve not allowed for this transaction type";
221 JLOG(ctx.
j.
debug()) <<
"preflight1: Sponsor account cannot be the same as the account";
236 if (!ctx.
rules.
enabled(featurePermissionDelegationV1_1))
239 if (ctx.
tx[sfDelegate] == ctx.
tx[sfAccount])
249 !perm.hasGranularPermissions(txType))
253 if (
auto const ret =
preflight0(ctx, flagMask))
259 JLOG(ctx.
j.
warn()) <<
"preflight1: bad account id";
265 if (!fee.native() || fee.negative() || !
isLegalAmount(fee.xrp()))
267 JLOG(ctx.
j.
debug()) <<
"preflight1: invalid fee";
331 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;
772 JLOG(ctx.
j.
trace()) <<
"applyTransaction: delay: source account does not exist "
778 (sle->getFieldH256(sfAccountTxnID) != ctx.
tx.
getFieldH256(sfAccountTxnID)))
794 XRPL_ASSERT(sleAccount,
"xrpl::Transactor::consumeSeqProxy : non-null account");
796 if (seqProxy.
isSeq())
801 sleAccount->setFieldU32(sfSequence, seqProxy.
value() + 1);
822 JLOG(j.
fatal()) <<
"Ticket disappeared from ledger.";
831 JLOG(j.
fatal()) <<
"Unable to delete Ticket from owner.";
842 JLOG(j.
fatal()) <<
"Could not find Ticket owner account root.";
847 if (
auto ticketCount = (*sleAccount)[~sfTicketCount])
849 if (*ticketCount == 1)
851 sleAccount->makeFieldAbsent(sfTicketCount);
855 ticketCount = *ticketCount - 1;
861 JLOG(j.
fatal()) <<
"TicketCount field missing from account root.";
870 view.erase(sleTicket);
894 "xrpl::Transactor::apply : non-null SLE or zero account");
908 if (sle->isFieldPresent(sfAccountTxnID))
909 sle->setFieldH256(sfAccountTxnID,
ctx_.tx.getTransactionID());
925 bool permitUncreatedAccount)
930 if ((
view.rules().enabled(featureLendingProtocol) ||
931 view.rules().enabled(featureBatchV1_1) ||
view.rules().enabled(fixCleanup3_3_0)) &&
941 auto const pkSigner = sigObject.
getFieldVL(sfSigningPubKey);
943 if (parentBatchId &&
view.rules().enabled(featureBatchV1_1))
946 if (sigObject.
isFieldPresent(sfTxnSignature) || !pkSigner.empty() ||
969 auto const sponsorID = sigObject.
getAccountID(sfSponsor);
970 auto const sponsorSignature = sigObject.
getFieldObject(sfSponsorSignature);
971 if (
auto const ret =
checkSign(
view, flags, std::nullopt, sponsorID, sponsorSignature, j);
984 XRPL_ASSERT(!pkSigner.empty(),
"xrpl::Transactor::checkSign : non-empty signer");
988 JLOG(j.
trace()) <<
"checkSign: signing public key type is unknown";
1000 if (!permitUncreatedAccount)
1002 if (idAccount != idSigner)
1026 bool const isMasterDisabled = sleAccount->isFlag(lsfDisableMaster);
1029 if ((*sleAccount)[~sfRegularKey] == idSigner)
1035 if (!isMasterDisabled && idAccount == idSigner)
1041 if (isMasterDisabled && idAccount == idSigner)
1061 if (!sleAccountSigners)
1063 JLOG(j.
trace()) <<
"applyTransaction: Invalid: Not a multi-signing account.";
1070 sleAccountSigners->isFieldPresent(sfSignerListID),
1071 "xrpl::Transactor::checkMultiSign : has signer list ID");
1073 sleAccountSigners->getFieldU32(sfSignerListID) == 0,
1074 "xrpl::Transactor::checkMultiSign : signer list ID is 0");
1077 if (!accountSigners)
1078 return accountSigners.error();
1090 auto iter = accountSigners->begin();
1091 for (
auto const& txSigner : txSigners)
1093 AccountID const txSignerAcctID = txSigner.getAccountID(sfAccount);
1096 while (iter->account < txSignerAcctID)
1098 if (++iter == accountSigners->end())
1100 JLOG(j.
trace()) <<
"applyTransaction: Invalid SigningAccount.Account.";
1104 if (iter->account != txSignerAcctID)
1107 JLOG(j.
trace()) <<
"applyTransaction: Invalid SigningAccount.Account.";
1114 auto const spk = txSigner.getFieldVL(sfSigningPubKey);
1120 JLOG(j.
trace()) <<
"checkMultiSign: signing public key type is unknown";
1126 "xrpl::Transactor::checkMultiSign : non-empty signer or "
1128 AccountID const signingAcctIDFromPubKey =
1158 if (signingAcctIDFromPubKey == txSignerAcctID)
1161 if (sleTxSignerRoot)
1164 std::uint32_t const signerAccountFlags = sleTxSignerRoot->getFieldU32(sfFlags);
1166 if ((signerAccountFlags & lsfDisableMaster) != 0u)
1168 JLOG(j.
trace()) <<
"applyTransaction: Signer:Account lsfDisableMaster.";
1177 if (!sleTxSignerRoot)
1179 JLOG(j.
trace()) <<
"applyTransaction: Non-phantom signer "
1180 "lacks account root.";
1184 if (!sleTxSignerRoot->isFieldPresent(sfRegularKey))
1186 JLOG(j.
trace()) <<
"applyTransaction: Account lacks RegularKey.";
1189 if (signingAcctIDFromPubKey != sleTxSignerRoot->getAccountID(sfRegularKey))
1191 JLOG(j.
trace()) <<
"applyTransaction: Account doesn't match RegularKey.";
1196 weightSum += iter->weight;
1200 if (weightSum < sleAccountSigners->getFieldU32(sfSignerQuorum))
1202 JLOG(j.
trace()) <<
"applyTransaction: Signers failed to meet quorum.";
1217 for (
auto const& index : offers)
1237 for (
auto const& index : offers)
1251 for (
auto const& index : creds)
1258 <<
"removeExpiredCredentials: failed to delete expired credential. Err: "
1273 JLOG(viewJ.
error()) <<
"removeDeletedTrustLines: deleted trustlines exceed max "
1274 << trustLines.
size();
1278 for (
auto const& index : trustLines)
1280 if (
auto const sleState = view.
peek({ltRIPPLE_STATE, index});
1283 JLOG(viewJ.
error()) <<
"removeDeletedTrustLines: failed to delete AMM trustline";
1307 auto const payerSle =
view().
peek(feePayer.keylet);
1313 if (payerSle->isFieldPresent(feePayer.balanceField))
1315 balance = payerSle->getFieldAmount(feePayer.balanceField).xrp();
1317 else if (feePayer.balanceField != sfFeeAmount)
1324 auto const cap = payerSle->getFieldAmount(sfMaxFee).xrp();
1336 spendable = balance > sponsorReserve ? balance - sponsorReserve :
beast::kZero;
1342 "xrpl::Transactor::reset : valid balance");
1347 if (fee > spendable)
1356 auto const feeAmountAfter = balance - fee;
1357 if (feeAmountAfter ==
beast::kZero && feePayer.balanceField == sfFeeAmount)
1360 payerSle->makeFieldAbsent(feePayer.balanceField);
1364 payerSle->setFieldAmount(feePayer.balanceField, feeAmountAfter);
1368 XRPL_ASSERT(
isTesSuccess(ter),
"xrpl::Transactor::reset : result is tesSUCCESS");
1373 if (payerSle != txnAcct)
1390 if (
view.exists(sponsorshipKeylet))
1395 .keylet = sponsorshipKeylet,
1396 .balanceField = sfFeeAmount,
1403 "xrpl::getFeePayer has sponsor signature without a sponsorship object");
1409 .balanceField = sfBalance,
1415 auto const payerType =
1419 .id = payerID, .keylet = payerAccountKeylet, .balanceField = sfBalance, .type = payerType};
1427 JLOG(
j_.debug()) <<
"Transaction trapped: " << txHash;
1433 JLOG(
j_.trace()) <<
"reapplying because of " <<
transToken(result);
1440 auto typesForResult = [](
TER const ter) {
1448 types.
insert(ltRIPPLE_STATE);
1452 types.
insert(ltNFTOKEN_OFFER);
1453 types.
insert(ltCREDENTIAL);
1461 auto const typesToCollect = typesForResult(result);
1464 if (!typesToCollect.empty())
1467 [&typesToCollect, &deletedObjects](
1473 "xrpl::Transactor::processPersistentChanges : non-null "
1475 if (before &&
after)
1477 auto const type = before->getType();
1478 if (typesToCollect.contains(type))
1482 if (type == ltOFFER &&
1483 before->getFieldAmount(sfTakerPays) !=
1484 after->getFieldAmount(sfTakerPays))
1487 deletedObjects[type].push_back(index);
1496 auto const resetResult =
reset(fee);
1498 result = resetResult.first;
1500 fee = resetResult.second;
1505 auto const typesToApply = typesForResult(result);
1506 if (
isTecClaim(result) && !typesToApply.empty())
1508 auto const viewJ =
ctx_.registry.get().getJournal(
"View");
1509 for (
auto const& [type, ids] : deletedObjects)
1511 if (ids.empty() || !typesToApply.contains(type))
1519 case ltNFTOKEN_OFFER:
1522 case ltRIPPLE_STATE:
1531 "xrpl::Transactor::processPersistentChanges() : "
1555 JLOG(
j_.trace()) <<
"apply: " <<
ctx_.tx.getTransactionID();
1574 JLOG(
j_.fatal()) <<
"Transaction serdes mismatch";
1577 UNREACHABLE(
"xrpl::Transactor::operator() : transaction serdes mismatch");
1583 if (
auto const& trap =
ctx_.registry.get().getTrapTxID();
1584 trap && *trap ==
ctx_.tx.getTransactionID())
1589 auto result =
ctx_.preclaimResult;
1595 XRPL_ASSERT(result !=
temUNKNOWN,
"xrpl::Transactor::operator() : result is not temUNKNOWN");
1597 if (
auto stream =
j_.trace())
1598 stream <<
"preclaim result: " <<
transToken(result);
1600 auto fee =
ctx_.tx.getFieldAmount(sfFee).xrp();
1601 bool const canApply =
std::invoke([&result, &fee,
this] {
1612 canApplyTmp =
false;
1625 auto const logger = [
this](
1629 JLOG(
j_.trace()) << (canApply ?
"applied " :
"not applied ") <<
transToken(result);
1630 return {result, canApply, std::move(metadata)};
1634 return logger(result, canApply);
1646 auto const resetResult =
reset(fee);
1648 result = resetResult.first;
1650 fee = resetResult.second;
1664 return logger(result,
false);
1682 ctx_.destroyXRP(fee);
1685 metadata =
ctx_.apply(result);
1688 return logger(result,
false, std::move(metadata));
1690 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)
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 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.
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