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]))
324 bool includeOppositeLimit,
330 amount = sle->getFieldAmount(sfBalance);
331 bool const accountHigh = account > issuer;
332 auto const& oppositeField = accountHigh ? sfLowLimit : sfHighLimit;
338 if (includeOppositeLimit)
340 amount += sle->getFieldAmount(oppositeField);
342 amount.
get<
Issue>().account = issuer;
349 JLOG(j.
trace()) <<
"getTrustLineBalance:" <<
" account=" <<
to_string(account)
372 if (returnSpendable && account == issuer)
396 view, account, issue.
currency, issue.
account, zeroIfFrozen, j, includeFullBalance);
411 auto const& issuer = mptIssue.
getIssuer();
412 bool const mptokensV2 = view.
rules().
enabled(featureMPTokensV2);
414 if (returnSpendable && account == mptIssue.
getIssuer())
426 return STAmount{mptIssue, available};
435 amount.
clear(mptIssue);
439 amount =
STAmount{mptIssue, sleMpt->getFieldU64(sfMPTAmount)};
449 amount.
clear(mptIssue);
457 if (sleIssuance && sleIssuance->isFlag(lsfMPTRequireAuth) &&
458 !sleMpt->isFlag(lsfMPTAuthorized))
459 amount.
clear(mptIssue);
468[[nodiscard]] STAmount
479 [&](
Issue const& issue) {
480 return accountHolds(view, account, issue, zeroIfFrozen, j, includeFullBalance);
484 view, account, issue, zeroIfFrozen, zeroIfUnauthorized, j, includeFullBalance);
496 XRPL_ASSERT(saDefault.
holds<
Issue>(),
"xrpl::accountFunds: saDefault holds Issue");
515 [&](
Issue const&) {
return accountFunds(view,
id, saDefault, freezeHandling, j); },
555 if (!issuer->isFlag(lsfDefaultRipple))
611 return requireAuth(view, issue, account, authType);
627 return canTransfer(view, issue, from, to, waive, depth);
657 !bCheckIssuer || uSenderID == issuer || uReceiverID == issuer,
658 "xrpl::directSendNoFeeIOU : matching issuer or don't care");
662 XRPL_ASSERT(uSenderID != uReceiverID,
"xrpl::directSendNoFeeIOU : sender is not receiver");
664 bool const bSenderHigh = uSenderID > uReceiverID;
669 "xrpl::directSendNoFeeIOU : sender is not XRP");
672 "xrpl::directSendNoFeeIOU : receiver is not XRP");
675 if (
auto const sleRippleState = view.
peek(index))
677 STAmount saBalance = sleRippleState->getFieldAmount(sfBalance);
682 view.
creditHookIOU(uSenderID, uReceiverID, saAmount, saBalance);
684 STAmount const saBefore = saBalance;
686 saBalance -= saAmount;
688 JLOG(j.
trace()) <<
"directSendNoFeeIOU: " <<
to_string(uSenderID) <<
" -> "
693 bool bDelete =
false;
695 auto const senderReserveFlag = bSenderHigh ? lsfHighReserve : lsfLowReserve;
696 auto const senderNoRippleFlag = bSenderHigh ? lsfHighNoRipple : lsfLowNoRipple;
697 auto const senderFreezeFlag = bSenderHigh ? lsfHighFreeze : lsfLowFreeze;
698 auto const receiverReserveFlag = bSenderHigh ? lsfLowReserve : lsfHighReserve;
706 && sleRippleState->isFlag(senderReserveFlag)
708 && sleRippleState->isFlag(senderNoRippleFlag) !=
710 !sleRippleState->isFlag(senderFreezeFlag) &&
711 !sleRippleState->getFieldAmount(bSenderHigh ? sfHighLimit : sfLowLimit)
713 && (sleRippleState->getFieldU32(bSenderHigh ? sfHighQualityIn : sfLowQualityIn) == 0u)
716 (sleRippleState->getFieldU32(bSenderHigh ? sfHighQualityOut : sfLowQualityOut) == 0u))
721 view, sleRippleState, !bSenderHigh ? sfLowSponsor : sfHighSponsor);
725 sleRippleState, !bSenderHigh ? sfLowSponsor : sfHighSponsor);
728 sleRippleState->clearFlag(senderReserveFlag);
732 && !sleRippleState->isFlag(receiverReserveFlag);
740 sleRippleState->setFieldAmount(sfBalance, saBalance);
748 bSenderHigh ? uReceiverID : uSenderID,
749 bSenderHigh ? uSenderID : uReceiverID,
753 view.
update(sleRippleState);
757 STAmount const saReceiverLimit(
Issue{currency, uReceiverID});
762 JLOG(j.
debug()) <<
"directSendNoFeeIOU: "
771 bool const noRipple = !sleAccount->isFlag(lsfDefaultRipple);
806 auto const& issuer = saAmount.
getIssuer();
810 "xrpl::directSendNoLimitIOU : neither sender nor receiver is XRP");
811 XRPL_ASSERT(uSenderID != uReceiverID,
"xrpl::directSendNoLimitIOU : sender is not receiver");
813 if (uSenderID == issuer || uReceiverID == issuer || issuer ==
noAccount())
831 JLOG(j.
debug()) <<
"directSendNoLimitIOU> " <<
to_string(uSenderID) <<
" - > "
839 terResult =
directSendNoFeeIOU(view, uSenderID, issuer, saActual,
true, sponsorSle, j);
860 XRPL_ASSERT(!
isXRP(senderID),
"xrpl::directSendNoLimitMultiIOU : sender is not XRP");
864 actual = takeFromSender;
867 for (
auto const& r : receivers)
869 auto const& receiverID = r.first;
870 STAmount const amount{issue, r.second};
875 if (!amount || (senderID == receiverID))
878 XRPL_ASSERT(!
isXRP(receiverID),
"xrpl::directSendNoLimitMultiIOU : receiver is not XRP");
880 if (senderID == issuer || receiverID == issuer || issuer ==
noAccount())
901 actual += actualSend;
902 takeFromSender += actualSend;
904 JLOG(j.
debug()) <<
"directSendNoLimitMultiIOU> " <<
to_string(senderID) <<
" - > "
912 if (senderID != issuer && takeFromSender)
914 if (
TER const terResult =
944 "xrpl::accountSendIOU : minimum amount and not MPT");
951 if (!saAmount || (uSenderID == uReceiverID))
958 JLOG(j.
trace()) <<
"accountSendIOU: " <<
to_string(uSenderID) <<
" -> "
962 view, uSenderID, uReceiverID, saAmount, saActual, j, sponsorSle, waiveFee);
977 if (
auto stream = j.
trace())
988 stream <<
"accountSendIOU> " <<
to_string(uSenderID) <<
" (" << senderBal <<
") -> "
1023 if (
auto stream = j.
trace())
1034 stream <<
"accountSendIOU< " <<
to_string(uSenderID) <<
" (" << senderBal <<
") -> "
1051 receivers.
size() > 1,
"xrpl::accountSendMultiIOU",
"multiple recipients provided");
1056 JLOG(j.
trace()) <<
"accountSendMultiIOU: " <<
to_string(senderID) <<
" sending "
1057 << receivers.
size() <<
" IOUs";
1071 if (
auto stream = j.
trace())
1078 stream <<
"accountSendMultiIOU> " <<
to_string(senderID) <<
" (" << senderBal <<
") -> "
1079 << receivers.
size() <<
" receivers.";
1084 for (
auto const& r : receivers)
1086 auto const& receiverID = r.first;
1087 STAmount const amount{issue, r.second};
1097 if (!amount || (senderID == receiverID))
1103 if (
auto stream = j.
trace())
1110 stream <<
"accountSendMultiIOU> " <<
to_string(senderID) <<
" -> "
1111 <<
to_string(receiverID) <<
" (" << receiverBal
1125 takeFromSender += amount;
1128 if (
auto stream = j.
trace())
1135 stream <<
"accountSendMultiIOU< " <<
to_string(senderID) <<
" -> "
1136 <<
to_string(receiverID) <<
" (" << receiverBal
1155 if (
auto stream = j.
trace())
1162 stream <<
"accountSendMultiIOU< " <<
to_string(senderID) <<
" (" << senderBal <<
") -> "
1163 << receivers.
size() <<
" receivers.";
1178 auto const& issuer = saAmount.
getIssuer();
1179 auto sleIssuance = view.
peek(mptID);
1184 auto const outstanding = sleIssuance->getFieldU64(sfOutstandingAmount);
1186 auto const amt = saAmount.
mpt().
value();
1188 if (uSenderID == issuer)
1195 (*sleIssuance)[sfOutstandingAmount] += amt;
1196 view.
update(sleIssuance);
1201 if (
auto sle = view.
peek(mptokenID))
1203 auto const senderBalance = sle->getFieldU64(sfMPTAmount);
1204 if (senderBalance < amt)
1206 view.
creditHookMPT(uSenderID, uReceiverID, saAmount, (*sle)[sfMPTAmount], available);
1207 (*sle)[sfMPTAmount] = senderBalance - amt;
1216 if (uReceiverID == issuer)
1218 if (outstanding >= amt)
1220 sleIssuance->setFieldU64(sfOutstandingAmount, outstanding - amt);
1221 view.
update(sleIssuance);
1231 if (
auto sle = view.
peek(mptokenID))
1240 view.
creditHookMPT(uSenderID, uReceiverID, saAmount, (*sle)[sfMPTAmount], available);
1241 (*sle)[sfMPTAmount] += amt;
1264 XRPL_ASSERT(uSenderID != uReceiverID,
"xrpl::directSendNoLimitMPT : sender is not receiver");
1267 auto const& issuer = saAmount.
getIssuer();
1273 if (uSenderID == issuer || uReceiverID == issuer)
1277 if (uSenderID == issuer)
1279 auto const sendAmount = saAmount.
mpt().
value();
1281 auto const outstanding = sle->getFieldU64(sfOutstandingAmount);
1282 auto const mptokensV2 = view.
rules().
enabled(featureMPTokensV2);
1286 if (
isMPTOverflow(sendAmount, outstanding, maxAmount, allowOverflow))
1294 saActual = saAmount;
1303 JLOG(j.
debug()) <<
"directSendNoLimitMPT> " <<
to_string(uSenderID) <<
" - > "
1307 if (
auto const terResult =
directSendNoFeeMPT(view, issuer, uReceiverID, saAmount, j);
1324 auto const& issuer = mptIssue.
getIssuer();
1339 std::uint64_t const outstandingAmount = sle->getFieldU64(sfOutstandingAmount);
1346 actual = takeFromSender;
1348 for (
auto const& [receiverID, amt] : receivers)
1350 STAmount const amount{mptIssue, amt};
1355 if (!amount || senderID == receiverID)
1358 if (senderID == issuer || receiverID == issuer)
1360 if (senderID == issuer)
1364 "xrpl::directSendNoLimitMultiMPT",
1365 "sender == issuer, takeFromSender == zero");
1375 bool const exceedsMaximumAmount =
1377 sendAmount > maximumAmount ||
1379 totalSendAmount > maximumAmount - sendAmount ||
1381 outstandingAmount > maximumAmount - sendAmount - totalSendAmount;
1383 if (exceedsMaximumAmount)
1385 totalSendAmount += sendAmount;
1393 if (sendAmount > maximumAmount ||
1394 outstandingAmount > maximumAmount - sendAmount)
1413 actual += actualSend;
1414 takeFromSender += actualSend;
1416 JLOG(j.
debug()) <<
"directSendNoLimitMultiMPT> " <<
to_string(senderID) <<
" - > "
1424 if (senderID != issuer && takeFromSender)
1446 "xrpl::accountSendMPT : minimum amount and MPT");
1451 if (!saAmount || (uSenderID == uReceiverID))
1457 view, uSenderID, uReceiverID, saAmount, saActual, j, waiveFee, allowOverflow);
1491 return directSendNoFeeIOU(view, uSenderID, uReceiverID, saAmount, bCheckIssuer, {}, j);
1494 XRPL_ASSERT(!bCheckIssuer,
"xrpl::directSendNoFee : not checking issuer");
1512 return accountSendIOU(view, uSenderID, uReceiverID, saAmount, j, sponsorSle, waiveFee);
1516 view, uSenderID, uReceiverID, saAmount, j, waiveFee, allowOverflow);
1530 receivers.
size() > 1,
"xrpl::accountSendMulti",
"multiple recipients provided");
1532 [&](
Issue const& issue) {
1548 XRPL_ASSERT(from !=
beast::kZero,
"xrpl::transferXRP : nonzero from account");
1549 XRPL_ASSERT(to !=
beast::kZero,
"xrpl::transferXRP : nonzero to account");
1550 XRPL_ASSERT(from != to,
"xrpl::transferXRP : sender is not receiver");
1551 XRPL_ASSERT(amount.
native(),
"xrpl::transferXRP : amount is XRP");
1555 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 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 > const & ref
std::shared_ptr< STLedgerEntry > pointer
std::shared_ptr< STLedgerEntry const > const & 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.
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)
SpendableHandling
Controls whether to include the account's full spendable balance.
TER checkIndividualFrozen(ReadView const &view, AccountID const &account, Asset const &asset)
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 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 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.
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 trustDelete(ApplyView &view, SLE::ref sleRippleState, AccountID const &uLowAccountID, AccountID const &uHighAccountID, beast::Journal j)
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.
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.
bool isDeepFrozen(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer)
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)
bool isGlobalFrozen(ReadView const &view, AccountID const &issuer)
Check if the issuer has the global freeze flag set.
TER canAddHolding(ReadView const &view, MPTIssue const &mptIssue)
static STAmount getTrustLineBalance(ReadView const &view, SLE::const_ref sle, AccountID const &account, Currency const ¤cy, AccountID const &issuer, bool includeOppositeLimit, beast::Journal j)
void removeSponsorFromLedgerEntry(SLE::ref sle, SF_ACCOUNT const &field=sfSponsor)
Remove the reserve sponsor field from a ledger entry.
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)
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.
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)
static TER accountSendIOU(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, beast::Journal j, SLE::ref sponsorSle, WaiveTransferFee waiveFee)
TER checkGlobalFrozen(ReadView const &view, Asset const &asset)
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)
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)
SLE::pointer getLedgerEntryReserveSponsor(ApplyView &view, SLE::const_ref sle, SF_ACCOUNT const &field=sfSponsor)
Return a mutable SLE for the reserve sponsor recorded on a ledger entry.
std::vector< std::pair< AccountID, Number > > MultiplePaymentDestinations
bool isPseudoAccount(SLE::const_pointer sleAcct, std::set< SField const * > const &pseudoFieldFilter={})
Returns true if and only if sleAcct is a pseudo-account or specific pseudo-accounts in pseudoFieldFil...
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 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 directSendNoFeeIOU(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, bool bCheckIssuer, SLE::ref sponsorSle, beast::Journal j)
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j, SpendableHandling includeFullBalance=SpendableHandling::SimpleBalance)
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.