20#include <xrpld/ledger/ReadView.h>
21#include <xrpld/ledger/View.h>
23#include <xrpl/basics/Log.h>
24#include <xrpl/basics/chrono.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>
41 std::is_same_v<std::remove_cv_t<N>,
SLE> &&
42 std::is_base_of_v<ReadView, V>>>
51 auto const& svIndexes = page->getFieldV256(sfIndexes);
53 index <= svIndexes.size(),
54 "ripple::detail::internalDirNext : index inside range");
56 if (index >= svIndexes.size())
58 auto const next = page->getFieldU64(sfIndexNext);
66 if constexpr (std::is_const_v<N>)
71 XRPL_ASSERT(page,
"ripple::detail::internalDirNext : non-null root");
81 entry = svIndexes[index++];
89 std::is_same_v<std::remove_cv_t<N>,
SLE> &&
90 std::is_base_of_v<ReadView, V>>>
99 if constexpr (std::is_const_v<N>)
196 if constexpr (std::is_same_v<TIss, Issue>)
213 if (issuer != account)
250 if (issuer != account)
283 if (issuer == account)
325 auto const allowBalance = [&]() {
333 if (
isFrozen(view, account, currency, issuer) ||
348 else if (sleIssuer->isFieldPresent(sfAMMID))
357 (*sleAmm)[sfAsset].get<Issue>(),
358 (*sleAmm)[sfAsset2].get<Issue>()))
371 amount = sle->getFieldAmount(sfBalance);
372 if (account > issuer)
384 JLOG(j.
trace()) <<
"accountHolds:"
417 amount.
clear(mptIssue);
420 amount.
clear(mptIssue);
423 amount =
STAmount{mptIssue, sleMpt->getFieldU64(sfMPTAmount)};
429 auto const sleIssuance =
436 amount.
clear(mptIssue);
485 <<
"Account " << *
id <<
" owner count exceeds max!";
498 <<
"Account " << *
id <<
" owner count set below 0!";
501 XRPL_ASSERT(!
id,
"ripple::confineOwnerCount : id is not set");
520 view.
ownerCountHook(
id, sle->getFieldU32(sfOwnerCount)), ownerCountAdj);
523 auto const reserve = sle->isFieldPresent(sfAMMID)
527 auto const fullBalance = sle->getFieldAmount(sfBalance);
532 (balance < reserve) ?
STAmount{0} : balance - reserve;
534 JLOG(j.
trace()) <<
"accountHolds:"
537 <<
" fullBalance=" << fullBalance.getFullText()
538 <<
" balance=" << balance.getFullText()
539 <<
" reserve=" << reserve <<
" ownerCount=" << ownerCount
540 <<
" ownerCountAdj=" << ownerCountAdj;
552 root.type == ltDIR_NODE,
"ripple::forEachItem : valid root type");
554 if (
root.type != ltDIR_NODE)
561 auto sle = view.
read(pos);
564 for (
auto const& key : sle->getFieldV256(sfIndexes))
566 auto const next = sle->getFieldU64(sfIndexNext);
583 root.type == ltDIR_NODE,
"ripple::forEachItemAfter : valid root type");
585 if (
root.type != ltDIR_NODE)
588 auto currentIndex =
root;
591 if (
after.isNonZero())
595 if (
auto hintDir = view.
read(hintIndex))
597 for (
auto const& key : hintDir->getFieldV256(sfIndexes))
602 currentIndex = hintIndex;
611 auto const ownerDir = view.
read(currentIndex);
614 for (
auto const& key : ownerDir->getFieldV256(sfIndexes))
627 auto const uNodeNext = ownerDir->getFieldU64(sfIndexNext);
637 auto const ownerDir = view.
read(currentIndex);
640 for (
auto const& key : ownerDir->getFieldV256(sfIndexes))
643 auto const uNodeNext = ownerDir->getFieldU64(sfIndexNext);
656 if (sle && sle->isFieldPresent(sfTransferRate))
657 return Rate{sle->getFieldU32(sfTransferRate)};
669 sle && sle->isFieldPresent(sfTransferFee))
670 return Rate{1'000'000'000u + 10'000 * sle->getFieldU16(sfTransferFee)};
691 if (hash && (*hash != validLedger.
info().
hash))
693 JLOG(s) << reason <<
" incompatible with valid ledger";
695 JLOG(s) <<
"Hash(VSeq): " <<
to_string(*hash);
707 if (hash && (*hash != testLedger.
info().
hash))
709 JLOG(s) << reason <<
" incompatible preceding ledger";
711 JLOG(s) <<
"Hash(NSeq): " <<
to_string(*hash);
721 JLOG(s) << reason <<
" incompatible ledger";
728 JLOG(s) <<
"Val: " << validLedger.
info().
seq <<
" "
731 JLOG(s) <<
"New: " << testLedger.
info().
seq <<
" "
748 if (testLedger.
info().
seq > validIndex)
755 if (hash && (*hash != validHash))
757 JLOG(s) << reason <<
" incompatible following ledger";
758 JLOG(s) <<
"Hash(VSeq): " <<
to_string(*hash);
764 (validIndex == testLedger.
info().
seq) &&
765 (testLedger.
info().
hash != validHash))
767 JLOG(s) << reason <<
" incompatible ledger";
774 JLOG(s) <<
"Val: " << validIndex <<
" " <<
to_string(validHash);
776 JLOG(s) <<
"New: " << testLedger.
info().
seq <<
" "
786 auto const sleNode = view.
read(k);
789 if (!sleNode->getFieldV256(sfIndexes).empty())
794 return sleNode->getFieldU64(sfIndexNext) == 0;
804 if (sle->isFieldPresent(sfAmendments))
806 auto const& v = sle->getFieldV256(sfAmendments);
807 amendments.insert(v.begin(), v.end());
821 if (sle->isFieldPresent(sfMajorities))
824 using d = tp::duration;
826 auto const majorities = sle->getFieldArray(sfMajorities);
828 for (
auto const& m : majorities)
829 ret[m.getFieldH256(sfAmendment)] =
830 tp(d(m.getFieldU32(sfCloseTime)));
841 if (seq > ledger.
seq())
844 <<
"Can't get seq " << seq <<
" from " << ledger.
seq() <<
" future";
847 if (seq == ledger.
seq())
849 if (seq == (ledger.
seq() - 1))
852 if (
int diff = ledger.
seq() - seq; diff <= 256)
859 hashIndex->getFieldU32(sfLastLedgerSequence) ==
861 "ripple::hashOfSeq : matching ledger sequence");
862 STVector256 vec = hashIndex->getFieldV256(sfHashes);
863 if (vec.
size() >= diff)
864 return vec[vec.
size() - diff];
866 <<
"Ledger " << ledger.
seq() <<
" missing hash for " << seq
867 <<
" (" << vec.
size() <<
"," << diff <<
")";
872 <<
"Ledger " << ledger.
seq() <<
":" << ledger.
info().
hash
873 <<
" missing normal list";
877 if ((seq & 0xff) != 0)
879 JLOG(journal.
debug())
880 <<
"Can't get seq " << seq <<
" from " << ledger.
seq() <<
" past";
888 auto const lastSeq = hashIndex->getFieldU32(sfLastLedgerSequence);
889 XRPL_ASSERT(lastSeq >= seq,
"ripple::hashOfSeq : minimum last ledger");
891 (lastSeq & 0xff) == 0,
"ripple::hashOfSeq : valid last ledger");
892 auto const diff = (lastSeq - seq) >> 8;
893 STVector256 vec = hashIndex->getFieldV256(sfHashes);
894 if (vec.
size() > diff)
895 return vec[vec.
size() - diff - 1];
897 JLOG(journal.
warn()) <<
"Can't get seq " << seq <<
" from " << ledger.
seq()
917 XRPL_ASSERT(amount,
"ripple::adjustOwnerCount : nonzero amount input");
922 sle->setFieldU32(sfOwnerCount, adjusted);
930 (*sle)[sfOwner] = account;
943 bool const bNoRipple,
954 JLOG(j.
trace()) <<
"trustCreate: " <<
to_string(uSrcAccountID) <<
", "
958 auto const& uLowAccountID = !bSrcHigh ? uSrcAccountID : uDstAccountID;
959 auto const& uHighAccountID = bSrcHigh ? uSrcAccountID : uDstAccountID;
961 auto const sleRippleState = std::make_shared<SLE>(ltRIPPLE_STATE, uIndex);
962 view.
insert(sleRippleState);
966 sleRippleState->
key(),
974 sleRippleState->
key(),
980 bool const bSetDst = saLimit.
getIssuer() == uDstAccountID;
981 bool const bSetHigh = bSrcHigh ^ bSetDst;
983 XRPL_ASSERT(sleAccount,
"ripple::trustCreate : non-null SLE");
988 sleAccount->getAccountID(sfAccount) ==
989 (bSetHigh ? uHighAccountID : uLowAccountID),
990 "ripple::trustCreate : matching account ID");
997 sleRippleState->setFieldU64(sfLowNode, *lowNode);
998 sleRippleState->setFieldU64(sfHighNode, *highNode);
1000 sleRippleState->setFieldAmount(
1001 bSetHigh ? sfHighLimit : sfLowLimit, saLimit);
1002 sleRippleState->setFieldAmount(
1003 bSetHigh ? sfLowLimit : sfHighLimit,
1005 saBalance.
getCurrency(), bSetDst ? uSrcAccountID : uDstAccountID}));
1008 sleRippleState->setFieldU32(
1009 bSetHigh ? sfHighQualityIn : sfLowQualityIn, uQualityIn);
1012 sleRippleState->setFieldU32(
1013 bSetHigh ? sfHighQualityOut : sfLowQualityOut, uQualityOut);
1040 sleRippleState->setFieldU32(sfFlags, uFlags);
1044 sleRippleState->setFieldAmount(
1045 sfBalance, bSetHigh ? -saBalance : saBalance);
1048 uSrcAccountID, uDstAccountID, saBalance, saBalance.
zeroed());
1062 std::uint64_t uLowNode = sleRippleState->getFieldU64(sfLowNode);
1063 std::uint64_t uHighNode = sleRippleState->getFieldU64(sfHighNode);
1065 JLOG(j.
trace()) <<
"trustDelete: Deleting ripple line: low";
1070 sleRippleState->key(),
1076 JLOG(j.
trace()) <<
"trustDelete: Deleting ripple line: high";
1081 sleRippleState->key(),
1087 JLOG(j.
trace()) <<
"trustDelete: Deleting ripple line: state";
1088 view.
erase(sleRippleState);
1098 auto offerIndex = sle->key();
1099 auto owner = sle->getAccountID(sfAccount);
1102 uint256 uDirectory = sle->getFieldH256(sfBookDirectory);
1106 sle->getFieldU64(sfOwnerNode),
1115 sle->getFieldU64(sfBookNode),
1147 !bCheckIssuer || uSenderID == issuer || uReceiverID == issuer,
1148 "ripple::rippleCreditIOU : matching issuer or don't care");
1153 uSenderID != uReceiverID,
1154 "ripple::rippleCreditIOU : sender is not receiver");
1156 bool const bSenderHigh = uSenderID > uReceiverID;
1157 auto const index =
keylet::line(uSenderID, uReceiverID, currency);
1161 "ripple::rippleCreditIOU : sender is not XRP");
1164 "ripple::rippleCreditIOU : receiver is not XRP");
1167 if (
auto const sleRippleState = view.
peek(index))
1169 STAmount saBalance = sleRippleState->getFieldAmount(sfBalance);
1174 view.
creditHook(uSenderID, uReceiverID, saAmount, saBalance);
1176 STAmount const saBefore = saBalance;
1178 saBalance -= saAmount;
1180 JLOG(j.
trace()) <<
"rippleCreditIOU: " <<
to_string(uSenderID) <<
" -> "
1186 std::uint32_t const uFlags(sleRippleState->getFieldU32(sfFlags));
1187 bool bDelete =
false;
1191 if (saBefore > beast::zero
1193 && saBalance <= beast::zero
1204 !sleRippleState->getFieldAmount(
1205 !bSenderHigh ? sfLowLimit : sfHighLimit)
1207 && !sleRippleState->getFieldU32(
1208 !bSenderHigh ? sfLowQualityIn : sfHighQualityIn)
1210 && !sleRippleState->getFieldU32(
1211 !bSenderHigh ? sfLowQualityOut : sfHighQualityOut))
1219 sleRippleState->setFieldU32(
1224 bDelete = !saBalance
1233 sleRippleState->setFieldAmount(sfBalance, saBalance);
1241 bSenderHigh ? uReceiverID : uSenderID,
1242 !bSenderHigh ? uReceiverID : uSenderID,
1246 view.
update(sleRippleState);
1250 STAmount const saReceiverLimit(
Issue{currency, uReceiverID});
1255 JLOG(j.
debug()) <<
"rippleCreditIOU: "
1297 auto const issuer = saAmount.
getIssuer();
1301 "ripple::rippleSendIOU : neither sender nor receiver is XRP");
1303 uSenderID != uReceiverID,
1304 "ripple::rippleSendIOU : sender is not receiver");
1306 if (uSenderID == issuer || uReceiverID == issuer || issuer ==
noAccount())
1313 saActual = saAmount;
1325 JLOG(j.
debug()) <<
"rippleSendIOU> " <<
to_string(uSenderID) <<
" - > "
1334 terResult =
rippleCreditIOU(view, uSenderID, issuer, saActual,
true, j);
1359 "ripple::accountSendIOU : minimum amount and not MPT");
1365 if (!saAmount || (uSenderID == uReceiverID))
1372 JLOG(j.
trace()) <<
"accountSendIOU: " <<
to_string(uSenderID) <<
" -> "
1377 view, uSenderID, uReceiverID, saAmount, saActual, j, waiveFee);
1394 if (
auto stream = j.
trace())
1405 stream <<
"accountSendIOU> " <<
to_string(uSenderID) <<
" ("
1406 << sender_bal <<
") -> " <<
to_string(uReceiverID) <<
" ("
1407 << receiver_bal <<
") : " << saAmount.
getFullText();
1440 if (
auto stream = j.
trace())
1451 stream <<
"accountSendIOU< " <<
to_string(uSenderID) <<
" ("
1452 << sender_bal <<
") -> " <<
to_string(uReceiverID) <<
" ("
1453 << receiver_bal <<
") : " << saAmount.
getFullText();
1468 auto const issuer = saAmount.
getIssuer();
1469 auto sleIssuance = view.
peek(mptID);
1472 if (uSenderID == issuer)
1474 (*sleIssuance)[sfOutstandingAmount] += saAmount.
mpt().
value();
1475 view.
update(sleIssuance);
1480 if (
auto sle = view.
peek(mptokenID))
1482 auto const amt = sle->getFieldU64(sfMPTAmount);
1483 auto const pay = saAmount.
mpt().
value();
1486 (*sle)[sfMPTAmount] = amt - pay;
1493 if (uReceiverID == issuer)
1495 auto const outstanding = sleIssuance->getFieldU64(sfOutstandingAmount);
1496 auto const redeem = saAmount.
mpt().
value();
1497 if (outstanding >= redeem)
1499 sleIssuance->setFieldU64(sfOutstandingAmount, outstanding - redeem);
1500 view.
update(sleIssuance);
1508 if (
auto sle = view.
peek(mptokenID))
1510 (*sle)[sfMPTAmount] += saAmount.
mpt().
value();
1530 uSenderID != uReceiverID,
1531 "ripple::rippleSendMPT : sender is not receiver");
1534 auto const issuer = saAmount.
getIssuer();
1541 if (uSenderID == issuer || uReceiverID == issuer)
1545 if (uSenderID == issuer)
1547 auto const sendAmount = saAmount.
mpt().
value();
1548 auto const maximumAmount =
1550 if (sendAmount > maximumAmount ||
1551 sle->getFieldU64(sfOutstandingAmount) >
1552 maximumAmount - sendAmount)
1561 saActual = saAmount;
1572 JLOG(j.
debug()) <<
"rippleSendMPT> " <<
to_string(uSenderID) <<
" - > "
1577 if (
auto const terResult =
1596 "ripple::accountSendMPT : minimum amount and MPT");
1601 if (!saAmount || (uSenderID == uReceiverID))
1607 view, uSenderID, uReceiverID, saAmount, saActual, j, waiveFee);
1621 if constexpr (std::is_same_v<TIss, Issue>)
1623 view, uSenderID, uReceiverID, saAmount, j, waiveFee);
1626 view, uSenderID, uReceiverID, saAmount, j, waiveFee);
1650 if (before > beast::zero
1652 &&
after <= beast::zero
1656 &&
static_cast<bool>(
1662 && !state->
getFieldU32(!bSenderHigh ? sfLowQualityIn : sfHighQualityIn)
1665 !state->
getFieldU32(!bSenderHigh ? sfLowQualityOut : sfHighQualityOut))
1694 "ripple::issueIOU : neither account nor issuer is XRP");
1697 XRPL_ASSERT(issue == amount.
issue(),
"ripple::issueIOU : matching issue");
1701 issue.
account != account,
"ripple::issueIOU : not issuer account");
1706 bool bSenderHigh = issue.
account > account;
1710 if (
auto state = view.
peek(index))
1712 STAmount final_balance = state->getFieldAmount(sfBalance);
1717 STAmount const start_balance = final_balance;
1719 final_balance -= amount;
1738 state->setFieldAmount(sfBalance, final_balance);
1743 bSenderHigh ? account : issue.
account,
1744 bSenderHigh ? issue.
account : account,
1761 if (!receiverAccount)
1794 "ripple::redeemIOU : neither account nor issuer is XRP");
1797 XRPL_ASSERT(issue == amount.
issue(),
"ripple::redeemIOU : matching issue");
1801 issue.
account != account,
"ripple::redeemIOU : not issuer account");
1806 bool bSenderHigh = account > issue.
account;
1811 STAmount final_balance = state->getFieldAmount(sfBalance);
1816 STAmount const start_balance = final_balance;
1818 final_balance -= amount;
1821 view, state, bSenderHigh, account, start_balance, final_balance, j);
1831 state->setFieldAmount(sfBalance, final_balance);
1838 bSenderHigh ? issue.
account : account,
1839 bSenderHigh ? account : issue.
account,
1852 <<
" but no trust line exists!";
1866 from != beast::zero,
"ripple::transferXRP : nonzero from account");
1867 XRPL_ASSERT(to != beast::zero,
"ripple::transferXRP : nonzero to account");
1868 XRPL_ASSERT(from != to,
"ripple::transferXRP : sender is not receiver");
1869 XRPL_ASSERT(amount.
native(),
"ripple::transferXRP : amount is XRP");
1873 if (!sender || !receiver)
1908 if (
auto const trustLine =
1910 return ((*trustLine)[sfFlags] &
1927 auto const sleIssuance = view.
read(mptID);
1932 auto const mptIssuer = sleIssuance->getAccountID(sfIssuer);
1935 if (mptIssuer == account)
1939 auto const sleToken = view.
read(mptokenID);
1961 auto const sleIssuance = view.
read(mptID);
1967 if (from != (*sleIssuance)[sfIssuer] && to != (*sleIssuance)[sfIssuer])
1976 Keylet const& ownerDirKeylet,
1983 unsigned int uDirEntry{0};
1984 uint256 dirEntry{beast::zero};
1987 if (view.
exists(ownerDirKeylet) &&
1988 dirFirst(view, ownerDirKeylet.
key, sleDirNode, uDirEntry, dirEntry))
1992 if (maxNodesToDelete && ++deleted > *maxNodesToDelete)
2001 <<
"DeleteAccount: Directory node in ledger " << view.
seq()
2002 <<
" has index to object that is missing: "
2008 sleItem->getFieldU16(sfLedgerEntryType))};
2012 auto const [ter, skipEntry] = deleter(nodeType, dirEntry, sleItem);
2034 "ripple::cleanupOnAccountDelete : minimum dir entries");
2038 <<
"DeleteAccount iterator re-validation failed.";
2045 dirNext(view, ownerDirKeylet.
key, sleDirNode, uDirEntry, dirEntry));
2058 if (!sleState || sleState->getType() != ltRIPPLE_STATE)
2062 sleState->getFieldAmount(sfLowLimit).getIssuer(),
2063 sleState->getFieldAmount(sfHighLimit).getIssuer());
2066 if (!sleLow || !sleHigh)
2068 bool const ammLow = sleLow->isFieldPresent(sfAMMID);
2069 bool const ammHigh = sleHigh->isFieldPresent(sfAMMID);
2072 if (ammLow && ammHigh)
2076 if (!ammLow && !ammHigh)
2083 if (
auto const ter =
trustDelete(view, sleState, low, high, j);
2087 <<
"deleteAMMTrustLine: failed to delete the trustline.";
2092 if (!(sleState->getFlags() & uFlags))
2111 if constexpr (std::is_same_v<TIss, Issue>)
2114 view, uSenderID, uReceiverID, saAmount, bCheckIssuer, j);
2120 "ripple::rippleCredit : not checking issuer");
2122 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.
std::shared_ptr< STLedgerEntry > pointer
std::shared_ptr< STLedgerEntry > const & ref
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 amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
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
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 trustCreate(ApplyView &view, bool const bSrcHigh, AccountID const &uSrcAccountID, AccountID const &uDstAccountID, uint256 const &uIndex, SLE::ref sleAccount, bool const bAuth, bool const bNoRipple, bool const bFreeze, bool bDeepFreeze, STAmount const &saBalance, STAmount const &saLimit, std::uint32_t uQualityIn, std::uint32_t uQualityOut, beast::Journal j)
Create a trust line.
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)
bool isLPTokenFrozen(ReadView const &view, AccountID const &account, Issue const &asset, Issue const &asset2)
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.
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
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, char const *reason)
Return false if the test ledger is provably incompatible with the valid ledger, that is,...
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.
T time_since_epoch(T... args)