1#include <xrpl/ledger/helpers/TokenHelpers.h>
3#include <xrpl/basics/Log.h>
4#include <xrpl/beast/utility/Journal.h>
5#include <xrpl/beast/utility/Zero.h>
6#include <xrpl/beast/utility/instrumentation.h>
7#include <xrpl/ledger/ApplyView.h>
8#include <xrpl/ledger/ReadView.h>
9#include <xrpl/ledger/View.h>
10#include <xrpl/ledger/helpers/AccountRootHelpers.h>
11#include <xrpl/ledger/helpers/MPTokenHelpers.h>
12#include <xrpl/ledger/helpers/RippleStateHelpers.h>
13#include <xrpl/ledger/helpers/SponsorHelpers.h>
14#include <xrpl/protocol/AccountID.h>
15#include <xrpl/protocol/Asset.h>
16#include <xrpl/protocol/Concepts.h>
17#include <xrpl/protocol/Feature.h>
18#include <xrpl/protocol/Indexes.h>
19#include <xrpl/protocol/Issue.h>
20#include <xrpl/protocol/LedgerFormats.h>
21#include <xrpl/protocol/MPTIssue.h>
22#include <xrpl/protocol/Protocol.h>
23#include <xrpl/protocol/Rate.h>
24#include <xrpl/protocol/SField.h>
25#include <xrpl/protocol/STAmount.h>
26#include <xrpl/protocol/STLedgerEntry.h>
27#include <xrpl/protocol/TER.h>
28#include <xrpl/protocol/UintTypes.h>
29#include <xrpl/protocol/XRPAmount.h>
81 [&](
auto const& issue) {
return isFrozen(view, account, issue, depth); }, asset.
value());
100 [&](
auto const& issue) {
return checkFrozen(view, account, issue); }, asset.
value());
135 return isFrozen(view, account, mptIssue, depth);
142 [&](
auto const& issue) {
return isDeepFrozen(view, account, issue, depth); },
169 "xrpl::checkWithdrawFreeze : source is a pseudo-account");
172 "xrpl::checkWithdrawFreeze : submitter is not a pseudo-account");
175 "xrpl::checkWithdrawFreeze : destination is not a pseudo-account");
179 "xrpl::checkWithdrawFreeze : asset issuer cannot be a pseudo-account");
196 if (submitterAcct != dstAcct)
210 UNREACHABLE(
"xrpl::checkWithdrawFreeze : pseudo-account backed object holds shares");
227 "xrpl::checkDepositFreeze : destination is a pseudo-account");
230 "xrpl::checkDepositFreeze : source is not a pseudo-account");
234 "xrpl::checkDepositFreeze : asset issuer cannot be a pseudo-account");
254 UNREACHABLE(
"xrpl::checkDepositFreeze : pseudo-account backed object holds shares");
286 if (
isFrozen(view, account, currency, issuer) ||
301 if (sleIssuer->isFieldPresent(sfAMMID))
306 isLPTokenFrozen(view, account, (*sleAmm)[sfAsset], (*sleAmm)[sfAsset2]))
333 bool includeOppositeLimit,
339 amount = sle->getFieldAmount(sfBalance);
340 bool const accountHigh = account > issuer;
341 auto const& oppositeField = accountHigh ? sfLowLimit : sfHighLimit;
347 if (includeOppositeLimit)
349 amount += sle->getFieldAmount(oppositeField);
351 amount.
get<
Issue>().account = issuer;
358 JLOG(j.
trace()) <<
"getTrustLineBalance:" <<
" account=" <<
to_string(account)
381 if (returnSpendable && account == issuer)
405 view, account, issue.
currency, issue.
account, zeroIfFrozen, j, includeFullBalance);
420 auto const& issuer = mptIssue.
getIssuer();
421 bool const mptokensV2 = view.
rules().
enabled(featureMPTokensV2);
423 if (returnSpendable && account == mptIssue.
getIssuer())
435 return STAmount{mptIssue, available};
444 amount.
clear(mptIssue);
448 amount =
STAmount{mptIssue, sleMpt->getFieldU64(sfMPTAmount)};
458 amount.
clear(mptIssue);
466 if (sleIssuance && sleIssuance->isFlag(lsfMPTRequireAuth) &&
467 !sleMpt->isFlag(lsfMPTAuthorized))
468 amount.
clear(mptIssue);
477[[nodiscard]] STAmount
488 [&](
Issue const& issue) {
489 return accountHolds(view, account, issue, zeroIfFrozen, j, includeFullBalance);
493 view, account, issue, zeroIfFrozen, zeroIfUnauthorized, j, includeFullBalance);
505 XRPL_ASSERT(saDefault.
holds<
Issue>(),
"xrpl::accountFunds: saDefault holds Issue");
524 [&](
Issue const&) {
return accountFunds(view,
id, saDefault, freezeHandling, j); },
570 if (!issuer->isFlag(lsfDefaultRipple))
652 return requireAuth(view, issue, account, authType);
668 return canTransfer(view, issue, from, to, waive, depth);
698 !bCheckIssuer || uSenderID == issuer || uReceiverID == issuer,
699 "xrpl::directSendNoFeeIOU : matching issuer or don't care");
703 XRPL_ASSERT(uSenderID != uReceiverID,
"xrpl::directSendNoFeeIOU : sender is not receiver");
705 bool const bSenderHigh = uSenderID > uReceiverID;
710 "xrpl::directSendNoFeeIOU : sender is not XRP");
713 "xrpl::directSendNoFeeIOU : receiver is not XRP");
716 if (
auto const sleRippleState = view.
peek(index))
718 STAmount saBalance = sleRippleState->getFieldAmount(sfBalance);
723 view.
creditHookIOU(uSenderID, uReceiverID, saAmount, saBalance);
725 STAmount const saBefore = saBalance;
727 saBalance -= saAmount;
729 JLOG(j.
trace()) <<
"directSendNoFeeIOU: " <<
to_string(uSenderID) <<
" -> "
734 bool bDelete =
false;
736 auto const senderReserveFlag = bSenderHigh ? lsfHighReserve : lsfLowReserve;
737 auto const senderNoRippleFlag = bSenderHigh ? lsfHighNoRipple : lsfLowNoRipple;
738 auto const senderFreezeFlag = bSenderHigh ? lsfHighFreeze : lsfLowFreeze;
739 auto const receiverReserveFlag = bSenderHigh ? lsfLowReserve : lsfHighReserve;
747 && sleRippleState->isFlag(senderReserveFlag)
749 && sleRippleState->isFlag(senderNoRippleFlag) !=
751 !sleRippleState->isFlag(senderFreezeFlag) &&
752 !sleRippleState->getFieldAmount(bSenderHigh ? sfHighLimit : sfLowLimit)
754 && (sleRippleState->getFieldU32(bSenderHigh ? sfHighQualityIn : sfLowQualityIn) == 0u)
757 (sleRippleState->getFieldU32(bSenderHigh ? sfHighQualityOut : sfLowQualityOut) == 0u))
762 view, sleRippleState, !bSenderHigh ? sfLowSponsor : sfHighSponsor);
766 sleRippleState, !bSenderHigh ? sfLowSponsor : sfHighSponsor);
769 sleRippleState->clearFlag(senderReserveFlag);
773 && !sleRippleState->isFlag(receiverReserveFlag);
781 sleRippleState->setFieldAmount(sfBalance, saBalance);
789 bSenderHigh ? uReceiverID : uSenderID,
790 bSenderHigh ? uSenderID : uReceiverID,
794 view.
update(sleRippleState);
798 STAmount const saReceiverLimit(
Issue{currency, uReceiverID});
803 JLOG(j.
debug()) <<
"directSendNoFeeIOU: "
812 bool const noRipple = !sleAccount->isFlag(lsfDefaultRipple);
847 auto const& issuer = saAmount.
getIssuer();
851 "xrpl::directSendNoLimitIOU : neither sender nor receiver is XRP");
852 XRPL_ASSERT(uSenderID != uReceiverID,
"xrpl::directSendNoLimitIOU : sender is not receiver");
854 if (uSenderID == issuer || uReceiverID == issuer || issuer ==
noAccount())
872 JLOG(j.
debug()) <<
"directSendNoLimitIOU> " <<
to_string(uSenderID) <<
" - > "
880 terResult =
directSendNoFeeIOU(view, uSenderID, issuer, saActual,
true, sponsorSle, j);
901 XRPL_ASSERT(!
isXRP(senderID),
"xrpl::directSendNoLimitMultiIOU : sender is not XRP");
905 actual = takeFromSender;
908 for (
auto const& r : receivers)
910 auto const& receiverID = r.first;
911 STAmount const amount{issue, r.second};
916 if (!amount || (senderID == receiverID))
919 XRPL_ASSERT(!
isXRP(receiverID),
"xrpl::directSendNoLimitMultiIOU : receiver is not XRP");
921 if (senderID == issuer || receiverID == issuer || issuer ==
noAccount())
942 actual += actualSend;
943 takeFromSender += actualSend;
945 JLOG(j.
debug()) <<
"directSendNoLimitMultiIOU> " <<
to_string(senderID) <<
" - > "
953 if (senderID != issuer && takeFromSender)
955 if (
TER const terResult =
985 "xrpl::accountSendIOU : minimum amount and not MPT");
992 if (!saAmount || (uSenderID == uReceiverID))
999 JLOG(j.
trace()) <<
"accountSendIOU: " <<
to_string(uSenderID) <<
" -> "
1003 view, uSenderID, uReceiverID, saAmount, saActual, j, sponsorSle, waiveFee);
1018 if (
auto stream = j.
trace())
1029 stream <<
"accountSendIOU> " <<
to_string(uSenderID) <<
" (" << senderBal <<
") -> "
1064 if (
auto stream = j.
trace())
1075 stream <<
"accountSendIOU< " <<
to_string(uSenderID) <<
" (" << senderBal <<
") -> "
1092 receivers.
size() > 1,
"xrpl::accountSendMultiIOU",
"multiple recipients provided");
1097 JLOG(j.
trace()) <<
"accountSendMultiIOU: " <<
to_string(senderID) <<
" sending "
1098 << receivers.
size() <<
" IOUs";
1112 if (
auto stream = j.
trace())
1119 stream <<
"accountSendMultiIOU> " <<
to_string(senderID) <<
" (" << senderBal <<
") -> "
1120 << receivers.
size() <<
" receivers.";
1125 for (
auto const& r : receivers)
1127 auto const& receiverID = r.first;
1128 STAmount const amount{issue, r.second};
1138 if (!amount || (senderID == receiverID))
1144 if (
auto stream = j.
trace())
1151 stream <<
"accountSendMultiIOU> " <<
to_string(senderID) <<
" -> "
1152 <<
to_string(receiverID) <<
" (" << receiverBal
1166 takeFromSender += amount;
1169 if (
auto stream = j.
trace())
1176 stream <<
"accountSendMultiIOU< " <<
to_string(senderID) <<
" -> "
1177 <<
to_string(receiverID) <<
" (" << receiverBal
1196 if (
auto stream = j.
trace())
1203 stream <<
"accountSendMultiIOU< " <<
to_string(senderID) <<
" (" << senderBal <<
") -> "
1204 << receivers.
size() <<
" receivers.";
1219 auto const& issuer = saAmount.
getIssuer();
1220 auto sleIssuance = view.
peek(mptID);
1225 auto const outstanding = sleIssuance->getFieldU64(sfOutstandingAmount);
1227 auto const amt = saAmount.
mpt().
value();
1229 if (uSenderID == issuer)
1236 (*sleIssuance)[sfOutstandingAmount] += amt;
1237 view.
update(sleIssuance);
1242 if (
auto sle = view.
peek(mptokenID))
1244 auto const senderBalance = sle->getFieldU64(sfMPTAmount);
1245 if (senderBalance < amt)
1247 view.
creditHookMPT(uSenderID, uReceiverID, saAmount, (*sle)[sfMPTAmount], available);
1248 (*sle)[sfMPTAmount] = senderBalance - amt;
1257 if (uReceiverID == issuer)
1259 if (outstanding >= amt)
1261 sleIssuance->setFieldU64(sfOutstandingAmount, outstanding - amt);
1262 view.
update(sleIssuance);
1272 if (
auto sle = view.
peek(mptokenID))
1281 view.
creditHookMPT(uSenderID, uReceiverID, saAmount, (*sle)[sfMPTAmount], available);
1282 (*sle)[sfMPTAmount] += amt;
1305 XRPL_ASSERT(uSenderID != uReceiverID,
"xrpl::directSendNoLimitMPT : sender is not receiver");
1308 auto const& issuer = saAmount.
getIssuer();
1314 if (uSenderID == issuer || uReceiverID == issuer)
1318 if (uSenderID == issuer)
1320 auto const sendAmount = saAmount.
mpt().
value();
1322 auto const outstanding = sle->getFieldU64(sfOutstandingAmount);
1323 auto const mptokensV2 = view.
rules().
enabled(featureMPTokensV2);
1327 if (
isMPTOverflow(sendAmount, outstanding, maxAmount, allowOverflow))
1335 saActual = saAmount;
1344 JLOG(j.
debug()) <<
"directSendNoLimitMPT> " <<
to_string(uSenderID) <<
" - > "
1348 if (
auto const terResult =
directSendNoFeeMPT(view, issuer, uReceiverID, saAmount, j);
1365 auto const& issuer = mptIssue.
getIssuer();
1380 std::uint64_t const outstandingAmount = sle->getFieldU64(sfOutstandingAmount);
1387 actual = takeFromSender;
1389 for (
auto const& [receiverID, amt] : receivers)
1391 STAmount const amount{mptIssue, amt};
1396 if (!amount || senderID == receiverID)
1399 if (senderID == issuer || receiverID == issuer)
1401 if (senderID == issuer)
1405 "xrpl::directSendNoLimitMultiMPT",
1406 "sender == issuer, takeFromSender == zero");
1416 bool const exceedsMaximumAmount =
1418 sendAmount > maximumAmount ||
1420 totalSendAmount > maximumAmount - sendAmount ||
1422 outstandingAmount > maximumAmount - sendAmount - totalSendAmount;
1424 if (exceedsMaximumAmount)
1426 totalSendAmount += sendAmount;
1434 if (sendAmount > maximumAmount ||
1435 outstandingAmount > maximumAmount - sendAmount)
1454 actual += actualSend;
1455 takeFromSender += actualSend;
1457 JLOG(j.
debug()) <<
"directSendNoLimitMultiMPT> " <<
to_string(senderID) <<
" - > "
1465 if (senderID != issuer && takeFromSender)
1487 "xrpl::accountSendMPT : minimum amount and MPT");
1492 if (!saAmount || (uSenderID == uReceiverID))
1498 view, uSenderID, uReceiverID, saAmount, saActual, j, waiveFee, allowOverflow);
1532 return directSendNoFeeIOU(view, uSenderID, uReceiverID, saAmount, bCheckIssuer, {}, j);
1535 XRPL_ASSERT(!bCheckIssuer,
"xrpl::directSendNoFee : not checking issuer");
1553 return accountSendIOU(view, uSenderID, uReceiverID, saAmount, j, sponsorSle, waiveFee);
1557 view, uSenderID, uReceiverID, saAmount, j, waiveFee, allowOverflow);
1571 receivers.
size() > 1,
"xrpl::accountSendMulti",
"multiple recipients provided");
1573 [&](
Issue const& issue) {
1589 XRPL_ASSERT(from !=
beast::kZero,
"xrpl::transferXRP : nonzero from account");
1590 XRPL_ASSERT(to !=
beast::kZero,
"xrpl::transferXRP : nonzero to account");
1591 XRPL_ASSERT(from != to,
"xrpl::transferXRP : sender is not receiver");
1592 XRPL_ASSERT(amount.
native(),
"xrpl::transferXRP : amount is XRP");
1596 if (!sender || !receiver)
A generic endpoint for log messages.
Stream trace() const
Severity stream access functions.
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 creditHookIOU(AccountID const &from, AccountID const &to, STAmount const &amount, STAmount const &preCreditBalance)
virtual void creditHookMPT(AccountID const &from, AccountID const &to, STAmount const &amount, std::uint64_t preCreditBalanceHolder, std::int64_t preCreditBalanceIssuer)
virtual void update(SLE::Ref sle)=0
Indicate changes to a peeked SLE.
constexpr auto visit(Visitors &&... visitors) const -> decltype(auto)
constexpr TIss const & get() const
AccountID const & getIssuer() const
constexpr bool holds() const
constexpr value_type const & value() const
A currency issued by an account.
AccountID const & getIssuer() const
constexpr value_type value() const
Returns the underlying value.
constexpr MPTID const & getMptID() const
AccountID const & getIssuer() const
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 STAmount balanceHookMPT(AccountID const &account, MPTIssue const &issue, std::int64_t amount) const
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
virtual bool open() const =0
Returns true if this reflects an open ledger.
virtual STAmount balanceHookIOU(AccountID const &account, AccountID const &issuer, STAmount const &amount) const
bool enabled(UInt256 const &feature) const
Returns true if a feature is enabled.
constexpr bool holds() const noexcept
constexpr TIss const & get() const
std::string getFullText() const override
bool native() const noexcept
Asset const & asset() const
AccountID const & getIssuer() const
static constexpr std::uint64_t kMaxValue
static constexpr int kMaxOffset
std::shared_ptr< STLedgerEntry > pointer
std::shared_ptr< STLedgerEntry const > const & ConstRef
std::shared_ptr< STLedgerEntry > const & Ref
std::shared_ptr< STLedgerEntry const > const_pointer
void setFieldAmount(SField const &field, STAmount const &)
STAmount const & getFieldAmount(SField const &field) const
Keylet amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) 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.
void removeSponsorFromLedgerEntry(SLE::Ref sle, SF_ACCOUNT const &field=sfSponsor)
Remove the reserve sponsor field from a ledger entry.
TER checkDeepFrozen(ReadView const &view, AccountID const &account, Issue const &issue)
std::int64_t maxMPTAmount(SLE const &sleIssuance)
XRPAmount xrpLiquid(ReadView const &view, AccountID const &id, std::int32_t ownerCountAdj, beast::Journal j)
Calculate liquid XRP balance for an account.
FreezeHandling
Controls the treatment of frozen account balances.
static TER directSendNoLimitMultiIOU(ApplyView &view, AccountID const &senderID, Issue const &issue, MultiplePaymentDestinations const &receivers, STAmount &actual, beast::Journal j, WaiveTransferFee waiveFee)
static STAmount getTrustLineBalance(ReadView const &view, SLE::ConstRef sle, AccountID const &account, Currency const ¤cy, AccountID const &issuer, bool includeOppositeLimit, beast::Journal j)
SpendableHandling
Controls whether to include the account's full spendable balance.
TER checkIndividualFrozen(ReadView const &view, AccountID const &account, Asset const &asset)
bool isXRP(AccountID const &c)
bool isIndividualFrozen(ReadView const &view, AccountID const &account, MPTIssue const &mptIssue)
Returns true if account's MPToken for mptIssue carries the individual-lock flag (lsfMPTLocked).
TER checkDepositFreeze(ReadView const &view, AccountID const &srcAcct, AccountID const &pseudoAcct, Asset const &asset)
Checks freeze compliance for depositing an asset into a pseudo-account (e.g.
AllowMPTOverflow
Controls whether accountSend is allowed to overflow OutstandingAmount *.
static TER accountSendMultiIOU(ApplyView &view, AccountID const &senderID, Issue const &issue, MultiplePaymentDestinations const &receivers, beast::Journal j, WaiveTransferFee waiveFee)
TER removeEmptyHolding(ApplyViewContext ctx, AccountID const &accountID, MPTIssue const &mptIssue, beast::Journal journal)
TER checkFrozen(ReadView const &view, AccountID const &account, Issue const &issue)
BaseUInt< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
TER addEmptyHolding(ApplyViewContext ctx, AccountID const &accountID, XRPAmount priorBalance, MPTIssue const &mptIssue, beast::Journal journal)
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, SLE::Ref sponsorSle, beast::Journal j)
Create a trust line.
TER canTransfer(ReadView const &view, MPTIssue const &mptIssue, AccountID const &from, AccountID const &to, WaiveMPTCanTransfer waive=WaiveMPTCanTransfer::No, std::uint8_t depth=0)
Check whether to may receive the given MPT from from.
bool isDeepFrozen(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer)
static TER directSendNoFeeIOU(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, bool bCheckIssuer, SLE::Ref sponsorSle, beast::Journal j)
std::string to_string(BaseUInt< Bits, Tag > const &a)
bool isVaultPseudoAccountFrozen(ReadView const &view, AccountID const &account, MPTIssue const &mptShare, std::uint8_t depth)
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
static TER directSendNoLimitIOU(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, STAmount &saActual, beast::Journal j, SLE::Ref sponsorSle, WaiveTransferFee waiveFee)
bool isGlobalFrozen(ReadView const &view, AccountID const &issuer)
Check if the issuer has the global freeze flag set.
TER canTransferLPToken(ReadView const &view, AccountID const &from, AccountID const &to, AccountID const &lpTokenIssuer)
Check whether an AMM LPToken may be transferred between from and to.
TER canAddHolding(ReadView const &view, MPTIssue const &mptIssue)
TER accountSend(ApplyView &view, AccountID const &from, AccountID const &to, STAmount const &saAmount, beast::Journal j, SLE::Ref sponsorSle={}, WaiveTransferFee waiveFee=WaiveTransferFee::No, AllowMPTOverflow allowOverflow=AllowMPTOverflow::No)
Calls static accountSendIOU if saAmount represents Issue.
void decreaseOwnerCount(ApplyView &view, SLE::Ref accountSle, SLE::Ref sponsorSle, std::uint32_t count, beast::Journal j)
Decrease owner-count fields when the caller supplies the sponsor.
AuthHandling
Controls the treatment of unauthorized MPT balances.
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
static SLE::const_pointer getLineIfUsable(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j)
TER directSendNoFee(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, bool bCheckIssuer, beast::Journal j)
Calls static directSendNoFeeIOU if saAmount represents Issue.
std::int64_t availableMPTAmount(SLE const &sleIssuance)
TER transferXRP(ApplyView &view, AccountID const &from, AccountID const &to, STAmount const &amount, beast::Journal j)
WaiveMPTCanTransfer
Controls whether canTransfer enforces lsfMPTCanTransfer on MPTs.
bool isFrozen(ReadView const &view, AccountID const &account, MPTIssue const &mptIssue, std::uint8_t depth=0)
Returns true if account cannot send or receive tokens of mptIssue because a freeze applies.
TER checkGlobalFrozen(ReadView const &view, Asset const &asset)
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.
AccountID const & noAccount()
A placeholder for empty accounts.
static TER directSendNoLimitMPT(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, STAmount &saActual, beast::Journal j, WaiveTransferFee waiveFee, AllowMPTOverflow allowOverflow)
static TER accountSendMPT(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, beast::Journal j, WaiveTransferFee waiveFee, AllowMPTOverflow allowOverflow)
bool isTesSuccess(TER x) noexcept
bool isAnyFrozen(ReadView const &view, std::initializer_list< AccountID > const &accounts, MPTIssue const &mptIssue, std::uint8_t depth=0)
SLE::pointer getLedgerEntryReserveSponsor(ApplyView &view, SLE::ConstRef sle, SF_ACCOUNT const &field=sfSponsor)
Return a mutable SLE for the reserve sponsor recorded on a ledger entry.
TERSubset< CanCvtToTER > TER
bool isLPTokenFrozen(ReadView const &view, AccountID const &account, Asset const &asset, Asset const &asset2)
TER requireAuth(ReadView const &view, MPTIssue const &mptIssue, AccountID const &account, AuthType authType=AuthType::Legacy, std::uint8_t depth=0)
Check if the account lacks required authorization for MPT.
static TER directSendNoLimitMultiMPT(ApplyView &view, AccountID const &senderID, MPTIssue const &mptIssue, MultiplePaymentDestinations const &receivers, STAmount &actual, beast::Journal j, WaiveTransferFee waiveFee)
AccountID const & xrpAccount()
Compute AccountID from public key.
STAmount multiply(STAmount const &amount, Number const &frac, Number::RoundingMode rm)
static TER accountSendMultiMPT(ApplyView &view, AccountID const &senderID, MPTIssue const &mptIssue, MultiplePaymentDestinations const &receivers, beast::Journal j, WaiveTransferFee waiveFee)
std::vector< std::pair< AccountID, Number > > MultiplePaymentDestinations
TER accountSendMulti(ApplyView &view, AccountID const &senderID, Asset const &asset, MultiplePaymentDestinations const &receivers, beast::Journal j, WaiveTransferFee waiveFee=WaiveTransferFee::No)
Like accountSend, except one account is sending multiple payments (with the same asset!...
constexpr std::uint64_t kMaxMpTokenAmount
The maximum amount of MPTokenIssuance.
TER trustDelete(ApplyView &view, SLE::Ref sleRippleState, AccountID const &uLowAccountID, AccountID const &uHighAccountID, beast::Journal j)
TER checkWithdrawFreeze(ReadView const &view, AccountID const &pseudoAcct, AccountID const &submitterAcct, AccountID const &dstAcct, Asset const &asset)
Checks freeze compliance for withdrawing an asset from a pseudo-account (e.g.
bool isMPTOverflow(std::int64_t sendAmount, std::uint64_t outstandingAmount, std::int64_t maximumAmount, AllowMPTOverflow allowOverflow)
Checks for two types of OutstandingAmount overflow during a send operation.
static TER accountSendIOU(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, beast::Journal j, SLE::Ref sponsorSle, WaiveTransferFee waiveFee)
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j, SpendableHandling includeFullBalance=SpendableHandling::SimpleBalance)
bool holdingExists(ReadView const &view, AccountID const &account, Asset const &asset)
True if the account already holds this asset (or is the issuer / XRP).
static TER directSendNoFeeMPT(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, beast::Journal j)
Bundles the mutable ledger view and the transaction being applied.