xrpld
Loading...
Searching...
No Matches
EscrowHelpers.h
1#pragma once
2
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/helpers/AccountRootHelpers.h>
10#include <xrpl/ledger/helpers/MPTokenHelpers.h>
11#include <xrpl/ledger/helpers/RippleStateHelpers.h>
12#include <xrpl/ledger/helpers/SponsorHelpers.h>
13#include <xrpl/ledger/helpers/TokenHelpers.h>
14#include <xrpl/protocol/AccountID.h>
15#include <xrpl/protocol/Concepts.h>
16#include <xrpl/protocol/Feature.h>
17#include <xrpl/protocol/Fees.h>
18#include <xrpl/protocol/Indexes.h>
19#include <xrpl/protocol/Issue.h>
20#include <xrpl/protocol/Keylet.h>
21#include <xrpl/protocol/LedgerFormats.h>
22#include <xrpl/protocol/MPTAmount.h>
23#include <xrpl/protocol/MPTIssue.h>
24#include <xrpl/protocol/Rate.h>
25#include <xrpl/protocol/SField.h>
26#include <xrpl/protocol/STAmount.h>
27#include <xrpl/protocol/STLedgerEntry.h>
28#include <xrpl/protocol/TER.h>
29#include <xrpl/protocol/UintTypes.h>
30
31#include <cstdint>
32
33namespace xrpl {
34
46template <ValidIssueType T>
47TER
49 ReadView const& view,
50 AccountID const& account,
51 AccountID const& dest,
52 STAmount const& amount,
54
55template <>
56inline TER
58 ReadView const& view,
59 AccountID const& account,
60 AccountID const& dest,
61 STAmount const& amount,
63{
64 auto const& issue = amount.get<Issue>();
65 auto const& issuer = amount.getIssuer();
66 // If the issuer is the same as the account, return tecNO_PERMISSION
67 if (issuer == account)
68 return tecNO_PERMISSION;
69
70 // If the lsfAllowTrustLineLocking is not enabled, return tecNO_PERMISSION
71 auto const sleIssuer = view.read(keylet::account(issuer));
72 if (!sleIssuer)
73 return tecNO_ISSUER;
74 if (!sleIssuer->isFlag(lsfAllowTrustLineLocking))
75 return tecNO_PERMISSION;
76
77 // If the account does not have a trustline to the issuer, return tecNO_LINE
78 auto const sleRippleState = view.read(keylet::trustLine(account, issuer, issue.currency));
79 if (!sleRippleState)
80 return tecNO_LINE;
81
82 STAmount const balance = (*sleRippleState)[sfBalance];
83
84 // If balance is positive, issuer must have higher address than account
85 if (balance > beast::kZero && issuer < account)
86 return tecNO_PERMISSION; // LCOV_EXCL_LINE
87
88 // If balance is negative, issuer must have lower address than account
89 if (balance < beast::kZero && issuer > account)
90 return tecNO_PERMISSION; // LCOV_EXCL_LINE
91
92 // If the issuer has requireAuth set, check if the account is authorized
93 if (auto const ter = requireAuth(view, issue, account); !isTesSuccess(ter))
94 return ter;
95
96 // If the issuer has requireAuth set, check if the destination is authorized
97 if (auto const ter = requireAuth(view, issue, dest); !isTesSuccess(ter))
98 return ter;
99
100 // If the issuer has frozen the account, return tecFROZEN
101 if (isFrozen(view, account, issue))
102 return tecFROZEN;
103
104 // If the issuer has frozen the destination, return tecFROZEN
105 if (isFrozen(view, dest, issue))
106 return tecFROZEN;
107
108 STAmount const spendableAmount =
109 accountHolds(view, account, issue.currency, issuer, FreezeHandling::IgnoreFreeze, j);
110
111 // If the balance is less than or equal to 0, return tecINSUFFICIENT_FUNDS
112 if (spendableAmount <= beast::kZero)
114
115 // If the spendable amount is less than the amount, return
116 // tecINSUFFICIENT_FUNDS
117 if (spendableAmount < amount)
119
120 // If the amount is not addable to the balance, return tecPRECISION_LOSS
121 if (!canAdd(spendableAmount, amount))
122 return tecPRECISION_LOSS;
123
124 return tesSUCCESS;
125}
126
127template <>
128inline TER
130 ReadView const& view,
131 AccountID const& account,
132 AccountID const& dest,
133 STAmount const& amount,
135{
136 AccountID const issuer = amount.getIssuer();
137 // If the issuer is the same as the account, return tecNO_PERMISSION
138 if (issuer == account)
139 return tecNO_PERMISSION;
140
141 // If the mpt does not exist, return tecOBJECT_NOT_FOUND
142 auto const issuanceKey = keylet::mptokenIssuance(amount.get<MPTIssue>().getMptID());
143 auto const sleIssuance = view.read(issuanceKey);
144 if (!sleIssuance)
145 return tecOBJECT_NOT_FOUND;
146
147 // If the lsfMPTCanEscrow is not enabled, return tecNO_PERMISSION
148 if (!sleIssuance->isFlag(lsfMPTCanEscrow))
149 return tecNO_PERMISSION;
150
151 // If the issuer is not the same as the issuer of the mpt, return
152 // tecNO_PERMISSION
153 if (sleIssuance->getAccountID(sfIssuer) != issuer)
154 return tecNO_PERMISSION; // LCOV_EXCL_LINE
155
156 // If the account does not have the mpt, return tecOBJECT_NOT_FOUND
157 if (!view.exists(keylet::mptoken(issuanceKey.key, account)))
158 return tecOBJECT_NOT_FOUND;
159
160 // If the issuer has requireAuth set, check if the account is
161 // authorized
162 auto const& mptIssue = amount.get<MPTIssue>();
163 if (auto const ter = requireAuth(view, mptIssue, account, AuthType::WeakAuth);
164 !isTesSuccess(ter))
165 return ter;
166
167 // If the issuer has requireAuth set, check if the destination is
168 // authorized
169 if (auto const ter = requireAuth(view, mptIssue, dest, AuthType::WeakAuth); !isTesSuccess(ter))
170 return ter;
171
172 // If the issuer has frozen the account, return tecLOCKED
173 if (isFrozen(view, account, *sleIssuance))
174 return tecLOCKED;
175
176 // If the issuer has frozen the destination, return tecLOCKED
177 if (isFrozen(view, dest, *sleIssuance))
178 return tecLOCKED;
179
180 // If the mpt cannot be transferred, return tecNO_AUTH
181 if (auto const ter = canTransfer(view, mptIssue, account, dest); !isTesSuccess(ter))
182 return ter;
183
184 STAmount const spendableAmount = accountHolds(
185 view,
186 account,
187 amount.get<MPTIssue>(),
190 j);
191
192 // If the balance is less than or equal to 0, return tecINSUFFICIENT_FUNDS
193 if (spendableAmount <= beast::kZero)
195
196 // If the spendable amount is less than the amount, return
197 // tecINSUFFICIENT_FUNDS
198 if (spendableAmount < amount)
200
201 return tesSUCCESS;
202}
203
204template <ValidIssueType T>
205TER
207 ApplyView& view,
208 AccountID const& issuer,
209 AccountID const& sender,
210 STAmount const& amount,
211 beast::Journal journal);
212
213template <>
214inline TER
216 ApplyView& view,
217 AccountID const& issuer,
218 AccountID const& sender,
219 STAmount const& amount,
220 beast::Journal journal)
221{
222 // Defensive: Issuer cannot create an escrow
223 if (issuer == sender)
224 return tecINTERNAL; // LCOV_EXCL_LINE
225
226 auto const ter =
227 directSendNoFee(view, sender, issuer, amount, !amount.holds<MPTIssue>(), journal);
228 if (!isTesSuccess(ter))
229 return ter; // LCOV_EXCL_LINE
230 return tesSUCCESS;
231}
232
233template <>
234inline TER
236 ApplyView& view,
237 AccountID const& issuer,
238 AccountID const& sender,
239 STAmount const& amount,
240 beast::Journal journal)
241{
242 // Defensive: Issuer cannot create an escrow
243 if (issuer == sender)
244 return tecINTERNAL; // LCOV_EXCL_LINE
245
246 auto const ter = lockEscrowMPT(view, sender, amount, journal);
247 if (!isTesSuccess(ter))
248 return ter; // LCOV_EXCL_LINE
249 return tesSUCCESS;
250}
251
252template <ValidIssueType T>
253TER
255 ReadView const& view,
256 AccountID const& account,
257 STAmount const& amount,
258 bool checkFreeze = true);
259
260template <>
261inline TER
263 ReadView const& view,
264 AccountID const& account,
265 STAmount const& amount,
266 bool checkFreeze)
267{
268 AccountID const& issuer = amount.getIssuer();
269 // If the issuer is the same as the account, return tesSUCCESS
270 if (issuer == account)
271 return tesSUCCESS;
272
273 // If the issuer has requireAuth set, check if the destination is authorized
274 if (auto const ter = requireAuth(view, amount.get<Issue>(), account); !isTesSuccess(ter))
275 return ter;
276
277 // If the issuer has deep frozen the destination, return tecFROZEN
278 if (checkFreeze &&
279 isDeepFrozen(view, account, amount.get<Issue>().currency, amount.getIssuer()))
280 return tecFROZEN;
281
282 return tesSUCCESS;
283}
284
285template <>
286inline TER
288 ReadView const& view,
289 AccountID const& account,
290 STAmount const& amount,
291 bool checkFreeze)
292{
293 AccountID const& issuer = amount.getIssuer();
294 // If the issuer is the same as the account, return tesSUCCESS
295 if (issuer == account)
296 return tesSUCCESS;
297
298 // If the mpt does not exist, return tecOBJECT_NOT_FOUND
299 auto const issuanceKey = keylet::mptokenIssuance(amount.get<MPTIssue>().getMptID());
300 auto const sleIssuance = view.read(issuanceKey);
301 if (!sleIssuance)
302 return tecOBJECT_NOT_FOUND;
303
304 // If the issuer has requireAuth set, check if the account is
305 // authorized
306 auto const& mptIssue = amount.get<MPTIssue>();
307 if (auto const ter = requireAuth(view, mptIssue, account, AuthType::WeakAuth);
308 !isTesSuccess(ter))
309 return ter;
310
311 // If the issuer has frozen the account, return tecLOCKED
312 if (checkFreeze && isFrozen(view, account, *sleIssuance))
313 return tecLOCKED;
314
315 return tesSUCCESS;
316}
317
318//------------------------------------------------------------------------------
319
320template <ValidIssueType T>
321TER
324 Rate lockedRate,
325 SLE::Ref sleDest,
326 XRPAmount xrpBalance,
327 STAmount const& amount,
328 AccountID const& issuer,
329 AccountID const& sender,
330 AccountID const& receiver,
331 bool createAsset,
332 beast::Journal journal);
333
334template <>
335inline TER
338 Rate lockedRate,
339 SLE::Ref sleDest,
340 XRPAmount xrpBalance,
341 STAmount const& amount,
342 AccountID const& issuer,
343 AccountID const& sender,
344 AccountID const& receiver,
345 bool createAsset,
346 beast::Journal journal)
347{
348 bool const senderIssuer = issuer == sender;
349 bool const receiverIssuer = issuer == receiver;
350
351 if (senderIssuer)
352 return tecINTERNAL; // LCOV_EXCL_LINE
353
354 if (receiverIssuer)
355 return tesSUCCESS;
356
357 auto const& issue = amount.get<Issue>();
358 Keylet const trustLineKey = keylet::trustLine(receiver, issue);
359 bool const recvLow = issuer > receiver;
360
361 if (!ctx.view.exists(trustLineKey) && createAsset)
362 {
363 // Can the account cover the trust line's reserve?
364 auto const sponsorSle = getEffectiveTxReserveSponsor(ctx, sleDest);
365 if (!sponsorSle)
366 return sponsorSle.error(); // LCOV_EXCL_LINE
367
368 if (auto const ret = checkReserve(
369 ctx,
370 sleDest,
371 xrpBalance,
372 *sponsorSle,
373 {.ownerCountDelta = 1},
374 journal,
376 !isTesSuccess(ret))
377 {
378 JLOG(journal.trace()) << "Trust line does not exist. "
379 "Insufficient reserve to create line.";
380 return ret;
381 }
382
383 Currency const currency = issue.currency;
384 STAmount initialBalance(issue);
385 initialBalance.get<Issue>().account = noAccount();
386
387 if (TER const ter = trustCreate(
388 ctx.view, // payment sandbox
389 recvLow, // is dest low?
390 issuer, // source
391 receiver, // destination
392 trustLineKey.key, // ledger index
393 sleDest, // Account to add to
394 false, // authorize account
395 !sleDest->isFlag(lsfDefaultRipple), //
396 false, // freeze trust line
397 false, // deep freeze trust line
398 initialBalance, // zero initial balance
399 Issue(currency, receiver), // limit of zero
400 0, // quality in
401 0, // quality out
402 *sponsorSle, // sponsor
403 journal); // journal
404 !isTesSuccess(ter))
405 {
406 return ter; // LCOV_EXCL_LINE
407 }
408
409 ctx.view.update(sleDest);
410 }
411
412 if (!ctx.view.exists(trustLineKey) && !receiverIssuer)
413 return tecNO_LINE;
414
415 auto const xferRate = transferRate(ctx.view, amount);
416 // update if issuer rate is less than locked rate
417 if (xferRate < lockedRate)
418 lockedRate = xferRate;
419
420 // Transfer Rate only applies when:
421 // 1. Issuer is not involved in the transfer (senderIssuer or
422 // receiverIssuer)
423 // 2. The locked rate is different from the parity rate
424
425 // NOTE: Transfer fee in escrow works a bit differently from a normal
426 // payment. In escrow, the fee is deducted from the locked/sending amount,
427 // whereas in a normal payment, the transfer fee is taken on top of the
428 // sending amount.
429 auto finalAmt = amount;
430 if ((!senderIssuer && !receiverIssuer) && lockedRate != kParityRate)
431 {
432 // compute transfer fee, if any
433 auto const xferFee =
434 amount.value() - divideRound(amount, lockedRate, amount.get<Issue>(), true);
435 // compute balance to transfer
436 finalAmt = amount.value() - xferFee;
437 }
438
439 // validate the line limit if the account submitting txn is not the receiver
440 // of the funds
441 if (!createAsset)
442 {
443 auto const sleRippleState = ctx.view.peek(trustLineKey);
444 if (!sleRippleState)
445 return tecINTERNAL; // LCOV_EXCL_LINE
446
447 // if the issuer is the high, then we use the low limit
448 // otherwise we use the high limit
449 STAmount const lineLimit =
450 sleRippleState->getFieldAmount(recvLow ? sfLowLimit : sfHighLimit);
451
452 STAmount lineBalance = sleRippleState->getFieldAmount(sfBalance);
453
454 // flip the sign of the line balance if the issuer is not high
455 if (!recvLow)
456 lineBalance.negate();
457
458 // add the final amount to the line balance
459 lineBalance += finalAmt;
460
461 // if the transfer would exceed the line limit return tecLIMIT_EXCEEDED
462 if (lineLimit < lineBalance)
463 return tecLIMIT_EXCEEDED;
464 }
465
466 // if destination is not the issuer then transfer funds
467 if (!receiverIssuer)
468 {
469 auto const ter = directSendNoFee(ctx.view, issuer, receiver, finalAmt, true, journal);
470 if (!isTesSuccess(ter))
471 return ter; // LCOV_EXCL_LINE
472 }
473 return tesSUCCESS;
474}
475
476template <>
477inline TER
480 Rate lockedRate,
481 SLE::Ref sleDest,
482 XRPAmount xrpBalance,
483 STAmount const& amount,
484 AccountID const& issuer,
485 AccountID const& sender,
486 AccountID const& receiver,
487 bool createAsset,
488 beast::Journal journal)
489{
490 bool const senderIssuer = issuer == sender;
491 bool const receiverIssuer = issuer == receiver;
492
493 auto const mptID = amount.get<MPTIssue>().getMptID();
494 auto const issuanceKey = keylet::mptokenIssuance(mptID);
495 auto const mptKeylet = keylet::mptoken(issuanceKey.key, receiver);
496 if (!ctx.view.exists(mptKeylet) && createAsset && !receiverIssuer)
497 {
498 auto const sponsorSle = getEffectiveTxReserveSponsor(ctx, sleDest);
499 if (!sponsorSle)
500 return sponsorSle.error(); // LCOV_EXCL_LINE
501
502 if (auto const ret = checkReserve(
503 ctx, sleDest, xrpBalance, *sponsorSle, {.ownerCountDelta = 1}, journal);
504 !isTesSuccess(ret))
505 return ret;
506
507 if (auto const ter = createMPToken(ctx.view, mptID, receiver, *sponsorSle, 0);
508 !isTesSuccess(ter))
509 {
510 return ter; // LCOV_EXCL_LINE
511 }
512
513 // update owner count.
514 increaseOwnerCount(ctx.view, sleDest, *sponsorSle, 1, journal);
515 }
516
517 if (!ctx.view.exists(mptKeylet) && !receiverIssuer)
518 return tecNO_PERMISSION;
519
520 auto const xferRate = transferRate(ctx.view, amount);
521 // update if issuer rate is less than locked rate
522 if (xferRate < lockedRate)
523 lockedRate = xferRate;
524
525 // Transfer Rate only applies when:
526 // 1. Issuer is not involved in the transfer (senderIssuer or
527 // receiverIssuer)
528 // 2. The locked rate is different from the parity rate
529
530 // NOTE: Transfer fee in escrow works a bit differently from a normal
531 // payment. In escrow, the fee is deducted from the locked/sending amount,
532 // whereas in a normal payment, the transfer fee is taken on top of the
533 // sending amount.
534 auto finalAmt = amount;
535 if ((!senderIssuer && !receiverIssuer) && lockedRate != kParityRate)
536 {
537 if (ctx.view.rules().enabled(fixCleanup3_4_0))
538 {
539 XRPL_ASSERT(
540 lockedRate >= kParityRate,
541 "xrpl::escrowUnlockApplyHelper<MPTIssue> : lockedRate is at least parity");
542 // MPTs are integral, so round the delivered amount down and
543 // charge any fractional transfer fee to the escrowed amount.
544 auto const delivered =
545 mulRatio(amount.mpt(), kParityRate.value, lockedRate.value, false);
546 finalAmt = STAmount(amount.asset(), delivered.value());
547 }
548 else
549 {
550 // compute transfer fee, if any
551 auto const xferFee =
552 amount.value() - divideRound(amount, lockedRate, amount.asset(), true);
553 // compute balance to transfer
554 finalAmt = amount.value() - xferFee;
555 }
556 }
557 return unlockEscrowMPT(
558 ctx.view,
559 sender,
560 receiver,
561 finalAmt,
562 ctx.view.rules().enabled(fixTokenEscrowV1) ? amount : finalAmt,
563 journal);
564}
565
574inline bool
576{
577 return fees.bytecodeSizeLimit == 0 || fees.gasLimit == 0;
578}
579
580inline bool
582{
583 return fees.gasLimit == 0;
584}
585
586
593template <class T>
594int32_t
595calculateAdditionalReserve(T const& finishFunction)
596{
597 static auto constexpr kBytecodeReserveIncrement = 500;
598
599 if (!finishFunction)
600 return 1;
601
602 auto const size = finishFunction->size();
603 if (size == 0)
604 {
605 // LCOV_EXCL_START
606 // Empty Bytecode is refused at create, so no escrow carries it. Ceiling
607 // division would answer 0, which would subtract less than the create added.
608 UNREACHABLE("xrpl::calculateAdditionalReserve : empty Bytecode");
609 return 1;
610 // LCOV_EXCL_STOP
611 }
612
613 return static_cast<int32_t>((size + kBytecodeReserveIncrement - 1) / kBytecodeReserveIncrement);
614}
615
616} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:44
Stream trace() const
Severity stream access functions.
Definition Journal.h:338
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:141
virtual SLE::pointer peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
virtual void update(SLE::Ref sle)=0
Indicate changes to a peeked SLE.
constexpr value_type const & value() const
Definition Asset.h:201
A currency issued by an account.
Definition Issue.h:18
Currency currency
Definition Issue.h:20
constexpr MPTID const & getMptID() const
Definition MPTIssue.h:43
A view into a ledger.
Definition ReadView.h:41
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 SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
bool enabled(UInt256 const &feature) const
Returns true if a feature is enabled.
Definition Rules.cpp:182
constexpr bool holds() const noexcept
Definition STAmount.h:478
constexpr TIss const & get() const
void negate()
Definition STAmount.h:586
Asset const & asset() const
Definition STAmount.h:496
AccountID const & getIssuer() const
Definition STAmount.h:516
STAmount const & value() const noexcept
Definition STAmount.h:610
std::shared_ptr< STLedgerEntry > const & Ref
constexpr Zero kZero
Definition Zero.h:30
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Definition Indexes.cpp:547
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:233
Keylet mptokenIssuance(MPTID const &issuanceID) noexcept
Definition Indexes.cpp:541
Keylet trustLine(AccountID const &id0, AccountID const &id1, Currency const &currency) noexcept
The index of a trust line for a given currency.
Definition Indexes.cpp:287
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
int32_t calculateAdditionalReserve(T const &finishFunction)
Owner count an escrow costs.
TER escrowUnlockPreclaimHelper< MPTIssue >(ReadView const &view, AccountID const &account, STAmount const &amount, bool checkFreeze)
TER escrowUnlockPreclaimHelper< Issue >(ReadView const &view, AccountID const &account, STAmount const &amount, bool checkFreeze)
TER escrowUnlockApplyHelper(ApplyViewContext ctx, Rate lockedRate, SLE::Ref sleDest, XRPAmount xrpBalance, STAmount const &amount, AccountID const &issuer, AccountID const &sender, AccountID const &receiver, bool createAsset, beast::Journal journal)
bool isBytecodeExecutionDisabled(Fees const &fees)
TER lockEscrowMPT(ApplyView &view, AccountID const &uGrantorID, STAmount const &saAmount, beast::Journal j)
BaseUInt< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition UintTypes.h:42
TER escrowLockApplyHelper(ApplyView &view, AccountID const &issuer, AccountID const &sender, STAmount const &amount, beast::Journal journal)
TER checkReserve(ApplyViewContext ctx, SLE::ConstRef accSle, XRPAmount accBalance, SLE::ConstRef sponsorSle, Adjustment adj, beast::Journal j, TER insufReserveCode=tecINSUFFICIENT_RESERVE)
Check if an account has sufficient reserve.
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 unlockEscrowMPT(ApplyView &view, AccountID const &uGrantorID, AccountID const &uGranteeID, STAmount const &netAmount, STAmount const &grossAmount, beast::Journal j)
std::expected< SLE::pointer, TER > getEffectiveTxReserveSponsor(ApplyViewContext ctx, SLE::ConstRef accountSle)
The transaction's reserve sponsor for the given account, if applicable.
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.
void increaseOwnerCount(ApplyView &view, SLE::Ref accountSle, SLE::Ref sponsorSle, std::uint32_t count, beast::Journal j)
Increase owner-count fields when the caller supplies the sponsor.
bool isDeepFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
bool canAdd(STAmount const &amt1, STAmount const &amt2)
Safely checks if two STAmount values can be added without overflow, underflow, or precision loss.
TER escrowLockApplyHelper< MPTIssue >(ApplyView &view, AccountID const &issuer, AccountID const &sender, STAmount const &amount, beast::Journal journal)
IOUAmount mulRatio(IOUAmount const &amt, std::uint32_t num, std::uint32_t den, bool roundUp)
TER escrowUnlockPreclaimHelper(ReadView const &view, AccountID const &account, STAmount const &amount, bool checkFreeze=true)
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
Rate const kParityRate
A transfer rate signifying a 1:1 exchange.
TER checkFreeze(ReadView const &view, AccountID const &src, AccountID const &dst, Currency const &currency)
Definition StepChecks.h:19
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.
TER escrowLockPreclaimHelper< MPTIssue >(ReadView const &view, AccountID const &account, AccountID const &dest, STAmount const &amount, beast::Journal j)
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.
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:34
AccountID const & noAccount()
A placeholder for empty accounts.
TER escrowLockPreclaimHelper< Issue >(ReadView const &view, AccountID const &account, AccountID const &dest, STAmount const &amount, beast::Journal j)
TER escrowLockPreclaimHelper(ReadView const &view, AccountID const &account, AccountID const &dest, STAmount const &amount, beast::Journal j)
Validate that account may lock amount of a token for later delivery to dest.
bool isTesSuccess(TER x) noexcept
Definition TER.h:686
TERSubset< CanCvtToTER > TER
Definition TER.h:657
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.
@ tecLOCKED
Definition TER.h:369
@ tecNO_LINE_INSUF_RESERVE
Definition TER.h:303
@ tecOBJECT_NOT_FOUND
Definition TER.h:337
@ tecINTERNAL
Definition TER.h:321
@ tecFROZEN
Definition TER.h:314
@ tecINSUFFICIENT_FUNDS
Definition TER.h:336
@ tecNO_LINE
Definition TER.h:312
@ tecPRECISION_LOSS
Definition TER.h:374
@ tecLIMIT_EXCEEDED
Definition TER.h:372
@ tecNO_PERMISSION
Definition TER.h:316
@ tecNO_ISSUER
Definition TER.h:310
TER escrowLockApplyHelper< Issue >(ApplyView &view, AccountID const &issuer, AccountID const &sender, STAmount const &amount, beast::Journal journal)
TER createMPToken(ApplyView &view, MPTID const &mptIssuanceID, AccountID const &account, SLE::Ref sponsorSle, std::uint32_t const flags)
bool isBytecodeUploadDisabled(Fees const &fees)
Smart escrow kill switches, driven by the voted FeeSettings.
STAmount divideRound(STAmount const &amount, Rate const &rate, bool roundUp)
Definition Rate2.cpp:80
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j, SpendableHandling includeFullBalance=SpendableHandling::SimpleBalance)
@ tesSUCCESS
Definition TER.h:253
TER escrowUnlockApplyHelper< Issue >(ApplyViewContext ctx, Rate lockedRate, SLE::Ref sleDest, XRPAmount xrpBalance, STAmount const &amount, AccountID const &issuer, AccountID const &sender, AccountID const &receiver, bool createAsset, beast::Journal journal)
TER escrowUnlockApplyHelper< MPTIssue >(ApplyViewContext ctx, Rate lockedRate, SLE::Ref sleDest, XRPAmount xrpBalance, STAmount const &amount, AccountID const &issuer, AccountID const &sender, AccountID const &receiver, bool createAsset, beast::Journal journal)
Bundles the mutable ledger view and the transaction being applied.
Definition ApplyView.h:451
Reflects the fee settings for a particular ledger.
std::uint32_t gasLimit
Gas limit for Feature Extensions (instructions).
std::uint32_t bytecodeSizeLimit
Bytecode size limit for Feature Extensions (bytes).
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:20
Represents a transfer rate.
Definition Rate.h:21
std::uint32_t value
Definition Rate.h:22