1#include <xrpl/ledger/helpers/TokenHelpers.h>
3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/MathUtilities.h>
5#include <xrpl/basics/Number.h>
6#include <xrpl/beast/utility/Journal.h>
7#include <xrpl/beast/utility/Zero.h>
8#include <xrpl/beast/utility/instrumentation.h>
9#include <xrpl/ledger/ApplyView.h>
10#include <xrpl/ledger/ReadView.h>
11#include <xrpl/ledger/View.h>
12#include <xrpl/ledger/helpers/AccountRootHelpers.h>
13#include <xrpl/ledger/helpers/MPTokenHelpers.h>
14#include <xrpl/ledger/helpers/RippleStateHelpers.h>
15#include <xrpl/ledger/helpers/SponsorHelpers.h>
16#include <xrpl/protocol/AccountID.h>
17#include <xrpl/protocol/Asset.h>
18#include <xrpl/protocol/Concepts.h>
19#include <xrpl/protocol/Feature.h>
20#include <xrpl/protocol/Indexes.h>
21#include <xrpl/protocol/Issue.h>
22#include <xrpl/protocol/LedgerFormats.h>
23#include <xrpl/protocol/MPTAmount.h>
24#include <xrpl/protocol/MPTIssue.h>
25#include <xrpl/protocol/Protocol.h>
26#include <xrpl/protocol/Quality.h>
27#include <xrpl/protocol/Rate.h>
28#include <xrpl/protocol/SField.h>
29#include <xrpl/protocol/STAmount.h>
30#include <xrpl/protocol/STLedgerEntry.h>
31#include <xrpl/protocol/TER.h>
32#include <xrpl/protocol/UintTypes.h>
33#include <xrpl/protocol/XRPAmount.h>
85 [&](
auto const& issue) {
return isFrozen(view, account, issue, depth); }, asset.
value());
104 [&](
auto const& issue) {
return checkFrozen(view, account, issue); }, asset.
value());
139 return isFrozen(view, account, mptIssue, depth);
146 [&](
auto const& issue) {
return isDeepFrozen(view, account, issue, depth); },
173 "xrpl::checkWithdrawFreeze : source is a pseudo-account");
176 "xrpl::checkWithdrawFreeze : submitter is not a pseudo-account");
179 "xrpl::checkWithdrawFreeze : destination is not a pseudo-account");
183 "xrpl::checkWithdrawFreeze : asset issuer cannot be a pseudo-account");
200 if (submitterAcct != dstAcct)
214 UNREACHABLE(
"xrpl::checkWithdrawFreeze : pseudo-account backed object holds shares");
231 "xrpl::checkDepositFreeze : destination is a pseudo-account");
234 "xrpl::checkDepositFreeze : source is not a pseudo-account");
238 "xrpl::checkDepositFreeze : asset issuer cannot be a pseudo-account");
258 UNREACHABLE(
"xrpl::checkDepositFreeze : pseudo-account backed object holds shares");
290 if (
isFrozen(view, account, currency, issuer) ||
305 if (sleIssuer->isFieldPresent(sfAMMID))
310 isLPTokenFrozen(view, account, (*sleAmm)[sfAsset], (*sleAmm)[sfAsset2]))
337 bool includeOppositeLimit,
343 amount = sle->getFieldAmount(sfBalance);
344 bool const accountHigh = account > issuer;
345 auto const& oppositeField = accountHigh ? sfLowLimit : sfHighLimit;
351 if (includeOppositeLimit)
353 amount += sle->getFieldAmount(oppositeField);
355 amount.
get<
Issue>().account = issuer;
362 JLOG(j.
trace()) <<
"getTrustLineBalance:" <<
" account=" <<
to_string(account)
385 if (returnSpendable && account == issuer)
409 view, account, issue.
currency, issue.
account, zeroIfFrozen, j, includeFullBalance);
424 auto const& issuer = mptIssue.
getIssuer();
425 bool const mptokensV2 = view.
rules().
enabled(featureMPTokensV2);
427 if (returnSpendable && account == mptIssue.
getIssuer())
439 return STAmount{mptIssue, available};
448 amount.
clear(mptIssue);
452 amount =
STAmount{mptIssue, sleMpt->getFieldU64(sfMPTAmount)};
462 amount.
clear(mptIssue);
470 if (sleIssuance && sleIssuance->isFlag(lsfMPTRequireAuth) &&
471 !sleMpt->isFlag(lsfMPTAuthorized))
472 amount.
clear(mptIssue);
481[[nodiscard]] STAmount
492 [&](
Issue const& issue) {
493 return accountHolds(view, account, issue, zeroIfFrozen, j, includeFullBalance);
497 view, account, issue, zeroIfFrozen, zeroIfUnauthorized, j, includeFullBalance);
509 XRPL_ASSERT(saDefault.
holds<
Issue>(),
"xrpl::accountFunds: saDefault holds Issue");
528 [&](
Issue const&) {
return accountFunds(view,
id, saDefault, freezeHandling, j); },
590 if (!issuer->isFlag(lsfDefaultRipple))
672 return requireAuth(view, issue, account, authType);
688 return canTransfer(view, issue, from, to, waive, depth);
718 !bCheckIssuer || uSenderID == issuer || uReceiverID == issuer,
719 "xrpl::directSendNoFeeIOU : matching issuer or don't care");
723 XRPL_ASSERT(uSenderID != uReceiverID,
"xrpl::directSendNoFeeIOU : sender is not receiver");
725 bool const bSenderHigh = uSenderID > uReceiverID;
730 "xrpl::directSendNoFeeIOU : sender is not XRP");
733 "xrpl::directSendNoFeeIOU : receiver is not XRP");
736 if (
auto const sleRippleState = view.
peek(index))
738 STAmount saBalance = sleRippleState->getFieldAmount(sfBalance);
743 view.
creditHookIOU(uSenderID, uReceiverID, saAmount, saBalance);
745 STAmount const saBefore = saBalance;
747 saBalance -= saAmount;
749 JLOG(j.
trace()) <<
"directSendNoFeeIOU: " <<
to_string(uSenderID) <<
" -> "
754 bool bDelete =
false;
756 auto const senderReserveFlag = bSenderHigh ? lsfHighReserve : lsfLowReserve;
757 auto const senderNoRippleFlag = bSenderHigh ? lsfHighNoRipple : lsfLowNoRipple;
758 auto const senderFreezeFlag = bSenderHigh ? lsfHighFreeze : lsfLowFreeze;
759 auto const receiverReserveFlag = bSenderHigh ? lsfLowReserve : lsfHighReserve;
767 && sleRippleState->isFlag(senderReserveFlag)
769 && sleRippleState->isFlag(senderNoRippleFlag) !=
771 !sleRippleState->isFlag(senderFreezeFlag) &&
772 !sleRippleState->getFieldAmount(bSenderHigh ? sfHighLimit : sfLowLimit)
774 && (sleRippleState->getFieldU32(bSenderHigh ? sfHighQualityIn : sfLowQualityIn) == 0u)
777 (sleRippleState->getFieldU32(bSenderHigh ? sfHighQualityOut : sfLowQualityOut) == 0u))
782 view, sleRippleState, !bSenderHigh ? sfLowSponsor : sfHighSponsor);
786 sleRippleState, !bSenderHigh ? sfLowSponsor : sfHighSponsor);
789 sleRippleState->clearFlag(senderReserveFlag);
793 && !sleRippleState->isFlag(receiverReserveFlag);
801 sleRippleState->setFieldAmount(sfBalance, saBalance);
809 bSenderHigh ? uReceiverID : uSenderID,
810 bSenderHigh ? uSenderID : uReceiverID,
814 view.
update(sleRippleState);
818 STAmount const saReceiverLimit(
Issue{currency, uReceiverID});
823 JLOG(j.
debug()) <<
"directSendNoFeeIOU: "
832 bool const noRipple = !sleAccount->isFlag(lsfDefaultRipple);
867 auto const& issuer = saAmount.
getIssuer();
871 "xrpl::directSendNoLimitIOU : neither sender nor receiver is XRP");
872 XRPL_ASSERT(uSenderID != uReceiverID,
"xrpl::directSendNoLimitIOU : sender is not receiver");
874 if (uSenderID == issuer || uReceiverID == issuer || issuer ==
noAccount())
892 JLOG(j.
debug()) <<
"directSendNoLimitIOU> " <<
to_string(uSenderID) <<
" - > "
900 terResult =
directSendNoFeeIOU(view, uSenderID, issuer, saActual,
true, sponsorSle, j);
921 XRPL_ASSERT(!
isXRP(senderID),
"xrpl::directSendNoLimitMultiIOU : sender is not XRP");
925 actual = takeFromSender;
928 for (
auto const& r : receivers)
930 auto const& receiverID = r.first;
931 STAmount const amount{issue, r.second};
936 if (!amount || (senderID == receiverID))
939 XRPL_ASSERT(!
isXRP(receiverID),
"xrpl::directSendNoLimitMultiIOU : receiver is not XRP");
941 if (senderID == issuer || receiverID == issuer || issuer ==
noAccount())
962 actual += actualSend;
963 takeFromSender += actualSend;
965 JLOG(j.
debug()) <<
"directSendNoLimitMultiIOU> " <<
to_string(senderID) <<
" - > "
973 if (senderID != issuer && takeFromSender)
975 if (
TER const terResult =
996 JLOG(j.
fatal()) <<
"accountSendIOU: negative amount or invalid asset";
1004 if (!saAmount || (uSenderID == uReceiverID))
1011 JLOG(j.
trace()) <<
"accountSendIOU: " <<
to_string(uSenderID) <<
" -> "
1015 view, uSenderID, uReceiverID, saAmount, saActual, j, sponsorSle, waiveFee);
1030 if (
auto const stream = j.
trace())
1041 stream <<
"accountSendIOU> " <<
to_string(uSenderID) <<
" (" << senderBal <<
") -> "
1076 if (
auto const stream = j.
trace())
1087 stream <<
"accountSendIOU< " <<
to_string(uSenderID) <<
" (" << senderBal <<
") -> "
1104 receivers.
size() > 1,
"xrpl::accountSendMultiIOU",
"multiple recipients provided");
1109 JLOG(j.
trace()) <<
"accountSendMultiIOU: " <<
to_string(senderID) <<
" sending "
1110 << receivers.
size() <<
" IOUs";
1124 if (
auto const stream = j.
trace())
1131 stream <<
"accountSendMultiIOU> " <<
to_string(senderID) <<
" (" << senderBal <<
") -> "
1132 << receivers.
size() <<
" receivers.";
1137 for (
auto const& r : receivers)
1139 auto const& receiverID = r.first;
1140 STAmount const amount{issue, r.second};
1150 if (!amount || (senderID == receiverID))
1156 if (
auto const stream = j.
trace())
1163 stream <<
"accountSendMultiIOU> " <<
to_string(senderID) <<
" -> "
1164 <<
to_string(receiverID) <<
" (" << receiverBal
1182 takeFromSender += amount;
1185 if (
auto const stream = j.
trace())
1192 stream <<
"accountSendMultiIOU< " <<
to_string(senderID) <<
" -> "
1193 <<
to_string(receiverID) <<
" (" << receiverBal
1212 if (
auto const stream = j.
trace())
1219 stream <<
"accountSendMultiIOU< " <<
to_string(senderID) <<
" (" << senderBal <<
") -> "
1220 << receivers.
size() <<
" receivers.";
1235 auto const& issuer = saAmount.
getIssuer();
1236 auto const sleIssuance = view.
peek(mptID);
1241 auto const outstanding = sleIssuance->getFieldU64(sfOutstandingAmount);
1243 auto const amt = saAmount.
mpt().
value();
1245 if (uSenderID == issuer)
1252 (*sleIssuance)[sfOutstandingAmount] += amt;
1253 view.
update(sleIssuance);
1258 if (
auto const sle = view.
peek(mptokenID))
1260 auto const senderBalance = sle->getFieldU64(sfMPTAmount);
1261 if (senderBalance < amt)
1263 view.
creditHookMPT(uSenderID, uReceiverID, saAmount, (*sle)[sfMPTAmount], available);
1264 (*sle)[sfMPTAmount] = senderBalance - amt;
1273 if (uReceiverID == issuer)
1275 if (outstanding >= amt)
1277 sleIssuance->setFieldU64(sfOutstandingAmount, outstanding - amt);
1278 view.
update(sleIssuance);
1288 if (
auto const sle = view.
peek(mptokenID))
1297 view.
creditHookMPT(uSenderID, uReceiverID, saAmount, (*sle)[sfMPTAmount], available);
1298 (*sle)[sfMPTAmount] += amt;
1321 XRPL_ASSERT(uSenderID != uReceiverID,
"xrpl::directSendNoLimitMPT : sender is not receiver");
1324 auto const& issuer = saAmount.
getIssuer();
1330 if (uSenderID == issuer || uReceiverID == issuer)
1334 if (uSenderID == issuer)
1336 auto const sendAmount = saAmount.
mpt().
value();
1338 auto const outstanding = sle->getFieldU64(sfOutstandingAmount);
1339 auto const mptokensV2 = view.
rules().
enabled(featureMPTokensV2);
1343 if (
isMPTOverflow(sendAmount, outstanding, maxAmount, allowOverflow))
1351 saActual = saAmount;
1358 saActual = saAmount;
1372 saActual =
multiply(saAmount, rate);
1376 JLOG(j.
debug()) <<
"directSendNoLimitMPT> " <<
to_string(uSenderID) <<
" - > "
1380 if (
auto const terResult =
directSendNoFeeMPT(view, issuer, uReceiverID, saAmount, j);
1397 auto const& issuer = mptIssue.
getIssuer();
1412 std::uint64_t const outstandingAmount = sle->getFieldU64(sfOutstandingAmount);
1419 actual = takeFromSender;
1421 for (
auto const& [receiverID, amt] : receivers)
1423 STAmount const amount{mptIssue, amt};
1428 if (!amount || senderID == receiverID)
1431 if (senderID == issuer || receiverID == issuer)
1433 if (senderID == issuer)
1437 "xrpl::directSendNoLimitMultiMPT",
1438 "sender == issuer, takeFromSender == zero");
1448 bool const exceedsMaximumAmount =
1450 sendAmount > maximumAmount ||
1452 totalSendAmount > maximumAmount - sendAmount ||
1454 outstandingAmount > maximumAmount - sendAmount - totalSendAmount;
1456 if (exceedsMaximumAmount)
1458 totalSendAmount += sendAmount;
1466 if (sendAmount > maximumAmount ||
1467 outstandingAmount > maximumAmount - sendAmount)
1498 actualSend =
multiply(amount, rate);
1505 actual += actualSend;
1506 takeFromSender += actualSend;
1508 JLOG(j.
debug()) <<
"directSendNoLimitMultiMPT> " <<
to_string(senderID) <<
" - > "
1516 if (senderID != issuer && takeFromSender)
1538 "xrpl::accountSendMPT : minimum amount and MPT");
1543 if (!saAmount || (uSenderID == uReceiverID))
1549 view, uSenderID, uReceiverID, saAmount, saActual, j, waiveFee, allowOverflow);
1583 return directSendNoFeeIOU(view, uSenderID, uReceiverID, saAmount, bCheckIssuer, {}, j);
1586 XRPL_ASSERT(!bCheckIssuer,
"xrpl::directSendNoFee : not checking issuer");
1604 return accountSendIOU(view, uSenderID, uReceiverID, saAmount, j, sponsorSle, waiveFee);
1608 view, uSenderID, uReceiverID, saAmount, j, waiveFee, allowOverflow);
1622 receivers.
size() > 1,
"xrpl::accountSendMulti",
"multiple recipients provided");
1624 [&](
Issue const& issue) {
1640 XRPL_ASSERT(from !=
beast::kZero,
"xrpl::transferXRP : nonzero from account");
1641 XRPL_ASSERT(to !=
beast::kZero,
"xrpl::transferXRP : nonzero to account");
1642 XRPL_ASSERT(from != to,
"xrpl::transferXRP : sender is not receiver");
1643 XRPL_ASSERT(amount.
native(),
"xrpl::transferXRP : amount is XRP");
1647 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
constexpr value_type drops() const
Returns the number of drops.
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)
MaximumAmount doesn't exceed 2**63-1.
constexpr std::optional< std::int64_t > checkedAdd(std::int64_t a, std::int64_t b) noexcept
Add two signed 64-bit integers, returning std::nullopt when the exact mathematical sum is not represe...
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.
STAmount subtractTransferFee(STAmount const &amount, Rate const &rate)
Returns the amount a receiver gets when amount leaves the sender and the issuer takes the transfer fe...
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.
IOUAmount mulRatio(IOUAmount const &amt, std::uint32_t num, std::uint32_t den, bool roundUp)
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)
Rate const kParityRate
A transfer rate signifying a 1:1 exchange.
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)
OutstandingAmount may overflow and available amount might be negative.
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)
STAmount addTransferFee(STAmount const &amount, Rate const &rate)
Returns the amount a sender must part with for amount to reach the receiver once the issuer takes the...
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.
Represents a transfer rate.