1#include <xrpl/tx/invariants/InvariantCheck.h>
3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/beast/utility/Zero.h>
7#include <xrpl/beast/utility/instrumentation.h>
8#include <xrpl/ledger/ReadView.h>
9#include <xrpl/ledger/helpers/AccountRootHelpers.h>
10#include <xrpl/ledger/helpers/TokenHelpers.h>
11#include <xrpl/protocol/AccountID.h>
12#include <xrpl/protocol/Asset.h>
13#include <xrpl/protocol/Feature.h>
14#include <xrpl/protocol/Indexes.h>
15#include <xrpl/protocol/Issue.h>
16#include <xrpl/protocol/Keylet.h>
17#include <xrpl/protocol/LedgerFormats.h>
18#include <xrpl/protocol/MPTIssue.h>
19#include <xrpl/protocol/Protocol.h>
20#include <xrpl/protocol/Rules.h>
21#include <xrpl/protocol/SField.h>
22#include <xrpl/protocol/STAmount.h>
23#include <xrpl/protocol/STLedgerEntry.h>
24#include <xrpl/protocol/STNumber.h>
25#include <xrpl/protocol/STTx.h>
26#include <xrpl/protocol/STVector256.h>
27#include <xrpl/protocol/SystemParameters.h>
28#include <xrpl/protocol/TER.h>
29#include <xrpl/protocol/TxFormats.h>
30#include <xrpl/protocol/TxSettings.h>
31#include <xrpl/protocol/UintTypes.h>
32#include <xrpl/protocol/XRPAmount.h>
33#include <xrpl/tx/invariants/InvariantCheckPrivilege.h>
46#pragma push_macro("UNWRAP")
48#pragma push_macro("TRANSACTION")
51#define UNWRAP(...) __VA_ARGS__
52#define TRANSACTION(tag, value, name, settings, ...) \
54 return ((TxSettings UNWRAP settings).privileges & priv) != Privilege::NoPriv; \
62#include <xrpl/protocol/detail/transactions.macro>
71#pragma pop_macro("TRANSACTION")
73#pragma pop_macro("UNWRAP")
85 UNREACHABLE(
"xrpl::ledgerEntryTypeName : ledger entry has no known ledger format");
89 return item->getName();
109 JLOG(j.
fatal()) <<
"Invariant failed: fee paid was negative: " << fee.
drops();
117 JLOG(j.
fatal()) <<
"Invariant failed: fee paid exceeds system limit: " << fee.
drops();
125 JLOG(j.
fatal()) <<
"Invariant failed: fee paid is " << fee.
drops()
126 <<
" exceeds fee specified in transaction.";
147 switch (before->getType())
150 drops_ -= (*before)[sfBalance].xrp().drops();
153 drops_ -= ((*before)[sfAmount] - (*before)[sfBalance]).xrp().drops();
156 if (
isXRP((*before)[sfAmount]))
157 drops_ -= (*before)[sfAmount].xrp().drops();
160 if (before->isFieldPresent(sfFeeAmount))
163 isXRP((*before)[sfFeeAmount]),
164 "XRPNotCreated::visitEntry : Sponsorship.FeeAmount is XRP");
165 drops_ -= (*before)[sfFeeAmount].xrp().drops();
176 UNREACHABLE(
"xrpl::XRPNotCreated::visitEntry : after can't be null");
180 switch (
after->getType())
183 drops_ += (*after)[sfBalance].xrp().drops();
187 drops_ += ((*after)[sfAmount] - (*after)[sfBalance]).xrp().drops();
191 drops_ += (*after)[sfAmount].xrp().drops();
194 if (!isDelete &&
after->isFieldPresent(sfFeeAmount))
198 "XRPNotCreated::visitEntry : Sponsorship.FeeAmount is XRP");
199 drops_ += (*after)[sfFeeAmount].xrp().drops();
222 JLOG(j.
fatal()) <<
"Invariant failed: XRP net change was positive: " <<
drops_;
229 JLOG(j.
fatal()) <<
"Invariant failed: XRP net change of " <<
drops_ <<
" doesn't match fee "
242 auto const isBad = [](
STAmount const& balance) {
243 if (!balance.native())
246 auto const drops = balance.xrp();
260 if (before && before->getType() == ltACCOUNT_ROOT)
261 bad_ |= isBad((*before)[sfBalance]);
263 if (
after &&
after->getType() == ltACCOUNT_ROOT)
277 JLOG(j.
fatal()) <<
"Invariant failed: incorrect account XRP balance";
298 return pays.
native() && gets.native();
301 if (before && before->getType() == ltOFFER)
302 bad_ |= isBad((*before)[sfTakerPays], (*before)[sfTakerGets]);
318 JLOG(j.
fatal()) <<
"Invariant failed: offer with a bad amount";
330 auto const isBad = [](
STAmount const& amount) {
342 return amount.asset().visit(
343 [&](
Issue const& issue) {
360 if (amount.mpt() >
MPTAmount{kMaxMpTokenAmount})
369 if (before && before->getType() == ltESCROW)
370 bad_ |= isBad((*before)[sfAmount]);
382 if (
after &&
after->getType() == ltMPTOKEN_ISSUANCE)
384 auto const outstanding = (*after)[sfOutstandingAmount];
385 checkAmount(outstanding);
386 if (
auto const locked = (*
after)[~sfLockedAmount])
388 checkAmount(*locked);
389 bool const isBad = outstanding < *locked;
390 if (overwriteFixEnabled)
403 auto const mptAmount = (*after)[sfMPTAmount];
404 checkAmount(mptAmount);
405 if (
auto const locked = (*
after)[~sfLockedAmount])
407 checkAmount(*locked);
422 JLOG(j.
fatal()) <<
"Invariant failed: escrow specifies invalid amount";
434 if (isDelete && before && before->getType() == ltACCOUNT_ROOT)
457 JLOG(j.
fatal()) <<
"Invariant failed: account deletion "
458 "succeeded without deleting an account";
462 JLOG(j.
fatal()) <<
"Invariant failed: account deletion "
463 "succeeded but deleted multiple accounts!";
477 JLOG(j.
fatal()) <<
"Invariant failed: an account root was deleted";
486 if (isDelete && before && before->getType() == ltACCOUNT_ROOT)
502 [[maybe_unused]]
bool const enforce = view.
rules().
enabled(fixCleanup3_2_0) ||
506 auto const objectExists = [&view, enforce, &j](
auto const&
keylet) {
511 JLOG(j.
fatal()) <<
"Invariant failed: account deletion left behind a "
517 "xrpl::AccountRootsDeletedClean::finalize::objectExists : "
518 "account deletion left no objects behind");
526 auto const accountID = before->getAccountID(sfAccount);
530 JLOG(j.
fatal()) <<
"Invariant failed: account deletion left "
531 "behind a non-zero balance";
534 "xrpl::AccountRootsDeletedClean::finalize : "
535 "deleted account has zero balance");
540 if (
after->at(sfOwnerCount) != 0)
542 JLOG(j.
fatal()) <<
"Invariant failed: account deletion left "
543 "behind a non-zero owner count";
546 "xrpl::AccountRootsDeletedClean::finalize : "
547 "deleted account has zero owner count");
552 if (
after->isFieldPresent(sfSponsoredOwnerCount) ||
553 after->isFieldPresent(sfSponsoringOwnerCount) ||
554 after->isFieldPresent(sfSponsoringAccountCount) ||
after->isFieldPresent(sfSponsor))
556 JLOG(j.
fatal()) <<
"Invariant failed: account deletion left "
557 "behind a sponsorship field";
560 "xrpl::AccountRootsDeletedClean::finalize : "
561 "deleted account has no sponsorship fields");
568 if (objectExists(
std::invoke(keyletDesc.function, accountID)) && enforce)
583 if (key && objectExists(
Keylet{ltNFTOKEN_PAGE, *key}) && enforce)
591 if (before->isFieldPresent(*field))
593 auto const key = before->getFieldH256(*field);
608 if (before &&
after && before->getType() !=
after->getType())
613#pragma push_macro("LEDGER_ENTRY")
616#define LEDGER_ENTRY(tag, ...) case tag:
618 switch (
after->getType())
620#include <xrpl/protocol/detail/ledger_entries.macro>
629#pragma pop_macro("LEDGER_ENTRY")
646 JLOG(j.
fatal()) <<
"Invariant failed: ledger entry type mismatch";
651 JLOG(j.
fatal()) <<
"Invariant failed: invalid ledger entry type added";
664 if (
after &&
after->getType() == ltRIPPLE_STATE)
669 bool const isXrp =
after->getFieldAmount(sfLowLimit).asset() ==
xrpIssue() ||
671 if (overwriteFixEnabled)
693 JLOG(j.
fatal()) <<
"Invariant failed: an XRP trust line was created";
702 if (
after &&
after->getType() == ltRIPPLE_STATE)
706 bool const lowFreeze =
after->isFlag(lsfLowFreeze);
707 bool const lowDeepFreeze =
after->isFlag(lsfLowDeepFreeze);
709 bool const highFreeze =
after->isFlag(lsfHighFreeze);
710 bool const highDeepFreeze =
after->isFlag(lsfHighDeepFreeze);
712 bool const bad = (lowDeepFreeze && !lowFreeze) || (highDeepFreeze && !highFreeze);
713 if (overwriteFixEnabled)
735 JLOG(j.
fatal()) <<
"Invariant failed: a trust line with deep freeze flag "
736 "without normal freeze was created";
745 if (!before &&
after->getType() == ltACCOUNT_ROOT)
767 JLOG(j.
fatal()) <<
"Invariant failed: multiple accounts "
768 "created in a single transaction";
776 bool const pseudoAccount =
778 (view.
rules().enabled(featureSingleAssetVault) ||
783 JLOG(j.
fatal()) <<
"Invariant failed: pseudo-account created by a "
784 "wrong transaction type";
792 JLOG(j.
fatal()) <<
"Invariant failed: account created with "
793 "wrong starting sequence number";
799 std::uint32_t const expected = (lsfDisableMaster | lsfDefaultRipple | lsfDepositAuth);
802 JLOG(j.
fatal()) <<
"Invariant failed: pseudo-account created with "
811 JLOG(j.
fatal()) <<
"Invariant failed: account root created illegally";
827 if (sle->getType() != ltRIPPLE_STATE ||
833 STAmount balance = sle->getFieldAmount(sfBalance);
836 balance.
get<
Issue>().account = issuer;
843 if (before && before->getType() == ltRIPPLE_STATE)
846 iou_.before = before;
849 if (!isDelete &&
after &&
after->getType() == ltRIPPLE_STATE)
852 if (before && before->getType() == ltMPTOKEN)
855 mpt_.before = before;
858 if (!isDelete &&
after &&
after->getType() == ltMPTOKEN)
877 JLOG(j.
fatal()) <<
"Invariant failed: more than one trustline changed.";
883 JLOG(j.
fatal()) <<
"Invariant failed: more than one mptokens changed.";
887 bool const mptV2Enabled = view.
rules().
enabled(featureMPTokensV2);
890 JLOG(j.
fatal()) <<
"Invariant failed: trustline and MPToken both changed.";
900 [&](
Issue const& issue) {
906 if (holderBalance.
signum() < 0)
908 JLOG(j.
fatal()) <<
"Invariant failed: trustline or MPT balance is negative";
915 <<
"Invariant failed: trustline clawback changed the wrong line";
916 return !mptV2Enabled;
923 if (!beforeBalance || !afterBalance)
926 <<
"Invariant failed: trustline clawback changed the wrong line";
927 return !mptV2Enabled;
931 clawAmount.
get<
Issue>().account = issuer;
934 JLOG(j.
fatal()) <<
"Invariant failed: trustline clawback amount is invalid";
935 return !mptV2Enabled;
942 if (*afterBalance > *beforeBalance ||
943 *afterBalance != *beforeBalance -
std::min(*beforeBalance, clawAmount))
946 <<
"Invariant failed: trustline clawback balance change is invalid";
947 return !mptV2Enabled;
953 auto const holder = tx[~sfHolder];
956 JLOG(j.
fatal()) <<
"Invariant failed: MPT clawback missing holder";
957 return !mptV2Enabled;
962 JLOG(j.
fatal()) <<
"Invariant failed: MPT clawback token is missing";
963 return !mptV2Enabled;
966 if (
mpt_.before->getAccountID(sfAccount) != *holder ||
967 mpt_.after->getAccountID(sfAccount) != *holder ||
968 (*
mpt_.before)[sfMPTokenIssuanceID] != issue.getMptID() ||
969 (*
mpt_.after)[sfMPTokenIssuanceID] != issue.getMptID())
971 JLOG(j.
fatal()) <<
"Invariant failed: MPT clawback changed the wrong token";
972 return !mptV2Enabled;
975 auto const before =
mpt_.before->getFieldU64(sfMPTAmount);
976 auto const after =
mpt_.after->getFieldU64(sfMPTAmount);
979 JLOG(j.
fatal()) <<
"Invariant failed: MPT clawback amount is invalid";
980 return !mptV2Enabled;
982 auto const clawAmount = amount.
mantissa();
989 <<
"Invariant failed: MPT clawback balance change is invalid";
990 return !mptV2Enabled;
1001 JLOG(j.
fatal()) <<
"Invariant failed: some trustlines were changed "
1002 "despite failure of the transaction.";
1008 JLOG(j.
fatal()) <<
"Invariant failed: some mptokens were changed "
1009 "despite failure of the transaction.";
1025 [&](
Issue const& issue) {
1038 auto const pseudoAcctID = pseudo[sfAccount];
1042 if (entry.getType() == ltAMM)
1043 return entry.key() == pseudo[sfAMMID];
1048 if (
isHolding(entry, (*amm)[sfAsset], pseudoAcctID) ||
1049 isHolding(entry, (*amm)[sfAsset2], pseudoAcctID))
1054 if (entry.getType() != ltRIPPLE_STATE)
1056 auto const low = entry[sfLowLimit].getIssuer();
1057 auto const high = entry[sfHighLimit].getIssuer();
1058 auto const lpCurrency = (*amm)[sfLPTokenBalance].
get<
Issue>().currency;
1059 return (low == pseudoAcctID || high == pseudoAcctID) &&
1065 if (entry.getType() == ltLOAN_BROKER)
1066 return entry[sfVaultID] == pseudo[sfVaultID];
1072 isHolding(entry, (*vault)[sfAsset], pseudoAcctID);
1077 if (entry.getType() == ltLOAN)
1078 return entry[sfLoanBrokerID] == pseudo[sfLoanBrokerID];
1084 return vault &&
isHolding(entry, (*vault)[sfAsset], pseudoAcctID);
1101 if (
after &&
after->getType() == ltDIR_NODE &&
after->isFieldPresent(sfOwner))
1103 auto const& afterIndexes =
after->getFieldV256(sfIndexes);
1107 added.
assign(afterIndexes.begin(), afterIndexes.end());
1111 auto const& beforeIndexes = before->getFieldV256(sfIndexes);
1112 for (
auto const& index : afterIndexes)
1114 if (!std::ranges::contains(beforeIndexes, index))
1122 owned.insert(owned.end(), added.
begin(), added.
end());
1127 if (
after &&
after->getType() == ltACCOUNT_ROOT)
1129 bool const isPseudo = [&] {
1136 if (
after->at(sfSequence) == 0)
1156 [&
after](
SField const* sf) ->
bool {
return after->isFieldPresent(*sf); });
1160 error <<
"pseudo-account has " << numFields <<
" pseudo-account fields set";
1164 if (before && before->at(sfSequence) !=
after->at(sfSequence))
1166 errors_.emplace_back(
"pseudo-account sequence changed");
1168 if (!
after->isFlag(lsfDisableMaster | lsfDefaultRipple | lsfDepositAuth))
1170 errors_.emplace_back(
"pseudo-account flags are not set");
1172 if (
after->isFieldPresent(sfRegularKey))
1174 errors_.emplace_back(
"pseudo-account has a regular key");
1176 if (
after->isFieldPresent(sfSponsoredOwnerCount) ||
1177 after->isFieldPresent(sfSponsoringOwnerCount) ||
after->isFieldPresent(sfSponsor) ||
1178 after->isFieldPresent(sfSponsoringAccountCount))
1180 errors_.emplace_back(
"pseudo-account has a sponsorship field");
1194 bool const enforce = view.
rules().
enabled(featureSingleAssetVault);
1197 "xrpl::ValidPseudoAccounts::finalize : no bad "
1198 "changes or enforce invariant");
1201 for (
auto const& error :
errors_)
1203 JLOG(j.
fatal()) <<
"Invariant failed: " << error;
1221 for (
auto const& index : indexes)
1226 JLOG(j.
fatal()) <<
"Invariant failed: pseudo-account " <<
toBase58(owner)
1227 <<
" owner directory links a missing object " <<
to_string(index);
1233 JLOG(j.
fatal()) <<
"Invariant failed: pseudo-account " <<
toBase58(owner)
1249 if (isDelete || !before)
1266 auto const kFieldChanged = [&j, &tx](
auto const& before,
auto const&
after,
auto const& field) {
1267 bool const beforeField = before->isFieldPresent(field);
1268 bool const afterField =
after->isFieldPresent(field);
1269 bool const changed =
1270 beforeField != afterField || (afterField && before->at(field) !=
after->at(field));
1273 JLOG(j.
fatal()) <<
"Invariant failed: " << field.getName()
1280 auto const& before = slePair.first;
1281 auto const&
after = slePair.second;
1282 auto const type =
after->getType();
1287 bool const enforce = view.
rules().
enabled(featureLendingProtocol);
1288 bool bad = kFieldChanged(before,
after, sfLedgerEntryType) ||
1289 kFieldChanged(before,
after, sfLedgerIndex);
1293 bad = bad || kFieldChanged(before,
after, sfSequence) ||
1294 kFieldChanged(before,
after, sfOwnerNode) ||
1295 kFieldChanged(before,
after, sfVaultNode) ||
1296 kFieldChanged(before,
after, sfVaultID) ||
1297 kFieldChanged(before,
after, sfAccount) ||
1298 kFieldChanged(before,
after, sfOwner) ||
1299 kFieldChanged(before,
after, sfManagementFeeRate) ||
1300 kFieldChanged(before,
after, sfCoverRateMinimum) ||
1301 kFieldChanged(before,
after, sfCoverRateLiquidation);
1305 bad = bad || kFieldChanged(before,
after, sfFlags);
1308 bad = bad || kFieldChanged(before,
after, sfSequence) ||
1309 kFieldChanged(before,
after, sfOwnerNode) ||
1310 kFieldChanged(before,
after, sfLoanBrokerNode) ||
1311 kFieldChanged(before,
after, sfLoanBrokerID) ||
1312 kFieldChanged(before,
after, sfBorrower) ||
1313 kFieldChanged(before,
after, sfLoanOriginationFee) ||
1314 kFieldChanged(before,
after, sfLoanServiceFee) ||
1315 kFieldChanged(before,
after, sfLatePaymentFee) ||
1316 kFieldChanged(before,
after, sfClosePaymentFee) ||
1317 kFieldChanged(before,
after, sfOverpaymentFee) ||
1318 kFieldChanged(before,
after, sfInterestRate) ||
1319 kFieldChanged(before,
after, sfLateInterestRate) ||
1320 kFieldChanged(before,
after, sfCloseInterestRate) ||
1321 kFieldChanged(before,
after, sfOverpaymentInterestRate) ||
1322 kFieldChanged(before,
after, sfStartDate) ||
1323 kFieldChanged(before,
after, sfPaymentInterval) ||
1324 kFieldChanged(before,
after, sfGracePeriod) ||
1325 kFieldChanged(before,
after, sfLoanScale);
1334 bool const overpaymentChanged =
1335 (beforeFlags & lsfLoanOverpayment) != (afterFlags & lsfLoanOverpayment);
1336 if (overpaymentChanged)
1338 JLOG(j.
fatal()) <<
"Invariant failed: lsfLoanOverpayment flag "
1339 "toggled on immutable ledger entry in "
1342 bad = bad || overpaymentChanged;
1343 bool const defaultCleared =
1344 (beforeFlags & lsfLoanDefault) != 0 && (afterFlags & lsfLoanDefault) == 0;
1347 JLOG(j.
fatal()) <<
"Invariant failed: lsfLoanDefault flag "
1348 "cleared on immutable ledger entry in "
1351 bad = bad || defaultCleared;
1363 bad = bad || kFieldChanged(before,
after, sfVaultKind) ||
1364 kFieldChanged(before,
after, sfSubscriptionDate) ||
1365 kFieldChanged(before,
after, sfRedemptionDate) ||
1366 kFieldChanged(before,
after, sfSequence) ||
1367 kFieldChanged(before,
after, sfOwnerNode) ||
1368 kFieldChanged(before,
after, sfOwner) ||
1369 kFieldChanged(before,
after, sfWithdrawalPolicy) ||
1370 kFieldChanged(before,
after, sfScale) ||
1371 kFieldChanged(before,
after, sfLEVersion) ||
1372 kFieldChanged(before,
after, sfAsset) ||
1373 kFieldChanged(before,
after, sfAccount) ||
1374 kFieldChanged(before,
after, sfShareMPTID);
1382 "xrpl::NoModifiedUnmodifiableFields::finalize : no bad "
1383 "changes or enforce invariant");
1386 JLOG(j.
fatal()) <<
"Invariant failed: changed an unchangeable field for "
1401 if (!isDelete &&
after)
1419 <<
"Invariant failed: ledger entry contains non-canonical MPT or XRP amount";
1437 "xrpl::ObjectHasPseudoAccount::visitEntry : deleted ledger entry missing before state");
1442 switch (before->getType())
1468 bool failed =
false;
1471 if (!sle->isFieldPresent(sfAccount))
1474 <<
" is missing pseudo-account field";
1483 <<
" without deleting its pseudo-account";
A generic endpoint for log messages.
Value get(UInt index, Value const &defaultValue) const
If the array contains at least index+1 elements, returns the element value, otherwise returns default...
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
std::vector< std::pair< SLE::const_pointer, SLE::const_pointer > > accountsDeleted_
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &) const
std::uint32_t accountsDeleted_
constexpr auto visit(Visitors &&... visitors) const -> decltype(auto)
A currency issued by an account.
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &) const
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &) const
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
bool deepFreezeWithoutFreeze_
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &) const
std::set< std::pair< SLE::const_pointer, SLE::const_pointer > > changedEntries_
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &) const
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &) const
std::vector< SLE::const_pointer > deletedObjSles_
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &) const
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
virtual Rules const & rules() const =0
Returns the tx processing rules.
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
LedgerIndex seq() const
Returns the sequence number of the base ledger.
virtual std::optional< key_type > succ(key_type const &key, std::optional< key_type > const &last=std::nullopt) const =0
Return the key of the next state item.
bool enabled(UInt256 const &feature) const
Returns true if a feature is enabled.
constexpr TIss const & get() const
std::uint64_t mantissa() const noexcept
int signum() const noexcept
bool negative() const noexcept
bool native() const noexcept
Asset const & asset() const
AccountID const & getIssuer() const
LedgerEntryType getType() const
std::shared_ptr< STLedgerEntry const > const & ConstRef
std::shared_ptr< STLedgerEntry const > const_pointer
bool isFieldPresent(SField const &field) const
AccountID getAccountID(SField const &field) const
STAmount const & getFieldAmount(SField const &field) const
TxType getTxnType() const
UInt256 getTransactionID() const
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
static bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &) const
std::vector< SLE::const_pointer > afterEntries_
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
std::uint32_t mptokensChanged_
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &) const
std::uint32_t trustlinesChanged_
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
std::uint32_t accountsCreated_
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &) const
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
std::uint32_t accountSeq_
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
std::vector< std::string > errors_
std::map< AccountID, std::vector< uint256 > > ownerDirAdditions_
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
constexpr value_type drops() const
Returns the number of drops.
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &) const
boost::multiprecision::int128_t drops_
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &) const
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
Keylet computation functions.
Keylet amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
Keylet nftokenPageMin(AccountID const &owner)
NFT page keylets.
Keylet unchecked(UInt256 const &key) noexcept
Any ledger entry.
Keylet vault(AccountID const &owner, SeqProxy const &seq) noexcept
Keylet nftokenPageMax(AccountID const &owner)
A keylet for the owner's last possible NFT page.
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Keylet loanBroker(AccountID const &owner, SeqProxy const &seq) noexcept
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet mptokenIssuance(MPTID const &issuanceID) noexcept
Keylet trustLine(AccountID const &id0, AccountID const &id1, Currency const ¤cy) noexcept
The index of a trust line for a given currency.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Issue const & xrpIssue()
Returns an asset specifier that represents XRP.
std::vector< SField const * > const & getPseudoAccountFields()
Returns the list of fields that define an ACCOUNT_ROOT as a pseudo-account if set.
bool isXRP(AccountID const &c)
static bool isOwnedByPseudoAccount(ReadView const &view, SLE const &pseudo, SLE const &entry)
bool isFeatureEnabled(UInt256 const &feature, bool resultIfNoRules)
Check whether a feature is enabled in the current ledger rules.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
BaseUInt< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Number root(Number f, unsigned d)
Privilege
Operations a transaction is permitted to perform, as a bitfield.
static bool isHolding(SLE const &entry, Asset const &asset, AccountID const &account)
std::string to_string(BaseUInt< Bits, Tag > const &a)
bool hasPrivilege(STTx const &tx, Privilege priv)
static std::optional< STAmount > clawbackTrustLineBalanceInHolderTerms(SLE::const_pointer const &sle, AccountID const &holder, AccountID const &issuer, Currency const ¤cy)
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
static std::string ledgerEntryTypeName(SLE const &sle)
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.
bool isTesSuccess(TER x) noexcept
TERSubset< CanCvtToTER > TER
Currency const & badCurrency()
We deliberately disallow the currency that looks like "XRP" because too many people were using it ins...
constexpr std::uint64_t kMaxMpTokenAmount
The maximum amount of MPTokenIssuance.
constexpr XRPAmount kInitialXrp
Configure the native currency.
std::array< KeyletDesc< AccountID const & >, 6 > const kDirectAccountKeylets
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j, SpendableHandling includeFullBalance=SpendableHandling::SimpleBalance)
A pair of SHAMap key and LedgerEntryType.
bool check(STLedgerEntry const &) const
Returns true if the SLE matches the type.