20#include <xrpld/ledger/ReadView.h>
21#include <xrpld/ledger/View.h>
22#include <xrpl/basics/Log.h>
23#include <xrpl/basics/chrono.h>
24#include <xrpl/basics/contract.h>
25#include <xrpl/beast/utility/instrumentation.h>
26#include <xrpl/protocol/Feature.h>
27#include <xrpl/protocol/Protocol.h>
28#include <xrpl/protocol/Quality.h>
29#include <xrpl/protocol/st.h>
40 std::is_same_v<std::remove_cv_t<N>,
SLE> &&
41 std::is_base_of_v<ReadView, V>>>
50 auto const& svIndexes = page->getFieldV256(sfIndexes);
52 index <= svIndexes.size(),
53 "ripple::detail::internalDirNext : index inside range");
55 if (index >= svIndexes.size())
57 auto const next = page->getFieldU64(sfIndexNext);
65 if constexpr (std::is_const_v<N>)
70 XRPL_ASSERT(page,
"ripple::detail::internalDirNext : non-null root");
80 entry = svIndexes[index++];
88 std::is_same_v<std::remove_cv_t<N>,
SLE> &&
89 std::is_base_of_v<ReadView, V>>>
98 if constexpr (std::is_const_v<N>)
195 if constexpr (std::is_same_v<TIss, Issue>)
212 if (issuer != account)
249 if (issuer != account)
282 if (issuer == account)
313 auto const allowBalance = [&]() {
321 if (
isFrozen(view, account, currency, issuer) ||
333 amount = sle->getFieldAmount(sfBalance);
334 if (account > issuer)
346 JLOG(j.
trace()) <<
"accountHolds:" <<
" account=" <<
to_string(account)
378 amount.
clear(mptIssue);
381 amount.
clear(mptIssue);
384 amount =
STAmount{mptIssue, sleMpt->getFieldU64(sfMPTAmount)};
390 auto const sleIssuance =
397 amount.
clear(mptIssue);
446 <<
"Account " << *
id <<
" owner count exceeds max!";
459 <<
"Account " << *
id <<
" owner count set below 0!";
462 XRPL_ASSERT(!
id,
"ripple::confineOwnerCount : id is not set");
481 view.
ownerCountHook(
id, sle->getFieldU32(sfOwnerCount)), ownerCountAdj);
484 auto const reserve = sle->isFieldPresent(sfAMMID)
488 auto const fullBalance = sle->getFieldAmount(sfBalance);
493 (balance < reserve) ?
STAmount{0} : balance - reserve;
495 JLOG(j.
trace()) <<
"accountHolds:" <<
" account=" <<
to_string(
id)
497 <<
" fullBalance=" << fullBalance.getFullText()
498 <<
" balance=" << balance.getFullText()
499 <<
" reserve=" << reserve <<
" ownerCount=" << ownerCount
500 <<
" ownerCountAdj=" << ownerCountAdj;
512 root.type == ltDIR_NODE,
"ripple::forEachItem : valid root type");
514 if (
root.type != ltDIR_NODE)
521 auto sle = view.
read(pos);
524 for (
auto const& key : sle->getFieldV256(sfIndexes))
526 auto const next = sle->getFieldU64(sfIndexNext);
543 root.type == ltDIR_NODE,
"ripple::forEachItemAfter : valid root type");
545 if (
root.type != ltDIR_NODE)
548 auto currentIndex =
root;
551 if (
after.isNonZero())
555 if (
auto hintDir = view.
read(hintIndex))
557 for (
auto const& key : hintDir->getFieldV256(sfIndexes))
562 currentIndex = hintIndex;
571 auto const ownerDir = view.
read(currentIndex);
574 for (
auto const& key : ownerDir->getFieldV256(sfIndexes))
587 auto const uNodeNext = ownerDir->getFieldU64(sfIndexNext);
597 auto const ownerDir = view.
read(currentIndex);
600 for (
auto const& key : ownerDir->getFieldV256(sfIndexes))
603 auto const uNodeNext = ownerDir->getFieldU64(sfIndexNext);
616 if (sle && sle->isFieldPresent(sfTransferRate))
617 return Rate{sle->getFieldU32(sfTransferRate)};
629 sle && sle->isFieldPresent(sfTransferFee))
630 return Rate{1'000'000'000u + 10'000 * sle->getFieldU16(sfTransferFee)};
651 if (hash && (*hash != validLedger.
info().
hash))
653 JLOG(s) << reason <<
" incompatible with valid ledger";
655 JLOG(s) <<
"Hash(VSeq): " <<
to_string(*hash);
667 if (hash && (*hash != testLedger.
info().
hash))
669 JLOG(s) << reason <<
" incompatible preceding ledger";
671 JLOG(s) <<
"Hash(NSeq): " <<
to_string(*hash);
681 JLOG(s) << reason <<
" incompatible ledger";
688 JLOG(s) <<
"Val: " << validLedger.
info().
seq <<
" "
691 JLOG(s) <<
"New: " << testLedger.
info().
seq <<
" "
708 if (testLedger.
info().
seq > validIndex)
715 if (hash && (*hash != validHash))
717 JLOG(s) << reason <<
" incompatible following ledger";
718 JLOG(s) <<
"Hash(VSeq): " <<
to_string(*hash);
724 (validIndex == testLedger.
info().
seq) &&
725 (testLedger.
info().
hash != validHash))
727 JLOG(s) << reason <<
" incompatible ledger";
734 JLOG(s) <<
"Val: " << validIndex <<
" " <<
to_string(validHash);
736 JLOG(s) <<
"New: " << testLedger.
info().
seq <<
" "
746 auto const sleNode = view.
read(k);
749 if (!sleNode->getFieldV256(sfIndexes).empty())
754 return sleNode->getFieldU64(sfIndexNext) == 0;
764 if (sle->isFieldPresent(sfAmendments))
766 auto const& v = sle->getFieldV256(sfAmendments);
767 amendments.insert(v.begin(), v.end());
781 if (sle->isFieldPresent(sfMajorities))
784 using d = tp::duration;
786 auto const majorities = sle->getFieldArray(sfMajorities);
788 for (
auto const& m : majorities)
789 ret[m.getFieldH256(sfAmendment)] =
790 tp(d(m.getFieldU32(sfCloseTime)));
801 if (seq > ledger.
seq())
804 <<
"Can't get seq " << seq <<
" from " << ledger.
seq() <<
" future";
807 if (seq == ledger.
seq())
809 if (seq == (ledger.
seq() - 1))
812 if (
int diff = ledger.
seq() - seq; diff <= 256)
819 hashIndex->getFieldU32(sfLastLedgerSequence) ==
821 "ripple::hashOfSeq : matching ledger sequence");
822 STVector256 vec = hashIndex->getFieldV256(sfHashes);
823 if (vec.
size() >= diff)
824 return vec[vec.
size() - diff];
826 <<
"Ledger " << ledger.
seq() <<
" missing hash for " << seq
827 <<
" (" << vec.
size() <<
"," << diff <<
")";
832 <<
"Ledger " << ledger.
seq() <<
":" << ledger.
info().
hash
833 <<
" missing normal list";
837 if ((seq & 0xff) != 0)
839 JLOG(journal.
debug())
840 <<
"Can't get seq " << seq <<
" from " << ledger.
seq() <<
" past";
848 auto const lastSeq = hashIndex->getFieldU32(sfLastLedgerSequence);
849 XRPL_ASSERT(lastSeq >= seq,
"ripple::hashOfSeq : minimum last ledger");
851 (lastSeq & 0xff) == 0,
"ripple::hashOfSeq : valid last ledger");
852 auto const diff = (lastSeq - seq) >> 8;
853 STVector256 vec = hashIndex->getFieldV256(sfHashes);
854 if (vec.
size() > diff)
855 return vec[vec.
size() - diff - 1];
857 JLOG(journal.
warn()) <<
"Can't get seq " << seq <<
" from " << ledger.
seq()
877 XRPL_ASSERT(amount,
"ripple::adjustOwnerCount : nonzero amount input");
882 sle->setFieldU32(sfOwnerCount, adjusted);
890 (*sle)[sfOwner] = account;
903 const bool bNoRipple,
914 JLOG(j.
trace()) <<
"trustCreate: " <<
to_string(uSrcAccountID) <<
", "
918 auto const& uLowAccountID = !bSrcHigh ? uSrcAccountID : uDstAccountID;
919 auto const& uHighAccountID = bSrcHigh ? uSrcAccountID : uDstAccountID;
921 auto const sleRippleState = std::make_shared<SLE>(ltRIPPLE_STATE, uIndex);
922 view.
insert(sleRippleState);
926 sleRippleState->
key(),
934 sleRippleState->
key(),
940 const bool bSetDst = saLimit.
getIssuer() == uDstAccountID;
941 const bool bSetHigh = bSrcHigh ^ bSetDst;
943 XRPL_ASSERT(sleAccount,
"ripple::trustCreate : non-null SLE");
949 (bSetHigh ? uHighAccountID : uLowAccountID),
950 "ripple::trustCreate : matching account ID");
957 sleRippleState->setFieldU64(sfLowNode, *lowNode);
958 sleRippleState->setFieldU64(sfHighNode, *highNode);
960 sleRippleState->setFieldAmount(
961 bSetHigh ? sfHighLimit : sfLowLimit, saLimit);
962 sleRippleState->setFieldAmount(
963 bSetHigh ? sfLowLimit : sfHighLimit,
965 saBalance.
getCurrency(), bSetDst ? uSrcAccountID : uDstAccountID}));
968 sleRippleState->setFieldU32(
969 bSetHigh ? sfHighQualityIn : sfLowQualityIn, uQualityIn);
972 sleRippleState->setFieldU32(
973 bSetHigh ? sfHighQualityOut : sfLowQualityOut, uQualityOut);
1000 sleRippleState->setFieldU32(sfFlags, uFlags);
1004 sleRippleState->setFieldAmount(
1005 sfBalance, bSetHigh ? -saBalance : saBalance);
1008 uSrcAccountID, uDstAccountID, saBalance, saBalance.
zeroed());
1022 std::uint64_t uLowNode = sleRippleState->getFieldU64(sfLowNode);
1023 std::uint64_t uHighNode = sleRippleState->getFieldU64(sfHighNode);
1025 JLOG(j.
trace()) <<
"trustDelete: Deleting ripple line: low";
1030 sleRippleState->key(),
1036 JLOG(j.
trace()) <<
"trustDelete: Deleting ripple line: high";
1041 sleRippleState->key(),
1047 JLOG(j.
trace()) <<
"trustDelete: Deleting ripple line: state";
1048 view.
erase(sleRippleState);
1058 auto offerIndex = sle->key();
1059 auto owner = sle->getAccountID(sfAccount);
1062 uint256 uDirectory = sle->getFieldH256(sfBookDirectory);
1066 sle->getFieldU64(sfOwnerNode),
1075 sle->getFieldU64(sfBookNode),
1107 !bCheckIssuer || uSenderID == issuer || uReceiverID == issuer,
1108 "ripple::rippleCreditIOU : matching issuer or don't care");
1113 uSenderID != uReceiverID,
1114 "ripple::rippleCreditIOU : sender is not receiver");
1116 bool const bSenderHigh = uSenderID > uReceiverID;
1117 auto const index =
keylet::line(uSenderID, uReceiverID, currency);
1121 "ripple::rippleCreditIOU : sender is not XRP");
1124 "ripple::rippleCreditIOU : receiver is not XRP");
1127 if (
auto const sleRippleState = view.
peek(index))
1129 STAmount saBalance = sleRippleState->getFieldAmount(sfBalance);
1134 view.
creditHook(uSenderID, uReceiverID, saAmount, saBalance);
1136 STAmount const saBefore = saBalance;
1138 saBalance -= saAmount;
1140 JLOG(j.
trace()) <<
"rippleCreditIOU: " <<
to_string(uSenderID) <<
" -> "
1146 std::uint32_t const uFlags(sleRippleState->getFieldU32(sfFlags));
1147 bool bDelete =
false;
1151 if (saBefore > beast::zero
1153 && saBalance <= beast::zero
1164 !sleRippleState->getFieldAmount(
1165 !bSenderHigh ? sfLowLimit : sfHighLimit)
1167 && !sleRippleState->getFieldU32(
1168 !bSenderHigh ? sfLowQualityIn : sfHighQualityIn)
1170 && !sleRippleState->getFieldU32(
1171 !bSenderHigh ? sfLowQualityOut : sfHighQualityOut))
1179 sleRippleState->setFieldU32(
1184 bDelete = !saBalance
1193 sleRippleState->setFieldAmount(sfBalance, saBalance);
1201 bSenderHigh ? uReceiverID : uSenderID,
1202 !bSenderHigh ? uReceiverID : uSenderID,
1206 view.
update(sleRippleState);
1210 STAmount const saReceiverLimit(
Issue{currency, uReceiverID});
1215 JLOG(j.
debug()) <<
"rippleCreditIOU: "
1257 auto const issuer = saAmount.
getIssuer();
1261 "ripple::rippleSendIOU : neither sender nor receiver is XRP");
1263 uSenderID != uReceiverID,
1264 "ripple::rippleSendIOU : sender is not receiver");
1266 if (uSenderID == issuer || uReceiverID == issuer || issuer ==
noAccount())
1273 saActual = saAmount;
1285 JLOG(j.
debug()) <<
"rippleSendIOU> " <<
to_string(uSenderID) <<
" - > "
1294 terResult =
rippleCreditIOU(view, uSenderID, issuer, saActual,
true, j);
1319 "ripple::accountSendIOU : minimum amount and not MPT");
1325 if (!saAmount || (uSenderID == uReceiverID))
1332 JLOG(j.
trace()) <<
"accountSendIOU: " <<
to_string(uSenderID) <<
" -> "
1337 view, uSenderID, uReceiverID, saAmount, saActual, j, waiveFee);
1354 if (
auto stream = j.
trace())
1365 stream <<
"accountSendIOU> " <<
to_string(uSenderID) <<
" ("
1366 << sender_bal <<
") -> " <<
to_string(uReceiverID) <<
" ("
1367 << receiver_bal <<
") : " << saAmount.
getFullText();
1400 if (
auto stream = j.
trace())
1411 stream <<
"accountSendIOU< " <<
to_string(uSenderID) <<
" ("
1412 << sender_bal <<
") -> " <<
to_string(uReceiverID) <<
" ("
1413 << receiver_bal <<
") : " << saAmount.
getFullText();
1428 auto const issuer = saAmount.
getIssuer();
1429 auto sleIssuance = view.
peek(mptID);
1432 if (uSenderID == issuer)
1434 (*sleIssuance)[sfOutstandingAmount] += saAmount.
mpt().
value();
1435 view.
update(sleIssuance);
1440 if (
auto sle = view.
peek(mptokenID))
1442 auto const amt = sle->getFieldU64(sfMPTAmount);
1443 auto const pay = saAmount.
mpt().
value();
1446 (*sle)[sfMPTAmount] = amt - pay;
1453 if (uReceiverID == issuer)
1455 auto const outstanding = sleIssuance->getFieldU64(sfOutstandingAmount);
1456 auto const redeem = saAmount.
mpt().
value();
1457 if (outstanding >= redeem)
1459 sleIssuance->setFieldU64(sfOutstandingAmount, outstanding - redeem);
1460 view.
update(sleIssuance);
1468 if (
auto sle = view.
peek(mptokenID))
1470 (*sle)[sfMPTAmount] += saAmount.
mpt().
value();
1490 uSenderID != uReceiverID,
1491 "ripple::rippleSendMPT : sender is not receiver");
1494 auto const issuer = saAmount.
getIssuer();
1501 if (uSenderID == issuer || uReceiverID == issuer)
1505 if (uSenderID == issuer)
1507 auto const sendAmount = saAmount.
mpt().
value();
1508 auto const maximumAmount =
1510 if (sendAmount > maximumAmount ||
1511 sle->getFieldU64(sfOutstandingAmount) >
1512 maximumAmount - sendAmount)
1521 saActual = saAmount;
1532 JLOG(j.
debug()) <<
"rippleSendMPT> " <<
to_string(uSenderID) <<
" - > "
1537 if (
auto const terResult =
1556 "ripple::accountSendMPT : minimum amount and MPT");
1561 if (!saAmount || (uSenderID == uReceiverID))
1567 view, uSenderID, uReceiverID, saAmount, saActual, j, waiveFee);
1581 if constexpr (std::is_same_v<TIss, Issue>)
1583 view, uSenderID, uReceiverID, saAmount, j, waiveFee);
1586 view, uSenderID, uReceiverID, saAmount, j, waiveFee);
1610 if (before > beast::zero
1612 &&
after <= beast::zero
1616 &&
static_cast<bool>(
1622 && !state->
getFieldU32(!bSenderHigh ? sfLowQualityIn : sfHighQualityIn)
1625 !state->
getFieldU32(!bSenderHigh ? sfLowQualityOut : sfHighQualityOut))
1654 "ripple::issueIOU : neither account nor issuer is XRP");
1657 XRPL_ASSERT(issue == amount.
issue(),
"ripple::issueIOU : matching issue");
1661 issue.
account != account,
"ripple::issueIOU : not issuer account");
1666 bool bSenderHigh = issue.
account > account;
1670 if (
auto state = view.
peek(index))
1672 STAmount final_balance = state->getFieldAmount(sfBalance);
1677 STAmount const start_balance = final_balance;
1679 final_balance -= amount;
1698 state->setFieldAmount(sfBalance, final_balance);
1703 bSenderHigh ? account : issue.
account,
1704 bSenderHigh ? issue.
account : account,
1721 if (!receiverAccount)
1754 "ripple::redeemIOU : neither account nor issuer is XRP");
1757 XRPL_ASSERT(issue == amount.
issue(),
"ripple::redeemIOU : matching issue");
1761 issue.
account != account,
"ripple::redeemIOU : not issuer account");
1766 bool bSenderHigh = account > issue.
account;
1771 STAmount final_balance = state->getFieldAmount(sfBalance);
1776 STAmount const start_balance = final_balance;
1778 final_balance -= amount;
1781 view, state, bSenderHigh, account, start_balance, final_balance, j);
1791 state->setFieldAmount(sfBalance, final_balance);
1798 bSenderHigh ? issue.
account : account,
1799 bSenderHigh ? account : issue.
account,
1812 <<
" but no trust line exists!";
1826 from != beast::zero,
"ripple::transferXRP : nonzero from account");
1827 XRPL_ASSERT(to != beast::zero,
"ripple::transferXRP : nonzero to account");
1828 XRPL_ASSERT(from != to,
"ripple::transferXRP : sender is not receiver");
1829 XRPL_ASSERT(amount.
native(),
"ripple::transferXRP : amount is XRP");
1833 if (!sender || !receiver)
1868 if (
auto const trustLine =
1870 return ((*trustLine)[sfFlags] &
1887 auto const sleIssuance = view.
read(mptID);
1892 auto const mptIssuer = sleIssuance->getAccountID(sfIssuer);
1895 if (mptIssuer == account)
1899 auto const sleToken = view.
read(mptokenID);
1921 auto const sleIssuance = view.
read(mptID);
1927 if (from != (*sleIssuance)[sfIssuer] && to != (*sleIssuance)[sfIssuer])
1936 Keylet const& ownerDirKeylet,
1943 unsigned int uDirEntry{0};
1944 uint256 dirEntry{beast::zero};
1947 if (view.
exists(ownerDirKeylet) &&
1948 dirFirst(view, ownerDirKeylet.
key, sleDirNode, uDirEntry, dirEntry))
1952 if (maxNodesToDelete && ++deleted > *maxNodesToDelete)
1961 <<
"DeleteAccount: Directory node in ledger " << view.
seq()
1962 <<
" has index to object that is missing: "
1968 sleItem->getFieldU16(sfLedgerEntryType))};
1972 auto const [ter, skipEntry] = deleter(nodeType, dirEntry, sleItem);
1994 "ripple::cleanupOnAccountDelete : minimum dir entries");
1998 <<
"DeleteAccount iterator re-validation failed.";
2005 dirNext(view, ownerDirKeylet.
key, sleDirNode, uDirEntry, dirEntry));
2018 if (!sleState || sleState->getType() != ltRIPPLE_STATE)
2022 sleState->getFieldAmount(sfLowLimit).getIssuer(),
2023 sleState->getFieldAmount(sfHighLimit).getIssuer());
2026 if (!sleLow || !sleHigh)
2028 bool const ammLow = sleLow->isFieldPresent(sfAMMID);
2029 bool const ammHigh = sleHigh->isFieldPresent(sfAMMID);
2032 if (ammLow && ammHigh)
2036 if (!ammLow && !ammHigh)
2043 if (
auto const ter =
trustDelete(view, sleState, low, high, j);
2047 <<
"deleteAMMTrustLine: failed to delete the trustline.";
2052 if (!(sleState->getFlags() & uFlags))
2071 if constexpr (std::is_same_v<TIss, Issue>)
2074 view, uSenderID, uReceiverID, saAmount, bCheckIssuer, j);
2080 "ripple::rippleCredit : not checking issuer");
2082 view, uSenderID, uReceiverID, saAmount, j);
Provide a light-weight way to check active() before string formatting.
A generic endpoint for log messages.
static Sink & getNullSink()
Returns a Sink which does nothing.
Stream trace() const
Severity stream access functions.
Writeable view to a ledger, for applying a transaction.
virtual void creditHook(AccountID const &from, AccountID const &to, STAmount const &amount, STAmount const &preCreditBalance)
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
virtual void adjustOwnerCountHook(AccountID const &account, std::uint32_t cur, std::uint32_t next)
virtual void insert(std::shared_ptr< SLE > const &sle)=0
Insert a new state SLE.
std::optional< std::uint64_t > dirInsert(Keylet const &directory, uint256 const &key, std::function< void(std::shared_ptr< SLE > const &)> const &describe)
Insert an entry to a directory.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
constexpr value_type const & value() const
A currency issued by an account.
constexpr value_type value() const
Returns the underlying value.
MPTID const & getMptID() const
std::chrono::time_point< NetClock > time_point
std::chrono::duration< rep, period > duration
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
NetClock::time_point parentCloseTime() const
Returns the close time of the previous ledger.
virtual std::uint32_t ownerCountHook(AccountID const &account, std::uint32_t count) const
virtual STAmount balanceHook(AccountID const &account, AccountID const &issuer, STAmount const &amount) const
virtual bool open() const =0
Returns true if this reflects an open ledger.
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
LedgerIndex seq() const
Returns the sequence number of the base ledger.
virtual LedgerInfo const & info() const =0
Returns information about the ledger.
virtual Rules const & rules() const =0
Returns the tx processing rules.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
constexpr bool holds() const noexcept
Asset const & asset() const
constexpr TIss const & get() const
void setIssuer(AccountID const &uIssuer)
Currency const & getCurrency() const
AccountID const & getIssuer() const
Issue const & issue() const
std::string getFullText() const override
bool native() const noexcept
STAmount zeroed() const
Returns a zero value with the same issuer and currency.
const std::shared_ptr< STLedgerEntry > & ref
std::shared_ptr< STLedgerEntry > pointer
AccountID getAccountID(SField const &field) const
std::uint32_t getFieldU32(SField const &field) const
void setFieldAmount(SField const &field, STAmount const &)
STAmount const & getFieldAmount(SField const &field) const
void setFieldU32(SField const &field, std::uint32_t)
bool internalDirFirst(V &view, uint256 const &root, std::shared_ptr< N > &page, unsigned int &index, uint256 &entry)
bool internalDirNext(V &view, uint256 const &root, std::shared_ptr< N > &page, unsigned int &index, uint256 &entry)
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
Keylet line(AccountID const &id0, AccountID const &id1, Currency const ¤cy) noexcept
The index of a trust line for a given currency.
Keylet const & amendments() noexcept
The index of the amendment table.
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet page(uint256 const &root, std::uint64_t index=0) noexcept
A page in a directory.
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet const & skip() noexcept
The index of the "short" skip list.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
AccountID const & noAccount()
A placeholder for empty accounts.
static bool updateTrustLine(ApplyView &view, SLE::pointer state, bool bSenderHigh, AccountID const &sender, STAmount const &before, STAmount const &after, beast::Journal j)
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
FreezeHandling
Controls the treatment of frozen account balances.
bool cdirFirst(ReadView const &view, uint256 const &root, std::shared_ptr< SLE const > &page, unsigned int &index, uint256 &entry)
Returns the first entry in the directory, advancing the index.
bool isXRP(AccountID const &c)
AccountID const & xrpAccount()
Compute AccountID from public key.
bool isIndividualFrozen(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer)
TER deleteAMMTrustLine(ApplyView &view, std::shared_ptr< SLE > sleState, std::optional< AccountID > const &ammAccountID, beast::Journal j)
Delete trustline to AMM.
static TER rippleSendMPT(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, STAmount &saActual, beast::Journal j, WaiveTransferFee waiveFee)
bool dirFirst(ApplyView &view, uint256 const &root, std::shared_ptr< SLE > &page, unsigned int &index, uint256 &entry)
bool dirNext(ApplyView &view, uint256 const &root, std::shared_ptr< SLE > &page, unsigned int &index, uint256 &entry)
TER requireAuth(ReadView const &view, Issue const &issue, AccountID const &account)
Check if the account lacks required authorization.
bool isDeepFrozen(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer)
std::optional< uint256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
std::uint64_t constexpr maxMPTokenAmount
The maximum amount of MPTokenIssuance.
TER redeemIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
STAmount multiply(STAmount const &amount, Rate const &rate)
AuthHandling
Controls the treatment of unauthorized MPT balances.
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
TER transferXRP(ApplyView &view, AccountID const &from, AccountID const &to, STAmount const &amount, beast::Journal j)
@ current
This was a new validation and was added.
TER offerDelete(ApplyView &view, std::shared_ptr< SLE > const &sle, beast::Journal j)
Delete an offer.
bool isFrozen(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer)
std::set< uint256 > getEnabledAmendments(ReadView const &view)
TER canTransfer(ReadView const &view, MPTIssue const &mptIssue, AccountID const &from, AccountID const &to)
Check if the destination account is allowed to receive MPT.
AccountID ammAccountID(std::uint16_t prefix, uint256 const &parentHash, uint256 const &ammID)
Calculate AMM account ID.
static std::uint32_t confineOwnerCount(std::uint32_t current, std::int32_t adjustment, std::optional< AccountID > const &id=std::nullopt, beast::Journal j=beast::Journal{beast::Journal::getNullSink()})
static TER rippleCreditIOU(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, bool bCheckIssuer, beast::Journal j)
static bool adjustOwnerCount(ApplyContext &ctx, int count)
TER issueIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
static TER accountSendIOU(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, beast::Journal j, WaiveTransferFee waiveFee)
std::map< uint256, NetClock::time_point > majorityAmendments_t
TER trustCreate(ApplyView &view, const bool bSrcHigh, AccountID const &uSrcAccountID, AccountID const &uDstAccountID, uint256 const &uIndex, SLE::ref sleAccount, const bool bAuth, const bool bNoRipple, const bool bFreeze, bool bDeepFreeze, STAmount const &saBalance, STAmount const &saLimit, std::uint32_t uQualityIn, std::uint32_t uQualityOut, beast::Journal j)
Create a trust line.
bool cdirNext(ReadView const &view, uint256 const &root, std::shared_ptr< SLE const > &page, unsigned int &index, uint256 &entry)
Returns the next entry in the directory, advancing the index.
TER trustDelete(ApplyView &view, std::shared_ptr< SLE > const &sleRippleState, AccountID const &uLowAccountID, AccountID const &uHighAccountID, beast::Journal j)
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j)
majorityAmendments_t getMajorityAmendments(ReadView const &view)
std::string to_string(base_uint< Bits, Tag > const &a)
LedgerEntryType
Identifiers for on-ledger objects.
bool forEachItemAfter(ReadView const &view, Keylet const &root, uint256 const &after, std::uint64_t const hint, unsigned int limit, std::function< bool(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items after an item in the given directory.
TER cleanupOnAccountDelete(ApplyView &view, Keylet const &ownerDirKeylet, EntryDeleter const &deleter, beast::Journal j, std::optional< uint16_t > maxNodesToDelete)
void forEachItem(ReadView const &view, Keylet const &root, std::function< void(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items in the given directory.
Number root(Number f, unsigned d)
bool hasExpired(ReadView const &view, std::optional< std::uint32_t > const &exp)
Determines whether the given expiration time has passed.
static TER rippleSendIOU(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, STAmount &saActual, beast::Journal j, WaiveTransferFee waiveFee)
TER rippleCredit(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, bool bCheckIssuer, beast::Journal j)
Calls static rippleCreditIOU if saAmount represents Issue.
TERSubset< CanCvtToTER > TER
bool areCompatible(ReadView const &validLedger, ReadView const &testLedger, beast::Journal::Stream &s, const char *reason)
Return false if the test ledger is provably incompatible with the valid ledger, that is,...
static bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
static TER rippleCreditMPT(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, beast::Journal j)
bool dirIsEmpty(ReadView const &view, Keylet const &k)
Returns true if the directory is empty.
TER accountSend(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, beast::Journal j, WaiveTransferFee waiveFee)
Calls static accountSendIOU if saAmount represents Issue.
static TER accountSendMPT(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, beast::Journal j, WaiveTransferFee waiveFee)
Rate const parityRate
A transfer rate signifying a 1:1 exchange.
XRPAmount xrpLiquid(ReadView const &view, AccountID const &id, std::int32_t ownerCountAdj, beast::Journal j)
bool isGlobalFrozen(ReadView const &view, AccountID const &issuer)
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
A pair of SHAMap key and LedgerEntryType.
Represents a transfer rate.