xrpld
Loading...
Searching...
No Matches
MPTInvariant.cpp
1#include <xrpl/tx/invariants/MPTInvariant.h>
2
3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/beast/utility/Zero.h>
7#include <xrpl/beast/utility/instrumentation.h>
8#include <xrpl/ledger/ReadView.h>
9#include <xrpl/ledger/helpers/AccountRootHelpers.h>
10#include <xrpl/ledger/helpers/LendingHelpers.h>
11#include <xrpl/ledger/helpers/MPTokenHelpers.h>
12#include <xrpl/protocol/AccountID.h>
13#include <xrpl/protocol/Feature.h>
14#include <xrpl/protocol/Indexes.h>
15#include <xrpl/protocol/LedgerFormats.h>
16#include <xrpl/protocol/MPTIssue.h>
17#include <xrpl/protocol/Protocol.h>
18#include <xrpl/protocol/Rules.h>
19#include <xrpl/protocol/SField.h>
20#include <xrpl/protocol/STLedgerEntry.h>
21#include <xrpl/protocol/STTx.h>
22#include <xrpl/protocol/TER.h>
23#include <xrpl/protocol/TxFormats.h>
24#include <xrpl/protocol/UintTypes.h>
25#include <xrpl/protocol/XRPAmount.h>
26#include <xrpl/tx/invariants/InvariantCheckPrivilege.h>
27
28#include <algorithm>
29#include <array>
30#include <cstddef>
31#include <cstdint>
32#include <memory>
33
34namespace xrpl {
35
36namespace {
37constexpr auto kConfidentialMptTxTypes = std::to_array<TxType>({
38 ttCONFIDENTIAL_MPT_SEND,
39 ttCONFIDENTIAL_MPT_CONVERT,
40 ttCONFIDENTIAL_MPT_CONVERT_BACK,
41 ttCONFIDENTIAL_MPT_MERGE_INBOX,
42 ttCONFIDENTIAL_MPT_CLAWBACK,
43 ttCONFIDENTIAL_MPT_MIRROR_UPDATE,
44 ttCONFIDENTIAL_MPT_HOLDER_KEY_UPDATE,
45});
46
47// Clamp to the cap (== INT64_MAX) before the signed conversion. Invariant
48// tests can inject INT64_MAX + 1, which would result in undefined behavior
49// under UBSan if converted directly.
50std::int64_t
51toSignedMPTAmount(std::uint64_t amount)
52{
53 return static_cast<std::int64_t>(std::min(amount, kMaxMpTokenAmount));
54}
55
56std::int64_t
57addMPTAmountDelta(std::int64_t delta, std::uint64_t amount)
58{
59 return delta + toSignedMPTAmount(amount);
60}
61
62std::int64_t
63subtractMPTAmountDelta(std::int64_t delta, std::uint64_t amount)
64{
65 return delta - toSignedMPTAmount(amount);
66}
67
68} // namespace
69
70void
72{
73 // The sfReferenceHolding tracking and the deleted-holding capture are
74 // only meaningful post-fixCleanup3_2_0 (the field is never set
75 // pre-amendment, and the holding-deletion rule does not apply).
76 // Skip both blocks when the amendment is off so we avoid wasted work
77 // on the hot path, except where noted for fixCleanup3_5_0 below.
78 bool const fix320Enabled = isFeatureEnabled(fixCleanup3_2_0);
79
80 if (after && after->getType() == ltMPTOKEN_ISSUANCE)
81 {
82 if (isDelete)
83 {
85 }
86 else if (!before)
87 {
89 if (fix320Enabled && after->isFieldPresent(sfReferenceHolding))
91 }
92 else
93 {
94 // lsfMPTLocked is the only issuance flag with a legal clear path
95 // (tfMPTUnlock); the rest are fixed at creation or set-once.
96 issuanceFlagsCleared_ |= before->getFlags() & ~after->getFlags() & ~lsfMPTLocked;
97
98 if (fix320Enabled)
99 {
100 // Modified issuance: detect any change to sfReferenceHolding.
101 bool const beforePresent = before->isFieldPresent(sfReferenceHolding);
102 bool const afterPresent = after->isFieldPresent(sfReferenceHolding);
103 if (beforePresent != afterPresent ||
104 (afterPresent &&
105 before->getFieldH256(sfReferenceHolding) !=
106 after->getFieldH256(sfReferenceHolding)))
107 {
109 }
110 }
111 }
112 }
113
114 if (after && after->getType() == ltMPTOKEN)
115 {
116 if (isDelete)
117 {
119 // deletedHoldings_ also feeds finalize()'s erase-time public
120 // balance check, gated on fixCleanup3_5_0 independently of
121 // fixCleanup3_2_0.
122 if (fix320Enabled || isFeatureEnabled(fixCleanup3_5_0))
123 deletedHoldings_.push_back(after);
124 }
125 else if (!before)
126 {
128 MPTIssue const mptIssue{after->at(sfMPTokenIssuanceID)};
129 if (mptIssue.getIssuer() == after->at(sfAccount))
130 mptCreatedByIssuer_ = true;
131 }
132 }
133
134 // Capture deleted RippleState SLEs so finalize() can verify none of
135 // them were owned by a vault pseudo-account outside VaultDelete.
136 if (fix320Enabled && isDelete && after && after->getType() == ltRIPPLE_STATE)
137 deletedHoldings_.push_back(after);
138}
139
140bool
142 STTx const& tx,
143 TER const result,
144 XRPAmount const fee,
145 ReadView const& view,
146 beast::Journal const& j) const
147{
148 auto const& rules = view.rules();
149 bool const mptV2Enabled = rules.enabled(featureMPTokensV2);
150
151 // Post-fixCleanup3_2_0:
152 // - sfReferenceHolding is set only by VaultCreate at share-issuance
153 // creation, and is immutable thereafter.
154 // - A vault pseudo-account's MPToken or RippleState may only be
155 // deleted by VaultDelete; the share's sfReferenceHolding pointer
156 // must not dangle outside that controlled lifecycle.
157 if (rules.enabled(fixCleanup3_2_0))
158 {
159 // Not an amendment gate like the same-named flags below, just an
160 // accumulator, so that every violation gets logged before returning.
161 bool invariantPasses = true;
163 {
164 JLOG(j.fatal()) << "Invariant failed: sfReferenceHolding was modified "
165 "on an existing MPTokenIssuance";
166 invariantPasses = false;
167 }
168 if (referenceHoldingSetOnCreate_ && tx.getTxnType() != ttVAULT_CREATE)
169 {
170 JLOG(j.fatal()) << "Invariant failed: sfReferenceHolding set on a new "
171 "MPTokenIssuance by a non-VaultCreate transaction";
172 invariantPasses = false;
173 }
174 if (!deletedHoldings_.empty() && tx.getTxnType() != ttVAULT_DELETE)
175 {
176 auto const isVaultPseudo = [&](AccountID const& acct) {
177 auto const sle = view.read(keylet::account(acct));
178 return sle && sle->isFieldPresent(sfVaultID);
179 };
180 for (auto const& sleHolding : deletedHoldings_)
181 {
182 bool offending = false;
183 if (sleHolding->getType() == ltMPTOKEN)
184 {
185 offending = isVaultPseudo(sleHolding->at(sfAccount));
186 }
187 else // ltRIPPLE_STATE
188 {
189 auto const lowLimit = sleHolding->getFieldAmount(sfLowLimit);
190 auto const highLimit = sleHolding->getFieldAmount(sfHighLimit);
191 // Each limit's STAmount.issuer is the COUNTERPARTY of
192 // that side's owner: lowLimit's issuer is the high
193 // account, highLimit's issuer is the low account.
194 offending =
195 isVaultPseudo(lowLimit.getIssuer()) || isVaultPseudo(highLimit.getIssuer());
196 }
197 if (offending)
198 {
199 JLOG(j.fatal()) << "Invariant failed: vault pseudo-account holding "
200 "deleted by a non-VaultDelete transaction";
201 invariantPasses = false;
202 }
203 }
204 }
205 if (!invariantPasses)
206 return false;
207 }
208
209 // Post-fixCleanup3_5_0: no transaction may clear an issuance flag other
210 // than lsfMPTLocked, so downstream code can trust set-once flags such as
211 // lsfMPTCanTransfer.
212 if (rules.enabled(fixCleanup3_5_0) && issuanceFlagsCleared_ != 0)
213 {
214 JLOG(j.fatal()) << "Invariant failed: immutable MPTokenIssuance flag cleared: "
216 return false;
217 }
218
219 // Deleting an MPToken with a non-zero MPTAmount is rejected.
220 if (rules.enabled(fixCleanup3_5_0))
221 {
222 for (auto const& sleHolding : deletedHoldings_)
223 {
224 if (sleHolding->getType() == ltMPTOKEN && sleHolding->getFieldU64(sfMPTAmount) > 0)
225 {
226 JLOG(j.fatal()) << "Invariant failed: MPToken deleted with non-zero balance";
227 return false;
228 }
229 }
230 }
231
232 if (isTesSuccess(result) || (mptV2Enabled && result == tecINCOMPLETE))
233 {
234 [[maybe_unused]]
235 bool const enforceCreatedByIssuer =
236 rules.enabled(featureSingleAssetVault) || rules.enabled(featureLendingProtocol);
238 {
239 JLOG(j.fatal()) << "Invariant failed: MPToken created for the MPT issuer";
240 // The comment above starting with "assert(enforce)" explains this
241 // assert.
242 XRPL_ASSERT_PARTS(
243 enforceCreatedByIssuer, "xrpl::ValidMPTIssuance::finalize", "no issuer MPToken");
244 if (enforceCreatedByIssuer)
245 return false;
246 }
247
248 auto const txnType = tx.getTxnType();
250 {
251 if (mptIssuancesCreated_ == 0)
252 {
253 JLOG(j.fatal()) << "Invariant failed: transaction "
254 "succeeded without creating a MPT issuance";
255 }
256 else if (mptIssuancesDeleted_ != 0)
257 {
258 JLOG(j.fatal()) << "Invariant failed: transaction "
259 "succeeded while removing MPT issuances";
260 }
261 else if (mptIssuancesCreated_ > 1)
262 {
263 JLOG(j.fatal()) << "Invariant failed: transaction "
264 "succeeded but created multiple issuances";
265 }
266
267 return mptIssuancesCreated_ == 1 && mptIssuancesDeleted_ == 0;
268 }
269
271 {
272 if (mptIssuancesDeleted_ == 0)
273 {
274 JLOG(j.fatal()) << "Invariant failed: MPT issuance deletion "
275 "succeeded without removing a MPT issuance";
276 }
277 else if (mptIssuancesCreated_ > 0)
278 {
279 JLOG(j.fatal()) << "Invariant failed: MPT issuance deletion "
280 "succeeded while creating MPT issuances";
281 }
282 else if (mptIssuancesDeleted_ > 1)
283 {
284 JLOG(j.fatal()) << "Invariant failed: MPT issuance deletion "
285 "succeeded but deleted multiple issuances";
286 }
287
288 return mptIssuancesCreated_ == 0 && mptIssuancesDeleted_ == 1;
289 }
290
291 bool const lendingProtocolEnabled = rules.enabled(featureLendingProtocol);
292 // ttESCROW_FINISH may authorize an MPT, but it can't have the
293 // mayAuthorizeMPT privilege, because that may cause
294 // non-amendment-gated side effects.
295 bool const enforceEscrowFinish = (txnType == ttESCROW_FINISH) &&
296 (rules.enabled(featureSingleAssetVault) || lendingProtocolEnabled);
298 enforceEscrowFinish)
299 {
300 bool const submittedByIssuer = tx.isFieldPresent(sfHolder);
301
302 if (mptIssuancesCreated_ > 0)
303 {
304 JLOG(j.fatal()) << "Invariant failed: MPT authorize "
305 "succeeded but created MPT issuances";
306 return false;
307 }
308 if (mptIssuancesDeleted_ > 0)
309 {
310 JLOG(j.fatal()) << "Invariant failed: MPT authorize "
311 "succeeded but deleted issuances";
312 return false;
313 }
314 if (mptV2Enabled && hasPrivilege(tx, Privilege::MayAuthorizeMpt) &&
315 (txnType == ttAMM_WITHDRAW || txnType == ttAMM_CLAWBACK))
316 {
317 if (submittedByIssuer && txnType == ttAMM_WITHDRAW && mptokensCreated_ > 0)
318 {
319 JLOG(j.fatal()) << "Invariant failed: MPT authorize "
320 "submitted by issuer succeeded "
321 "but created bad number of mptokens";
322 return false;
323 }
324 // At most two MPToken may be created on withdraw/clawback since:
325 // - Liquidity Provider must have at least one token in order
326 // participate in AMM pool liquidity or have LPTokens only.
327 // - At most two MPTokens may be deleted if AMM pool, which has exactly
328 // two tokens, is empty after withdraw/clawback.
329 SOMETIMES(mptokensCreated_ == 2, "AMM withdraw/clawback recreated two MPTokens");
330 if (mptokensCreated_ > 2 || mptokensDeleted_ > 2)
331 {
332 JLOG(j.fatal()) << "Invariant failed: MPT authorize succeeded "
333 "but created/deleted bad number of mptokens";
334 return false;
335 }
336 }
337 else
338 {
339 // Cap on MPToken creates and deletes while featureLendingProtocol is enabled.
340 // - LoanSet: at most two creates and no deletes.
341 // - VaultWithdraw: at most one create and one delete.
342 // - LoanBrokerDelete (post-fixCleanup3_5_0): at most one create and one delete.
343 // - Other MayAuthorizeMpt types: created + deleted <= 1.
344 // - MustAuthorizeMpt still requires exactly one create or delete below.
345 auto const mptokensExceedAuthorizeCap = [&] {
346 if (!lendingProtocolEnabled)
347 return false;
348 if (rules.enabled(fixCleanup3_4_0))
349 {
350 if (txnType == ttLOAN_SET)
351 return mptokensDeleted_ != 0 || mptokensCreated_ > 2;
352 if (txnType == ttVAULT_WITHDRAW)
353 return mptokensCreated_ > 1 || mptokensDeleted_ > 1;
354 }
355 // The cover payout may create the owner's MPToken while the
356 // pseudo-account's MPToken is deleted.
357 if (rules.enabled(fixCleanup3_5_0) && txnType == ttLOAN_BROKER_DELETE)
358 return mptokensCreated_ > 1 || mptokensDeleted_ > 1;
359 return (mptokensCreated_ + mptokensDeleted_) > 1;
360 };
361 if (mptokensExceedAuthorizeCap())
362 {
363 JLOG(j.fatal()) << "Invariant failed: MPT authorize succeeded "
364 "but created/deleted bad number mptokens";
365 return false;
366 }
367 if (submittedByIssuer && (mptokensCreated_ > 0 || mptokensDeleted_ > 0))
368 {
369 JLOG(j.fatal()) << "Invariant failed: MPT authorize submitted by issuer "
370 "succeeded but created/deleted mptokens";
371 return false;
372 }
373 if (!submittedByIssuer && hasPrivilege(tx, Privilege::MustAuthorizeMpt) &&
375 {
376 // if the holder submitted this tx, then a mptoken must be
377 // either created or deleted.
378 JLOG(j.fatal()) << "Invariant failed: MPT authorize submitted by holder "
379 "succeeded but created/deleted bad number of mptokens";
380 return false;
381 }
382 }
383
384 return true;
385 }
386
388 {
389 bool const submittedByIssuer = tx.isFieldPresent(sfHolder);
390
391 if (mptIssuancesCreated_ > 0)
392 {
393 JLOG(j.fatal()) << "Invariant failed: MPT authorize "
394 "succeeded but created MPT issuances";
395 return false;
396 }
397 if (mptIssuancesDeleted_ > 0)
398 {
399 JLOG(j.fatal()) << "Invariant failed: MPT authorize "
400 "succeeded but deleted issuances";
401 return false;
402 }
403 if (mptokensDeleted_ > 0)
404 {
405 JLOG(j.fatal()) << "Invariant failed: MPT authorize "
406 "succeeded but deleted MPTokens";
407 return false;
408 }
409 // AMMCreate may auto-create up to two MPT objects:
410 // - one per asset side in an MPT/MPT AMM, or one in an IOU/MPT AMM.
411 // CheckCash may auto-create at most one MPT object for the receiver.
412 if ((txnType == ttAMM_CREATE && mptokensCreated_ > 2) ||
413 (txnType == ttCHECK_CASH && mptokensCreated_ > 1))
414 {
415 JLOG(j.fatal()) << "Invariant failed: MPT authorize "
416 "succeeded but created bad number of mptokens";
417 return false;
418 }
419 if (submittedByIssuer)
420 {
421 JLOG(j.fatal()) << "Invariant failed: MPT authorize submitted by issuer "
422 "succeeded but created mptokens";
423 return false;
424 }
425
426 // Offer crossing or payment may consume multiple offers
427 // where takerPays is MPT amount. If the offer owner doesn't
428 // own MPT then MPT is created automatically.
429 return true;
430 }
431
432 if (txnType == ttESCROW_FINISH)
433 {
434 // ttESCROW_FINISH may authorize an MPT, but it can't have the
435 // mayAuthorizeMPT privilege, because that may cause
436 // non-amendment-gated side effects.
437 XRPL_ASSERT_PARTS(
438 !enforceEscrowFinish, "xrpl::ValidMPTIssuance::finalize", "not escrow finish tx");
439 return true;
440 }
441
443 ((txnType == ttAMM_DELETE && mptokensDeleted_ <= 2) || mptokensDeleted_ == 1) &&
445 return true;
446 }
447
448 if (mptIssuancesCreated_ != 0)
449 {
450 JLOG(j.fatal()) << "Invariant failed: a MPT issuance was created";
451 }
452 else if (mptIssuancesDeleted_ != 0)
453 {
454 JLOG(j.fatal()) << "Invariant failed: a MPT issuance was deleted";
455 }
456 else if (mptokensCreated_ != 0)
457 {
458 JLOG(j.fatal()) << "Invariant failed: a MPToken was created";
459 }
460 else if (mptokensDeleted_ != 0)
461 {
462 JLOG(j.fatal()) << "Invariant failed: a MPToken was deleted";
463 }
464
465 return mptIssuancesCreated_ == 0 && mptIssuancesDeleted_ == 0 && mptokensCreated_ == 0 &&
466 mptokensDeleted_ == 0;
467}
468
469void
471{
472 if (overflow_)
473 return;
474
475 auto makeKey = [](SLE const& sle) {
476 if (sle.getType() == ltMPTOKEN_ISSUANCE)
477 return makeMptID(sle[sfSequence], sle[sfIssuer]);
478 return sle[sfMPTokenIssuanceID];
479 };
480
481 auto const update = [&](SLE const& sle, Order order) -> bool {
482 auto const type = sle.getType();
483 if (type == ltMPTOKEN_ISSUANCE)
484 {
485 auto const outstanding = sle[sfOutstandingAmount];
486 if (outstanding > kMaxMpTokenAmount)
487 {
488 overflow_ = true;
489 return false;
490 }
491 data_[makeKey(sle)].outstanding[static_cast<std::size_t>(order)] = outstanding;
492 }
493 else if (type == ltMPTOKEN)
494 {
495 auto const mptAmt = sle[sfMPTAmount];
496 auto const lockedAmt = sle[~sfLockedAmount].value_or(0);
497 if (mptAmt > kMaxMpTokenAmount || lockedAmt > kMaxMpTokenAmount ||
498 lockedAmt > (kMaxMpTokenAmount - mptAmt))
499 {
500 overflow_ = true;
501 return false;
502 }
503 auto const res = static_cast<std::int64_t>(mptAmt + lockedAmt);
504 // subtract before from after
505 if (order == Order::Before)
506 {
507 data_[makeKey(sle)].mptAmount -= res;
508 }
509 else
510 {
511 data_[makeKey(sle)].mptAmount += res;
512 }
513 }
514 return true;
515 };
516
517 if (before && !update(*before, Order::Before))
518 return;
519
520 if (after)
521 {
522 if (after->getType() == ltMPTOKEN_ISSUANCE)
523 {
524 overflow_ = (*after)[sfOutstandingAmount] > maxMPTAmount(*after);
525 }
526 if (!update(*after, Order::After))
527 return;
528 }
529}
530
531bool
533 STTx const& tx,
534 TER const result,
535 XRPAmount const,
536 ReadView const& view,
537 beast::Journal const& j)
538{
539 auto const fix340Enabled = view.rules().enabled(fixCleanup3_4_0);
540
541 if (isTesSuccess(result) || fix340Enabled)
542 {
543 // Confidential transactions are validated by ValidConfidentialMPToken.
544 // They modify encrypted fields and sfConfidentialOutstandingAmount
545 // rather than sfMPTAmount/sfOutstandingAmount in the standard way,
546 // so ValidMPTPayment's accounting does not apply to them.
547 if (std::ranges::find(kConfidentialMptTxTypes, tx.getTxnType()) !=
548 kConfidentialMptTxTypes.end())
549 {
550 return true;
551 }
552
553 // Returned when a violation is found below, so this is the log-only
554 // condition. Either amendment makes the checks enforcing.
555 auto const invariantPasses = !(view.rules().enabled(featureMPTokensV2) || fix340Enabled);
556 if (overflow_)
557 {
558 JLOG(j.fatal()) << "Invariant failed: OutstandingAmount overflow";
559 return invariantPasses;
560 }
561
562 auto const signedMax = static_cast<std::int64_t>(kMaxMpTokenAmount);
563 for (auto const& [id, data] : data_)
564 {
565 (void)id;
566 static constexpr auto kIBefore = static_cast<std::size_t>(Order::Before);
567 static constexpr auto kIAfter = static_cast<std::size_t>(Order::After);
568 bool const addOverflows =
569 (data.mptAmount > 0 && data.outstanding[kIBefore] > (signedMax - data.mptAmount)) ||
570 (data.mptAmount < 0 && data.outstanding[kIBefore] < (-signedMax - data.mptAmount));
571 if (addOverflows ||
572 data.outstanding[kIAfter] != (data.outstanding[kIBefore] + data.mptAmount))
573 {
574 JLOG(j.fatal()) << "Invariant failed: invalid OutstandingAmount balance "
575 << data.outstanding[kIBefore] << " " << data.outstanding[kIAfter]
576 << " " << data.mptAmount;
577 return invariantPasses;
578 }
579
580 // A failed transaction must not have moved MPT value; the check
581 // above ties mptAmount to the OutstandingAmount delta. No result
582 // code is exempt: on any tec the transactor discards the view and
583 // re-applies only offer, trust line, NFT offer and credential
584 // deletions (Transactor::typesForResult), none of which touch MPTs.
585 if (!isTesSuccess(result) && data.mptAmount != 0)
586 {
587 JLOG(j.fatal()) << "Invariant failed: OutstandingAmount balance changed on failure "
588 << tx.getTxnType() << " " << result;
589 return invariantPasses;
590 }
591 }
592 }
593
594 return true;
595}
596
597void
599 bool isDelete,
600 std::shared_ptr<SLE const> const& before,
602{
603 // Helper to get MPToken Issuance ID safely
604 auto const getMptID = [](std::shared_ptr<SLE const> const& sle) -> UInt192 {
605 if (!sle)
606 return beast::kZero;
607 if (sle->getType() == ltMPTOKEN)
608 return sle->getFieldH192(sfMPTokenIssuanceID);
609 if (sle->getType() == ltMPTOKEN_ISSUANCE)
610 return makeMptID(sle->getFieldU32(sfSequence), sle->getAccountID(sfIssuer));
611 return beast::kZero;
612 };
613
614 if (before && before->getType() == ltMPTOKEN)
615 {
616 UInt192 const id = getMptID(before);
617 auto& change = changes_[id];
618 change.mptAmountDelta =
619 subtractMPTAmountDelta(change.mptAmountDelta, before->getFieldU64(sfMPTAmount));
620
621 // Cannot delete MPToken with non-zero confidential state.
622 if (isDelete)
623 {
624 // changes_ is keyed by issuance, so sibling holders erased by the
625 // same transaction share this entry. Only ever set these flags,
626 // never clear them, or an empty sibling visited later would mask
627 // a funded MPToken.
628
629 // Retired by fixCleanup3_5_0, which moved the public balance
630 // check to ValidMPTIssuance::finalize. Kept pre-amendment for
631 // consensus safety: a non-zero public balance used to feed the
632 // confidential gate below, rejecting the erase whenever the
633 // issuance's COA was non-zero, and already-validated ledgers
634 // depend on that.
635 if (!isFeatureEnabled(fixCleanup3_5_0) && before->getFieldU64(sfMPTAmount) > 0)
636 changes_[id].deletedWithBalanceBefore = true;
637
638 if (before->isFieldPresent(sfConfidentialBalanceSpending) ||
639 before->isFieldPresent(sfConfidentialBalanceInbox) ||
640 before->isFieldPresent(sfIssuerEncryptedBalance) ||
641 before->isFieldPresent(sfAuditorEncryptedBalance))
642 changes_[id].deletedWithEncrypted = true;
643 }
644 }
645
646 if (after && after->getType() == ltMPTOKEN)
647 {
648 UInt192 const id = getMptID(after);
649 auto& change = changes_[id];
650 change.mptAmountDelta =
651 addMPTAmountDelta(change.mptAmountDelta, after->getFieldU64(sfMPTAmount));
652
653 // Encrypted field existence consistency
654 bool const hasIssuerBalance = after->isFieldPresent(sfIssuerEncryptedBalance);
655 bool const hasHolderInbox = after->isFieldPresent(sfConfidentialBalanceInbox);
656 bool const hasHolderSpending = after->isFieldPresent(sfConfidentialBalanceSpending);
657 bool const hasAuditorBalance = after->isFieldPresent(sfAuditorEncryptedBalance);
658
659 // The core encrypted balances must all exist or not exist at the same time. The auditor
660 // balance is optional, but cannot exist without the core fields.
661 if (hasHolderInbox != hasHolderSpending || hasHolderInbox != hasIssuerBalance ||
662 (hasAuditorBalance && !hasIssuerBalance))
663 changes_[id].badConsistency = true;
664
665 auto const confidentialBalanceFieldChanged = [&before, &after](auto const& field) {
666 auto const afterValue = (*after)[~field];
667 if (!afterValue)
668 return false;
669
670 if (!before || before->getType() != ltMPTOKEN)
671 return true; // LCOV_EXCL_LINE
672
673 return (*before)[~field] != afterValue;
674 };
675
676 if (confidentialBalanceFieldChanged(sfConfidentialBalanceInbox) ||
677 confidentialBalanceFieldChanged(sfConfidentialBalanceSpending) ||
678 confidentialBalanceFieldChanged(sfIssuerEncryptedBalance) ||
679 confidentialBalanceFieldChanged(sfAuditorEncryptedBalance))
680 {
681 changes_[id].changesConfidentialFields = true;
682 }
683 }
684
685 if (before && before->getType() == ltMPTOKEN_ISSUANCE)
686 {
687 UInt192 const id = getMptID(before);
688 auto& change = changes_[id];
689 if (before->isFieldPresent(sfConfidentialOutstandingAmount))
690 {
691 change.coaDelta = subtractMPTAmountDelta(
692 change.coaDelta, before->getFieldU64(sfConfidentialOutstandingAmount));
693 }
694 change.outstandingDelta = subtractMPTAmountDelta(
695 change.outstandingDelta, before->getFieldU64(sfOutstandingAmount));
696 }
697
698 if (after && after->getType() == ltMPTOKEN_ISSUANCE)
699 {
700 UInt192 const id = getMptID(after);
701 auto& change = changes_[id];
702
703 bool const hasCOA = after->isFieldPresent(sfConfidentialOutstandingAmount);
704 std::uint64_t const coa = (*after)[~sfConfidentialOutstandingAmount].value_or(0);
705 std::uint64_t const oa = after->getFieldU64(sfOutstandingAmount);
706
707 if (hasCOA)
708 change.coaDelta = addMPTAmountDelta(change.coaDelta, coa);
709
710 change.outstandingDelta = addMPTAmountDelta(change.outstandingDelta, oa);
711 change.issuance = after;
712
713 // COA <= OutstandingAmount
714 if (coa > oa)
715 change.badCOA = true;
716 }
717
718 if (before && after && before->getType() == ltMPTOKEN && after->getType() == ltMPTOKEN)
719 {
720 UInt192 const id = getMptID(after);
721
722 // sfConfidentialBalanceVersion must change when spending changes
723 auto const spendingBefore = (*before)[~sfConfidentialBalanceSpending];
724 auto const spendingAfter = (*after)[~sfConfidentialBalanceSpending];
725 auto const versionBefore = (*before)[~sfConfidentialBalanceVersion];
726 auto const versionAfter = (*after)[~sfConfidentialBalanceVersion];
727
728 if (spendingBefore.has_value() && spendingBefore != spendingAfter)
729 {
730 if (versionBefore == versionAfter)
731 changes_[id].badVersion = true;
732 }
733 }
734}
735
736bool
738 STTx const& tx,
739 TER const result,
740 XRPAmount const,
741 ReadView const& view,
742 beast::Journal const& j)
743{
744 if (result != tesSUCCESS)
745 return true;
746
747 bool const fix350Enabled = view.rules().enabled(fixCleanup3_5_0);
748
749 for (auto const& [id, checks] : changes_)
750 {
751 // Find the MPTokenIssuance
752 auto const issuance = [&] -> std::shared_ptr<SLE const> {
753 if (checks.issuance)
754 return checks.issuance;
755 return view.read(keylet::mptokenIssuance(id));
756 }();
757
758 // Skip all invariance checks if issuance doesn't exist because that means the MPT has been
759 // deleted
760 if (!issuance)
761 continue;
762
763 // Cannot delete MPToken with non-zero confidential state.
764 //
765 // Before fixCleanup3_5_0 this gate also absorbed the pre-transaction
766 // public balance, so any drain-then-erase of an MPToken -- an
767 // AMMWithdraw of the whole pool, a LoanBrokerDelete returning cover --
768 // was rejected whenever some unrelated holder of the same issuance
769 // held a confidential balance. The COA gate itself is correct for
770 // ciphertext and mirrors MPTokenAuthorize::preclaim; only the public
771 // balance leg was misplaced.
772 bool const deletedWithEncrypted = fix350Enabled
773 ? checks.deletedWithEncrypted
774 : (checks.deletedWithEncrypted || checks.deletedWithBalanceBefore);
775
776 if (deletedWithEncrypted)
777 {
778 if ((*issuance)[~sfConfidentialOutstandingAmount].value_or(0) > 0)
779 {
780 JLOG(j.fatal())
781 << "Invariant failed: MPToken deleted with encrypted fields while COA > 0";
782 return false;
783 }
784 }
785
786 // Encrypted field existence consistency
787 if (checks.badConsistency)
788 {
789 JLOG(j.fatal()) << "Invariant failed: MPToken encrypted field "
790 "existence inconsistency";
791 return false;
792 }
793
794 // COA <= OutstandingAmount
795 if (checks.badCOA)
796 {
797 JLOG(j.fatal()) << "Invariant failed: Confidential outstanding amount "
798 "exceeds total outstanding amount";
799 return false;
800 }
801
802 // Confidential balance fields may remain on a holder MPToken after all
803 // confidential balances have returned to zero. Only creating or
804 // changing those fields requires the issuance privacy flag.
805 if (checks.changesConfidentialFields)
806 {
807 if (!issuance->isFlag(lsfMPTCanHoldConfidentialBalance))
808 {
809 JLOG(j.fatal()) << "Invariant failed: MPToken has encrypted "
810 "fields but Issuance does not have "
811 "lsfMPTCanHoldConfidentialBalance set";
812 return false;
813 }
814 }
815
816 // We only enforce this when Confidential Outstanding Amount changes (Convert, ConvertBack,
817 // ConfidentialClawback). This avoids falsely failing on Escrow or AMM operations that lock
818 // public tokens outside of ltMPTOKEN. Convert / ConvertBack:
819 // - COA and MPTAmount must have opposite deltas, which cancel each other out to zero.
820 // - OA remains unchanged.
821 // - Therefore, the net delta on both sides of the equation is zero.
822 //
823 // Clawback:
824 // - MPTAmount remains unchanged.
825 // - COA and OA must have identical deltas (mirrored on each side).
826 // - The equation remains balanced as both sides have equal offsets.
827 if (checks.coaDelta != 0)
828 {
829 if (checks.mptAmountDelta + checks.coaDelta != checks.outstandingDelta)
830 {
831 JLOG(j.fatal()) << "Invariant failed: Token conservation "
832 "violation for MPT "
833 << to_string(id);
834 return false;
835 }
836 }
837 else if (
838 std::ranges::find(kConfidentialMptTxTypes, tx.getTxnType()) !=
839 kConfidentialMptTxTypes.end())
840 {
841 // Confidential Txns should not modify public MPTAmount balance
842 // if Confidential Amount Delta is 0
843 if (checks.mptAmountDelta != 0)
844 {
845 JLOG(j.fatal()) << "Invariant failed: MPTAmount changed by confidential "
846 "transaction that should not modify this field."
847 << to_string(id);
848 return false;
849 }
850
851 // Reaching here means this confidential MPT transaction left coaDelta
852 // unmodified (e.g. ConfidentialMPTSend, ConfidentialMPTMergeInbox, or
853 // ConfidentialMPTHolderKeyUpdate/ConfidentialMPTMirrorUpdate, none of which touch
854 // sfConfidentialOutstandingAmount), so it must not modify sfOutstandingAmount either.
855 if (checks.outstandingDelta != 0)
856 {
857 JLOG(j.fatal()) << "Invariant failed: OutstandingAmount changed "
858 "by confidential transaction that should not "
859 "modify it for MPT "
860 << to_string(id);
861 return false;
862 }
863 }
864
865 if (checks.badVersion)
866 {
867 JLOG(j.fatal())
868 << "Invariant failed: MPToken sfConfidentialBalanceVersion not updated when "
869 "sfConfidentialBalanceSpending changed";
870 return false;
871 }
872 }
873
874 return true;
875}
876
877void
879 bool isDelete,
880 std::shared_ptr<SLE const> const& before,
882{
883 // Record the before/after MPTAmount for each (issuanceID, account) pair
884 // so finalize() can determine whether a transfer actually occurred.
885 auto const update = [&](SLE const& sle, bool isBefore) {
886 if (sle.getType() == ltMPTOKEN)
887 {
888 auto const issuanceID = sle[sfMPTokenIssuanceID];
889 auto const account = sle[sfAccount];
890 auto const amount = sle[sfMPTAmount];
891 if (isBefore)
892 {
893 amount_[issuanceID][account].amtBefore = amount;
894 }
895 else
896 {
897 amount_[issuanceID][account].amtAfter = amount;
898 }
899 if (isDelete && isBefore)
900 {
901 deletedAuthorized_[sle.key()] = sle.isFlag(lsfMPTAuthorized);
902 }
903 }
904 };
905
906 if (before)
907 update(*before, true);
908
909 if (after)
910 update(*after, false);
911
912 // Record whether every touched AccountRoot was a pseudo-account BEFORE
913 // the transaction applied (true and false). A transaction that erases a
914 // pseudo-account (and moves MPT out of it) in the same transaction leaves
915 // no trace of its pseudo-account status in the post-transaction view
916 // isAuthorized() sees at finalize() time.
917 if (before && before->getType() == ltACCOUNT_ROOT)
918 pseudoAccountsBefore_[before->at(sfAccount)] = isPseudoAccount(before);
919}
920
921bool
923 ReadView const& view,
924 MPTID const& mptid,
925 AccountID const& holder,
926 bool reqAuth) const
927{
928 // Pseudo-accounts (Vault, LoanBroker, AMM) hold assets on behalf of their
929 // participants and are implicitly authorized for any MPT they hold,
930 // including vault shares whose underlying asset would otherwise require
931 // auth. Exempt them here rather than relying on requireAuth: the recursive
932 // share -> underlying descent in requireAuth fails for a pseudo-account
933 // that holds the share but not the underlying.
934 //
935 // Use the pre-transaction classification for any account this
936 // transaction touched (pseudoAccountsBefore_): the post-transaction view
937 // is wrong for an account this same transaction erased. Untouched
938 // accounts aren't in the map, so fall back to the current view, which is
939 // still accurate for them since nothing changed.
940 auto const pseudoIt = pseudoAccountsBefore_.find(holder);
941 bool const isPseudo =
942 pseudoIt != pseudoAccountsBefore_.end() ? pseudoIt->second : isPseudoAccount(view, holder);
943 if (isPseudo)
944 return true;
945
946 auto const key = keylet::mptoken(mptid, holder);
947 auto const it = deletedAuthorized_.find(key.key);
948 if (it != deletedAuthorized_.end())
949 return !reqAuth || it->second;
950 return isTesSuccess(requireAuth(view, MPTIssue{mptid}, holder));
951}
952
953bool
955 STTx const& tx,
956 TER const result,
957 XRPAmount const,
958 ReadView const& view,
959 beast::Journal const& j)
960{
962 return true;
963
964 // XLS-0066: a broker must be able to default an already-late loan
965 // regardless of the vault asset's lock state. Gated behind
966 // fixCleanup3_4_0, and scoped below to exactly the broker/vault
967 // pseudo-accounts and the vault's own MPT issuance -- see
968 // FreezeInvariant.cpp's TransfersNotFrozen::finalize for the IOU-side
969 // equivalent and rationale.
970 auto const loanDefaultAccounts = getLoanDefaultFreezeExemptAccounts(view, tx);
971
972 // DEX transactions (AMM[Create,Deposit], cross-currency payments, offer creates) are
973 // subject to the MPTCanTrade flag in addition to the standard transfer rules.
974 // A payment is only DEX if it is a cross-currency payment.
975 auto const txnType = tx.getTxnType();
976 auto const isDEX = [&] {
977 if (txnType == ttPAYMENT)
978 {
979 // A payment is cross-currency (and thus DEX) only if SendMax is present
980 // and its asset differs from the destination asset.
981 auto const amount = tx[sfAmount];
982 return tx[~sfSendMax].value_or(amount).asset() != amount.asset();
983 }
984 return txnType == ttAMM_CREATE || txnType == ttAMM_DEPOSIT || txnType == ttOFFER_CREATE;
985 }();
986
987 auto const fix340Enabled = view.rules().enabled(fixCleanup3_4_0);
988 // Returned when a violation is found below, so this is the log-only
989 // condition. Either amendment makes the checks enforcing.
990 auto const invariantPasses = !(view.rules().enabled(featureMPTokensV2) || fix340Enabled);
991
992 // A failed transaction must not persist an MPToken deletion. Pre-loop
993 // because deletedAuthorized_ is not issuance-scoped and orphans continue.
994 if (fix340Enabled && !isTesSuccess(result) && !deletedAuthorized_.empty())
995 {
996 JLOG(j.fatal()) << "Invariant failed: MPToken deleted on failure " << txnType << " "
997 << result;
998 return invariantPasses;
999 }
1000
1001 for (auto const& [mptID, values] : amount_)
1002 {
1003 std::uint16_t senders = 0;
1004 std::uint16_t receivers = 0;
1005 bool invalidTransfer = false;
1006 auto const sleIssuance = view.read(keylet::mptokenIssuance(mptID));
1007 if (!sleIssuance)
1008 {
1009 // MPTokenIssuanceDestroy only requires a zero OutstandingAmount, so
1010 // an orphaned MPToken can outlive its issuance and be cleaned up
1011 // later by a transaction of any type. There are no transfer rules
1012 // left to check, but its balance is zero and nothing can raise it,
1013 // so any change other than deletion is a bug.
1014 for (auto const& [account, value] : values)
1015 {
1016 if (value.amtAfter.has_value() && value.amtBefore.value_or(0) != *value.amtAfter)
1017 {
1018 JLOG(j.fatal()) << "Invariant failed: orphaned MPToken balance changed "
1019 << txnType << " " << result;
1020 return invariantPasses;
1021 }
1022 }
1023 continue;
1024 }
1025
1026 // This issuance is the LoanManage default's own vault asset, so the
1027 // broker/vault freeze and CanTransfer exemptions apply to it -- an
1028 // unrelated MPT the same accounts happen to hold is still caught.
1029 bool const isLoanDefaultAsset = loanDefaultAccounts &&
1030 loanDefaultAccounts->asset.holds<MPTIssue>() &&
1031 loanDefaultAccounts->asset.get<MPTIssue>().getMptID() == mptID;
1032
1033 // These transactions settle an existing MPT position out of a protocol
1034 // account. They do not require CanTransfer.
1035 auto const waivesCanTransfer = txnType == ttAMM_WITHDRAW ||
1036 (view.rules().enabled(fixCleanup3_2_0) &&
1037 (txnType == ttVAULT_WITHDRAW || txnType == ttLOAN_BROKER_COVER_WITHDRAW ||
1038 txnType == ttLOAN_PAY)) ||
1039 (view.rules().enabled(fixCleanup3_5_0) &&
1040 (isLoanDefaultAsset || txnType == ttLOAN_BROKER_DELETE));
1041 auto const canTransfer = sleIssuance->isFlag(lsfMPTCanTransfer) || waivesCanTransfer;
1042 auto const canTrade = sleIssuance->isFlag(lsfMPTCanTrade);
1043 auto const reqAuth = sleIssuance->isFlag(lsfMPTRequireAuth);
1044
1045 for (auto const& [account, value] : values)
1046 {
1047 // Classify each account as a sender or receiver based on whether their MPTAmount
1048 // decreased or increased. Count new MPToken holders (no amtBefore) as receivers.
1049 // Skip deleted MPToken holders (amtAfter is nullopt); deletion requires zero balance.
1050 if (value.amtAfter.has_value() && value.amtBefore.value_or(0) != *value.amtAfter)
1051 {
1052 if (!value.amtBefore.has_value() || *value.amtAfter > *value.amtBefore)
1053 {
1054 ++receivers;
1055 }
1056 else
1057 {
1058 ++senders;
1059 }
1060
1061 // Check once: if any involved account is frozen, the whole issuance transfer is
1062 // considered frozen. Only need to check for frozen if there is a transfer of funds.
1063 //
1064 // The LoanManage default exemption only waives the frozen check, and only for
1065 // the specific broker/vault pseudo-accounts identified above -- authorization is
1066 // still enforced for them, and both checks still apply to every other account.
1067 bool const exemptFromFreeze = isLoanDefaultAsset && loanDefaultAccounts &&
1068 (account == loanDefaultAccounts->broker ||
1069 account == loanDefaultAccounts->vault);
1070 if (!invalidTransfer &&
1071 ((!exemptFromFreeze && isFrozen(view, account, *sleIssuance)) ||
1072 !isAuthorized(view, mptID, account, reqAuth)))
1073 {
1074 invalidTransfer = true;
1075 }
1076 }
1077 }
1078 // A transfer between holders has occurred (senders > 0 && receivers > 0).
1079 // Fail if the issuance is frozen, does not permit transfers, or — for
1080 // DEX transactions — does not permit trading.
1081 if ((invalidTransfer || !canTransfer || (isDEX && !canTrade)) && senders > 0 &&
1082 receivers > 0)
1083 {
1084 JLOG(j.fatal()) << "Invariant failed: invalid MPToken transfer between holders";
1085 return invariantPasses;
1086 }
1087
1088 // A failed transaction must not have changed a holder's balance. One
1089 // side is enough, unlike the transfer check above, so this also catches
1090 // a lock/unlock moving value between sfMPTAmount and sfLockedAmount.
1091 if (fix340Enabled && !isTesSuccess(result) && (senders > 0 || receivers > 0))
1092 {
1093 JLOG(j.fatal()) << "Invariant failed: MPToken balance changed on failure " << txnType
1094 << " " << result;
1095 return invariantPasses;
1096 }
1097 }
1098
1099 return true;
1100}
1101
1102} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:44
Stream fatal() const
Definition Journal.h:368
constexpr MPTID const & getMptID() const
Definition MPTIssue.h:43
AccountID const & getIssuer() const
Definition MPTIssue.cpp:29
A view into a ledger.
Definition ReadView.h:41
virtual Rules const & rules() const =0
Returns the tx processing rules.
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
UInt256 const & key() const
Returns the 'key' (or 'index') of this item.
LedgerEntryType getType() const
std::shared_ptr< STLedgerEntry const > const & ConstRef
bool isFlag(std::uint32_t) const
Definition STObject.cpp:511
bool isFieldPresent(SField const &field) const
Definition STObject.cpp:464
TxType getTxnType() const
Definition STTx.h:250
void visitEntry(bool isDelete, std::shared_ptr< SLE const > const &before, std::shared_ptr< SLE const > const &after)
Track confidential MPT balance, issuance, and version changes.
bool finalize(STTx const &tx, TER const result, XRPAmount const fee, ReadView const &view, beast::Journal const &j)
Verify confidential MPT accounting and encrypted-field invariants.
std::map< UInt192, Changes > changes_
void visitEntry(bool isDelete, SLE::ConstRef before, SLE::ConstRef after)
Track MPT amount and outstanding amount changes.
HashMap< UInt192, MPTData > data_
bool finalize(STTx const &tx, TER const result, XRPAmount const fee, ReadView const &view, beast::Journal const &j)
Verify public MPT payment accounting invariants.
std::uint32_t mptokensCreated_
bool referenceHoldingSetOnCreate_
sfReferenceHolding is intended to be set exactly once at vault creation and immutable thereafter; tru...
std::uint32_t mptokensDeleted_
bool finalize(STTx const &tx, TER const result, XRPAmount const fee, ReadView const &view, beast::Journal const &j) const
Verify MPT issuance invariants after transaction application.
void visitEntry(bool isDelete, SLE::ConstRef before, SLE::ConstRef after)
Track MPT issuance and holding creations, deletions, and mutations.
bool referenceHoldingMutated_
True when sfReferenceHolding was mutated on an existing MPTokenIssuance.
std::uint32_t mptIssuancesCreated_
std::vector< std::shared_ptr< SLE const > > deletedHoldings_
MPTokens and RippleStates deleted during apply.
std::uint32_t issuanceFlagsCleared_
Flags cleared on an existing MPTokenIssuance, except lsfMPTLocked, which tfMPTUnlock clears legitimat...
std::uint32_t mptIssuancesDeleted_
HashMap< AccountID, bool > pseudoAccountsBefore_
bool isAuthorized(ReadView const &view, MPTID const &mptid, AccountID const &holder, bool requireAuth) const
Check whether a holder is authorized to send or receive an MPToken.
void visitEntry(bool isDelete, std::shared_ptr< SLE const > const &before, std::shared_ptr< SLE const > const &after)
Track MPT balance changes and deleted authorization state.
HashMap< UInt192, HashMap< AccountID, Value > > amount_
HashMap< UInt256, bool > deletedAuthorized_
bool finalize(STTx const &tx, TER const result, XRPAmount const fee, ReadView const &view, beast::Journal const &j)
Verify MPT transfer authorization invariants.
T find(T... args)
T min(T... args)
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
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::int64_t maxMPTAmount(SLE const &sleIssuance)
MaximumAmount doesn't exceed 2**63-1.
bool isFeatureEnabled(UInt256 const &feature, bool resultIfNoRules)
Check whether a feature is enabled in the current ledger rules.
Definition Rules.cpp:199
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.
BaseUInt< 192 > UInt192
Definition base_uint.h:582
std::string to_string(BaseUInt< Bits, Tag > const &a)
Definition base_uint.h:658
TER canTrade(ReadView const &view, Asset const &asset, std::uint8_t depth=0)
Check whether asset may be traded on the DEX.
STLedgerEntry SLE
bool hasPrivilege(STTx const &tx, Privilege priv)
std::optional< LoanDefaultFreezeExemptAccounts > getLoanDefaultFreezeExemptAccounts(ReadView const &view, STTx const &tx)
Resolves the accounts and asset a LoanManage default transaction is exempt from freeze/lock for.
BaseUInt< 192 > MPTID
MPTID is a 192-bit value representing MPT Issuance ID, which is a concatenation of a 32-bit sequence ...
Definition UintTypes.h:54
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:668
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.
MPTID makeMptID(std::uint32_t const sequence, AccountID const &account)
Definition Indexes.cpp:219
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.
Definition AccountID.h:34
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.
@ tecINCOMPLETE
Definition TER.h:346
constexpr std::uint64_t kMaxMpTokenAmount
The maximum amount of MPTokenIssuance.
Definition Protocol.h:297
@ tesSUCCESS
Definition TER.h:253