xrpld
Loading...
Searching...
No Matches
InvariantsMPT_test.cpp
1#include <test/app/invariants/InvariantsBase.h>
2#include <test/jtx/Account.h>
3#include <test/jtx/Env.h>
4#include <test/jtx/amount.h>
5#include <test/jtx/mpt.h>
6#include <test/jtx/pay.h>
7#include <test/jtx/trust.h>
8#include <test/jtx/vault.h>
9
10#include <xrpl/basics/base_uint.h>
11#include <xrpl/beast/unit_test/suite.h>
12#include <xrpl/ledger/ApplyView.h>
13#include <xrpl/protocol/AccountID.h>
14#include <xrpl/protocol/Feature.h>
15#include <xrpl/protocol/Indexes.h>
16#include <xrpl/protocol/Issue.h>
17#include <xrpl/protocol/LedgerFormats.h>
18#include <xrpl/protocol/MPTIssue.h>
19#include <xrpl/protocol/Protocol.h>
20#include <xrpl/protocol/SField.h>
21#include <xrpl/protocol/STAmount.h>
22#include <xrpl/protocol/STLedgerEntry.h>
23#include <xrpl/protocol/STObject.h>
24#include <xrpl/protocol/STTx.h>
25#include <xrpl/protocol/SeqProxy.h>
26#include <xrpl/protocol/TER.h>
27#include <xrpl/protocol/TxFlags.h>
28#include <xrpl/protocol/TxFormats.h>
29#include <xrpl/protocol/UintTypes.h>
30#include <xrpl/protocol/XRPAmount.h>
31#include <xrpl/tx/ApplyContext.h>
32#include <xrpl/tx/applySteps.h>
33
34#include <array>
35#include <cstdint>
36#include <functional>
37#include <initializer_list>
38#include <memory>
39#include <ranges>
40#include <source_location>
41#include <string>
42#include <tuple>
43#include <utility>
44#include <vector>
45
46namespace xrpl::test {
47
49{
51
52 void
54 {
55 using namespace test::jtx;
56 testcase << "MPT";
57
58 MPTIssue const nonCanonicalMPTIssue{makeMptID(1, AccountID(0x4985601))};
59 auto const nonCanonicalMPTAmount = [&](SField const& field) {
60 return STAmount{
61 field,
62 nonCanonicalMPTIssue,
64 0,
65 false,
67 };
68 auto const negativeMPTAmount = [&](SField const& field) {
69 return STAmount{field, nonCanonicalMPTIssue, 2, 0, true, STAmount::Unchecked{}};
70 };
71 auto const nonCanonicalMPTPayment = [&] {
72 return STTx{ttPAYMENT, [&](STObject& tx) {
73 tx.setFieldAmount(sfAmount, nonCanonicalMPTAmount(sfAmount));
74 }};
75 };
76
78 makeEnv(all_ - fixCleanup3_2_0),
79 {},
80 [](Account const&, Account const&, ApplyContext&) { return true; },
81 XRPAmount{},
82 nonCanonicalMPTPayment(),
84
86 {{"ledger entry contains non-canonical MPT or XRP amount"}},
87 [&](Account const& a1, Account const& a2, ApplyContext& ac) {
88 auto const sle = ac.view().peek(keylet::account(a1.id()));
89 if (!sle)
90 return false;
91
92 auto const sleNew = std::make_shared<SLE>(
93 keylet::check(a1.id(), SeqProxy::rawSequence((*sle)[sfSequence])));
94 sleNew->setAccountID(sfAccount, a1.id());
95 sleNew->setAccountID(sfDestination, a2.id());
96 sleNew->setFieldAmount(sfSendMax, nonCanonicalMPTAmount(sfSendMax));
97 ac.view().insert(sleNew);
98 return true;
99 });
100
102 {{"ledger entry contains non-canonical MPT or XRP amount"}},
103 [&](Account const& a1, Account const& a2, ApplyContext& ac) {
104 auto const sle = ac.view().peek(keylet::account(a1.id()));
105 if (!sle)
106 return false;
107
108 auto const sleNew = std::make_shared<SLE>(
109 keylet::check(a1.id(), SeqProxy::rawSequence((*sle)[sfSequence])));
110 sleNew->setAccountID(sfAccount, a1.id());
111 sleNew->setAccountID(sfDestination, a2.id());
112 sleNew->setFieldAmount(sfSendMax, negativeMPTAmount(sfSendMax));
113 ac.view().insert(sleNew);
114 return true;
115 });
116
117 // MPT OutstandingAmount > MaximumAmount
119 {{"OutstandingAmount overflow"}},
120 [](Account const& a1, Account const&, ApplyContext& ac) {
121 // mptissuance outstanding is negative
122 auto const sle = ac.view().peek(keylet::account(a1.id()));
123 if (!sle)
124 return false;
125
126 MPTIssue const mpt{makeMptID(sle->getFieldU32(sfSequence), a1)};
127 auto const sleNew = std::make_shared<SLE>(keylet::mptokenIssuance(mpt.getMptID()));
128 sleNew->setFieldU64(sfOutstandingAmount, 110);
129 sleNew->setFieldU64(sfMaximumAmount, 100);
130 ac.view().insert(sleNew);
131 return true;
132 });
133
134 // MPTToken amount doesn't add up to OutstandingAmount
136 {{"invalid OutstandingAmount balance"}},
137 [](Account const& a1, Account const& a2, ApplyContext& ac) {
138 // mptissuance outstanding is negative
139 auto const sle = ac.view().peek(keylet::account(a1.id()));
140 if (!sle)
141 return false;
142
143 MPTIssue const mpt{makeMptID(sle->getFieldU32(sfSequence), a1)};
145 sleNew->setFieldU64(sfOutstandingAmount, 100);
146 sleNew->setFieldU64(sfMaximumAmount, 100);
147 ac.view().insert(sleNew);
148
150 sleNew->setFieldU64(sfMPTAmount, 90);
151 ac.view().insert(sleNew);
152
153 return true;
154 });
155
156 // Overflow/Invalid balance on payment
157 auto const testPayment = [&](std::string const& log, auto&& update) {
158 MPTID id;
160 {{log}},
161 [&](Account const& a1, Account const& a2, ApplyContext& ac) {
162 return update(id, ac, a1);
163 },
164 XRPAmount{},
165 STTx{ttPAYMENT, [](STObject& tx) {}},
167 [&](Account const& a1, Account const& a2, Env& env) {
168 Account const gw("gw");
169 env.fund(XRP(1'000), gw);
170 MPTTester const mpt(
171 {.env = env, .issuer = gw, .holders = {a1}, .pay = 100, .maxAmt = 100});
172 id = mpt.issuanceID();
173 return true;
174 });
175 };
176 testPayment(
177 "invalid OutstandingAmount balance",
178 [&](MPTID const& id, ApplyContext& ac, Account const& a1) {
179 auto const sle = ac.view().peek(keylet::mptoken(id, a1));
180 if (!sle)
181 return false;
182 sle->setFieldU64(sfMPTAmount, 101);
183 ac.view().update(sle);
184 return true;
185 });
186 testPayment(
187 "OutstandingAmount overflow", [&](MPTID const& id, ApplyContext& ac, Account const&) {
188 auto const sle = ac.view().peek(keylet::mptokenIssuance(id));
189 if (!sle)
190 return false;
191 sle->setFieldU64(sfOutstandingAmount, 101);
192 ac.view().update(sle);
193 return true;
194 });
195
196 // The on-failure MPT checks (OutstandingAmount balance / transfer) apply
197 // to every non-tesSUCCESS result, with no per-result exemption: on a tec
198 // the transactor discards the view and re-applies only offer, trust
199 // line, NFT offer and credential deletions, so an MPT change reaching
200 // the invariant is a bug whatever the code. Seeded via initialResult.
201 {
202 MPTID id;
203 // preclose: gw issues an MPT held by A1 and A2.
204 auto const setup = [&](Account const& a1, Account const& a2, Env& env) {
205 Account const gw("gw");
206 env.fund(XRP(1'000), gw);
207 MPTTester const mpt(
208 {.env = env, .issuer = gw, .holders = {a1, a2}, .pay = 50, .maxAmt = 1'000});
209 id = mpt.issuanceID();
210 return true;
211 };
212
213 // Consistent mint: OutstandingAmount and A1's balance both grow by
214 // 10, so conservation holds and only the on-failure check fires.
215 Precheck const mint = [&](Account const& a1, Account const&, ApplyContext& ac) {
216 auto const sleIss = ac.view().peek(keylet::mptokenIssuance(id));
217 auto const sleTok = ac.view().peek(keylet::mptoken(id, a1.id()));
218 if (!sleIss || !sleTok)
219 return false;
220 (*sleIss)[sfOutstandingAmount] = (*sleIss)[sfOutstandingAmount] + 10;
221 (*sleTok)[sfMPTAmount] = (*sleTok)[sfMPTAmount] + 10;
222 ac.view().update(sleIss);
223 ac.view().update(sleTok);
224 return true;
225 };
226
227 // Holder-to-holder transfer (A1 -> A2 by 10). OutstandingAmount is
228 // unchanged, and CanTransfer keeps the ordinary transfer check
229 // quiet, so only the on-failure check fires.
230 Precheck const transfer = [&](Account const& a1, Account const& a2, ApplyContext& ac) {
231 auto const sleIss = ac.view().peek(keylet::mptokenIssuance(id));
232 auto const sleA = ac.view().peek(keylet::mptoken(id, a1.id()));
233 auto const sleB = ac.view().peek(keylet::mptoken(id, a2.id()));
234 if (!sleIss || !sleA || !sleB)
235 return false;
236 (*sleIss)[sfFlags] = (*sleIss)[sfFlags] | lsfMPTCanTransfer;
237 (*sleA)[sfMPTAmount] = (*sleA)[sfMPTAmount] - 10;
238 (*sleB)[sfMPTAmount] = (*sleB)[sfMPTAmount] + 10;
239 ac.view().update(sleIss);
240 ac.view().update(sleA);
241 ac.view().update(sleB);
242 return true;
243 };
244
245 STTx const payment{ttPAYMENT, [](STObject&) {}};
246
247 // Negative controls: nothing fires on tesSUCCESS. Without these, the
248 // cases below would still pass if the result guard were dropped.
249 doInvariantCheck({}, mint, XRPAmount{}, payment, {tesSUCCESS, tesSUCCESS}, setup);
250 doInvariantCheck({}, transfer, XRPAmount{}, payment, {tesSUCCESS, tesSUCCESS}, setup);
251
252 // tecKILLED and tecINCOMPLETE are not special: an MPT change paired
253 // with either fires, as with any other failure.
255 {{"OutstandingAmount balance changed on failure"}},
256 mint,
257 XRPAmount{},
258 payment,
260 setup,
263 tecKILLED);
265 {{"OutstandingAmount balance changed on failure"}},
266 mint,
267 XRPAmount{},
268 payment,
270 setup,
275 {{"MPToken balance changed on failure"}},
276 transfer,
277 XRPAmount{},
278 payment,
280 setup,
283 tecKILLED);
285 {{"MPToken balance changed on failure"}},
286 transfer,
287 XRPAmount{},
288 payment,
290 setup,
294 // The same change under a third failure result: the check keys off
295 // "not tesSUCCESS", nothing finer.
297 {{"OutstandingAmount balance changed on failure"}},
298 mint,
299 XRPAmount{},
300 payment,
302 setup,
305 tecEXPIRED);
307 {{"MPToken balance changed on failure"}},
308 transfer,
309 XRPAmount{},
310 payment,
312 setup,
315 tecEXPIRED);
316
317 // A lock moves value within one holder, so it is not a two-sided
318 // transfer and the `senders || receivers` form is what catches it.
319 // OutstandingAmount and the holder total are unchanged, so the
320 // balance check stays quiet.
321 Precheck const lock = [&](Account const& a1, Account const&, ApplyContext& ac) {
322 auto const sleTok = ac.view().peek(keylet::mptoken(id, a1.id()));
323 if (!sleTok || (*sleTok)[sfMPTAmount] < 10)
324 return false;
325 // A fresh MPToken has no locked amount, so set it directly.
326 (*sleTok)[sfMPTAmount] = (*sleTok)[sfMPTAmount] - 10;
327 sleTok->setFieldU64(sfLockedAmount, 10);
328 ac.view().update(sleTok);
329 return true;
330 };
331 // Negative control: a lock is legitimate on tesSUCCESS.
332 doInvariantCheck({}, lock, XRPAmount{}, payment, {tesSUCCESS, tesSUCCESS}, setup);
334 {{"MPToken balance changed on failure"}},
335 lock,
336 XRPAmount{},
337 payment,
339 setup,
342 tecKILLED);
343 // The lock is caught under any failure result.
345 {{"MPToken balance changed on failure"}},
346 lock,
347 XRPAmount{},
348 payment,
350 setup,
353 tecEXPIRED);
354
355 // A deleted MPToken has no amtAfter, so the sender/receiver counts
356 // skip it and only the deletedAuthorized_ term can catch it. That
357 // needs holders authorized but never paid, so the MPToken can be
358 // erased with a zero balance and OutstandingAmount untouched --
359 // otherwise the holder would register as a sender instead.
360 MPTID emptyId;
361 auto const setupEmpty = [&](Account const& a1, Account const& a2, Env& env) {
362 Account const gw("gw");
363 env.fund(XRP(1'000), gw);
364 MPTTester const mpt({.env = env, .issuer = gw, .holders = {a1, a2}, .maxAmt = 100});
365 emptyId = mpt.issuanceID();
366 return true;
367 };
368 Precheck const eraseToken = [&](Account const& a1, Account const&, ApplyContext& ac) {
369 auto const sleTok = ac.view().peek(keylet::mptoken(emptyId, a1.id()));
370 if (!sleTok || (*sleTok)[sfMPTAmount] != 0)
371 return false;
372 ac.view().erase(sleTok);
373 return true;
374 };
375 // ValidMPTIssuance also reports the deletion, so assert on
376 // ValidMPTTransfer's message, which only the new check can produce.
378 {{"MPToken deleted on failure"}},
379 eraseToken,
380 XRPAmount{},
381 payment,
383 setupEmpty,
386 tecEXPIRED);
387 }
388
389 // Invalid IOU clawback delta must fail once MPTokensV2 enforces before/after validation.
390 {
391 Env env(*this, all_);
392 Account const issuer{"issuer"};
393 Account const holder{"holder"};
394 Account const other{"other"};
395 env.fund(XRP(1'000), issuer, holder, other);
396 auto const usd = issuer["USD"];
397 env.trust(usd(100), holder);
398 env(pay(issuer, holder, usd(100)));
399 env.close();
400
402 std::move(env),
403 holder,
404 other,
405 {{"Invariant failed: trustline clawback balance change is invalid"}},
406 [issuer, usd](Account const& holder, Account const&, ApplyContext& ac) {
407 auto const sle =
408 ac.view().peek(keylet::trustLine(holder.id(), issuer.id(), usd.currency));
409 if (!sle)
410 return false;
411
412 STAmount balance{Issue{usd.currency, issuer.id()}, 80};
413 if (holder.id() > issuer.id())
414 balance.negate();
415 sle->setFieldAmount(sfBalance, balance);
416 ac.view().update(sle);
417 return true;
418 },
419 XRPAmount{},
420 STTx{
421 ttCLAWBACK,
422 [&](STObject& tx) {
423 tx[sfAccount] = issuer.id();
424 tx[sfAmount] = STAmount{Issue{usd.currency, holder.id()}, 10};
425 }},
427 }
428
429 // Full IOU clawback may delete the trustline; missing after-SLE represents zero balance.
430 {
431 Env env(*this, all_);
432 Account const issuer{"issuer"};
433 Account const holder{"holder"};
434 Account const other{"other"};
435 env.fund(XRP(1'000), issuer, holder, other);
436 auto const usd = issuer["USD"];
437 env.trust(usd(100), holder);
438 env(pay(issuer, holder, usd(100)));
439 env.close();
440
442 std::move(env),
443 holder,
444 other,
445 {},
446 [issuer, usd](Account const& holder, Account const&, ApplyContext& ac) {
447 auto const sle =
448 ac.view().peek(keylet::trustLine(holder.id(), issuer.id(), usd.currency));
449 if (!sle)
450 return false;
451
452 ac.view().erase(sle);
453 return true;
454 },
455 XRPAmount{},
456 STTx{
457 ttCLAWBACK,
458 [&](STObject& tx) {
459 tx[sfAccount] = issuer.id();
460 tx[sfAmount] = STAmount{Issue{usd.currency, holder.id()}, 100};
461 }},
463 }
464
465 // Pre-MPTokensV2 invalid IOU clawback delta logs but remains non-enforcing.
466 {
467 Env env(*this, all_ - featureMPTokensV2);
468 Account const issuer{"issuer"};
469 Account const holder{"holder"};
470 Account const other{"other"};
471 env.fund(XRP(1'000), issuer, holder, other);
472 auto const usd = issuer["USD"];
473 env.trust(usd(100), holder);
474 env(pay(issuer, holder, usd(100)));
475 env.close();
476
478 std::move(env),
479 holder,
480 other,
481 {{"Invariant failed: trustline clawback balance change is invalid"}},
482 [issuer, usd](Account const& holder, Account const&, ApplyContext& ac) {
483 auto const sle =
484 ac.view().peek(keylet::trustLine(holder.id(), issuer.id(), usd.currency));
485 if (!sle)
486 return false;
487
488 STAmount balance{Issue{usd.currency, issuer.id()}, 80};
489 if (holder.id() > issuer.id())
490 balance.negate();
491 sle->setFieldAmount(sfBalance, balance);
492 ac.view().update(sle);
493 return true;
494 },
495 XRPAmount{},
496 STTx{
497 ttCLAWBACK,
498 [&](STObject& tx) {
499 tx[sfAccount] = issuer.id();
500 tx[sfAmount] = STAmount{Issue{usd.currency, holder.id()}, 10};
501 }},
503 }
504
505 // Invalid MPT clawback delta must fail when raw MPToken debit mismatches sfAmount.
506 {
507 Env env(*this, all_);
508 Account const issuer{"issuer"};
509 Account const holder{"holder"};
510 Account const other{"other"};
511 env.fund(XRP(1'000), issuer, holder, other);
512 MPTTester const mpt(
513 {.env = env, .issuer = issuer, .holders = {holder}, .pay = 100, .maxAmt = 100});
514 auto const id = mpt.issuanceID();
515
517 std::move(env),
518 holder,
519 other,
520 {{"Invariant failed: MPT clawback balance change is invalid"}},
521 [id](Account const& holder, Account const&, ApplyContext& ac) {
522 auto const sleToken = ac.view().peek(keylet::mptoken(id, holder));
523 auto const sleIssuance = ac.view().peek(keylet::mptokenIssuance(id));
524 if (!sleToken || !sleIssuance)
525 return false;
526
527 sleToken->setFieldU64(sfMPTAmount, 80);
528 sleIssuance->setFieldU64(sfOutstandingAmount, 80);
529 ac.view().update(sleToken);
530 ac.view().update(sleIssuance);
531 return true;
532 },
533 XRPAmount{},
534 STTx{
535 ttCLAWBACK,
536 [&](STObject& tx) {
537 tx[sfAccount] = issuer.id();
538 tx[sfHolder] = holder.id();
539 tx[sfAmount] = STAmount{MPTIssue{id}, 10};
540 }},
542 }
543
544 // A clawback that mutates both IOU and MPT entries must fail under MPTokensV2.
545 {
546 Env env(*this, all_);
547 Account const issuer{"issuer"};
548 Account const holder{"holder"};
549 Account const other{"other"};
550 env.fund(XRP(1'000), issuer, holder, other);
551 auto const usd = issuer["USD"];
552 env.trust(usd(100), holder);
553 env(pay(issuer, holder, usd(100)));
554 MPTTester const mpt(
555 {.env = env, .issuer = issuer, .holders = {holder}, .pay = 100, .maxAmt = 100});
556 auto const id = mpt.issuanceID();
557
559 std::move(env),
560 holder,
561 other,
562 {{"Invariant failed: trustline and MPToken both changed"}},
563 [issuer, usd, id](Account const& holder, Account const&, ApplyContext& ac) {
564 auto const sleLine =
565 ac.view().peek(keylet::trustLine(holder.id(), issuer.id(), usd.currency));
566 auto const sleToken = ac.view().peek(keylet::mptoken(id, holder.id()));
567 auto const sleIssuance = ac.view().peek(keylet::mptokenIssuance(id));
568 if (!sleLine || !sleToken || !sleIssuance)
569 return false;
570
571 STAmount balance{Issue{usd.currency, issuer.id()}, 90};
572 if (holder.id() > issuer.id())
573 balance.negate();
574 sleLine->setFieldAmount(sfBalance, balance);
575 sleToken->setFieldU64(sfMPTAmount, 90);
576 sleIssuance->setFieldU64(sfOutstandingAmount, 90);
577 ac.view().update(sleLine);
578 ac.view().update(sleToken);
579 ac.view().update(sleIssuance);
580 return true;
581 },
582 XRPAmount{},
583 STTx{
584 ttCLAWBACK,
585 [&](STObject& tx) {
586 tx[sfAccount] = issuer.id();
587 tx[sfHolder] = holder.id();
588 tx[sfAmount] = STAmount{MPTIssue{id}, 10};
589 }},
591 }
592
593 // Clawback that modifies a trustline other than the one implied by the
594 // tx amount: clawbackTrustLineBalanceInHolderTerms returns nullopt for
595 // the mismatched line.
596 {
597 Env env(*this, all_);
598 Account const issuer{"issuer"};
599 Account const holder{"holder"};
600 Account const other{"other"};
601 env.fund(XRP(1'000), issuer, holder, other);
602 auto const usd = issuer["USD"];
603 auto const eur = issuer["EUR"];
604 env.trust(eur(100), holder);
605 env(pay(issuer, holder, eur(100)));
606 env.close();
607
609 std::move(env),
610 holder,
611 other,
612 {{"Invariant failed: trustline clawback changed the wrong line"}},
613 [issuer, eur](Account const& holder, Account const&, ApplyContext& ac) {
614 auto const sle =
615 ac.view().peek(keylet::trustLine(holder.id(), issuer.id(), eur.currency));
616 if (!sle)
617 return false;
618 STAmount balance{Issue{eur.currency, issuer.id()}, 90};
619 if (holder.id() > issuer.id())
620 balance.negate();
621 sle->setFieldAmount(sfBalance, balance);
622 ac.view().update(sle);
623 return true;
624 },
625 XRPAmount{},
626 STTx{
627 ttCLAWBACK,
628 [&](STObject& tx) {
629 tx[sfAccount] = issuer.id();
630 tx[sfAmount] = STAmount{Issue{usd.currency, holder.id()}, 10};
631 }},
633 }
634
635 // Clawback leaving the holder's balance negative.
636 {
637 Env env(*this, all_);
638 Account const issuer{"issuer"};
639 Account const holder{"holder"};
640 Account const other{"other"};
641 env.fund(XRP(1'000), issuer, holder, other);
642 auto const usd = issuer["USD"];
643 env.trust(usd(100), holder);
644 env(pay(issuer, holder, usd(100)));
645 env.close();
646
648 std::move(env),
649 holder,
650 other,
651 {{"Invariant failed: trustline or MPT balance is negative"}},
652 [issuer, usd](Account const& holder, Account const&, ApplyContext& ac) {
653 auto const sle =
654 ac.view().peek(keylet::trustLine(holder.id(), issuer.id(), usd.currency));
655 if (!sle)
656 return false;
657 // Make the holder's balance negative from their perspective.
658 STAmount balance{Issue{usd.currency, issuer.id()}, 80};
659 if (holder.id() < issuer.id())
660 balance.negate();
661 sle->setFieldAmount(sfBalance, balance);
662 ac.view().update(sle);
663 return true;
664 },
665 XRPAmount{},
666 STTx{
667 ttCLAWBACK,
668 [&](STObject& tx) {
669 tx[sfAccount] = issuer.id();
670 tx[sfAmount] = STAmount{Issue{usd.currency, holder.id()}, 10};
671 }},
673 }
674
675 // IOU-amount clawback while only an MPToken changed: no trustline was
676 // recorded, so iou_.before is empty.
677 {
678 Env env(*this, all_);
679 Account const issuer{"issuer"};
680 Account const holder{"holder"};
681 Account const other{"other"};
682 env.fund(XRP(1'000), issuer, holder, other);
683 auto const usd = issuer["USD"];
684 MPTTester const mpt(
685 {.env = env, .issuer = issuer, .holders = {holder}, .pay = 100, .maxAmt = 100});
686 auto const id = mpt.issuanceID();
687
689 std::move(env),
690 holder,
691 other,
692 {{"Invariant failed: trustline clawback changed the wrong line"}},
693 [id](Account const& holder, Account const&, ApplyContext& ac) {
694 auto const sleToken = ac.view().peek(keylet::mptoken(id, holder));
695 auto const sleIssuance = ac.view().peek(keylet::mptokenIssuance(id));
696 if (!sleToken || !sleIssuance)
697 return false;
698 sleToken->setFieldU64(sfMPTAmount, 90);
699 sleIssuance->setFieldU64(sfOutstandingAmount, 90);
700 ac.view().update(sleToken);
701 ac.view().update(sleIssuance);
702 return true;
703 },
704 XRPAmount{},
705 STTx{
706 ttCLAWBACK,
707 [&](STObject& tx) {
708 tx[sfAccount] = issuer.id();
709 tx[sfAmount] = STAmount{Issue{usd.currency, holder.id()}, 10};
710 }},
712 }
713
714 // Valid trustline change but a zero clawback amount.
715 {
716 Env env(*this, all_);
717 Account const issuer{"issuer"};
718 Account const holder{"holder"};
719 Account const other{"other"};
720 env.fund(XRP(1'000), issuer, holder, other);
721 auto const usd = issuer["USD"];
722 env.trust(usd(100), holder);
723 env(pay(issuer, holder, usd(100)));
724 env.close();
725
727 std::move(env),
728 holder,
729 other,
730 {{"Invariant failed: trustline clawback amount is invalid"}},
731 [issuer, usd](Account const& holder, Account const&, ApplyContext& ac) {
732 auto const sle =
733 ac.view().peek(keylet::trustLine(holder.id(), issuer.id(), usd.currency));
734 if (!sle)
735 return false;
736 STAmount balance{Issue{usd.currency, issuer.id()}, 90};
737 if (holder.id() > issuer.id())
738 balance.negate();
739 sle->setFieldAmount(sfBalance, balance);
740 ac.view().update(sle);
741 return true;
742 },
743 XRPAmount{},
744 STTx{
745 ttCLAWBACK,
746 [&](STObject& tx) {
747 tx[sfAccount] = issuer.id();
748 tx[sfAmount] = STAmount{Issue{usd.currency, holder.id()}, 0};
749 }},
751 }
752
753 // MPT clawback tx missing the Holder field.
754 {
755 Env env(*this, all_);
756 Account const issuer{"issuer"};
757 Account const holder{"holder"};
758 Account const other{"other"};
759 env.fund(XRP(1'000), issuer, holder, other);
760 MPTTester const mpt(
761 {.env = env, .issuer = issuer, .holders = {holder}, .pay = 100, .maxAmt = 100});
762 auto const id = mpt.issuanceID();
763
765 std::move(env),
766 holder,
767 other,
768 {{"Invariant failed: MPT clawback missing holder"}},
769 [id](Account const& holder, Account const&, ApplyContext& ac) {
770 auto const sleToken = ac.view().peek(keylet::mptoken(id, holder));
771 auto const sleIssuance = ac.view().peek(keylet::mptokenIssuance(id));
772 if (!sleToken || !sleIssuance)
773 return false;
774 sleToken->setFieldU64(sfMPTAmount, 90);
775 sleIssuance->setFieldU64(sfOutstandingAmount, 90);
776 ac.view().update(sleToken);
777 ac.view().update(sleIssuance);
778 return true;
779 },
780 XRPAmount{},
781 STTx{
782 ttCLAWBACK,
783 [&](STObject& tx) {
784 tx[sfAccount] = issuer.id();
785 tx[sfAmount] = STAmount{MPTIssue{id}, 10};
786 }},
788 }
789
790 // MPT clawback where the holder's MPToken was deleted (after is empty).
791 {
792 Env env(*this, all_);
793 Account const issuer{"issuer"};
794 Account const holder{"holder"};
795 Account const other{"other"};
796 env.fund(XRP(1'000), issuer, holder, other);
797 MPTTester const mpt(
798 {.env = env, .issuer = issuer, .holders = {holder}, .pay = 100, .maxAmt = 100});
799 auto const id = mpt.issuanceID();
800
802 std::move(env),
803 holder,
804 other,
805 {{"Invariant failed: MPT clawback token is missing"}},
806 [id](Account const& holder, Account const&, ApplyContext& ac) {
807 auto const sleToken = ac.view().peek(keylet::mptoken(id, holder));
808 auto const sleIssuance = ac.view().peek(keylet::mptokenIssuance(id));
809 if (!sleToken || !sleIssuance)
810 return false;
811 // Keep the issuance consistent after removing the token.
812 sleIssuance->setFieldU64(sfOutstandingAmount, 0);
813 ac.view().update(sleIssuance);
814 ac.view().erase(sleToken);
815 return true;
816 },
817 XRPAmount{},
818 STTx{
819 ttCLAWBACK,
820 [&](STObject& tx) {
821 tx[sfAccount] = issuer.id();
822 tx[sfHolder] = holder.id();
823 tx[sfAmount] = STAmount{MPTIssue{id}, 10};
824 }},
826 }
827
828 // MPT clawback that changed a different holder's MPToken.
829 {
830 Env env(*this, all_);
831 Account const issuer{"issuer"};
832 Account const holder{"holder"};
833 Account const other{"other"};
834 env.fund(XRP(1'000), issuer, holder, other);
835 MPTTester const mpt({
836 .env = env,
837 .issuer = issuer,
838 .holders = {holder, other},
839 .pay = 100,
840 .maxAmt = 200,
841 });
842 auto const id = mpt.issuanceID();
843
845 std::move(env),
846 holder,
847 other,
848 {{"Invariant failed: MPT clawback changed the wrong token"}},
849 [id](Account const&, Account const& other, ApplyContext& ac) {
850 auto const sleToken = ac.view().peek(keylet::mptoken(id, other));
851 auto const sleIssuance = ac.view().peek(keylet::mptokenIssuance(id));
852 if (!sleToken || !sleIssuance)
853 return false;
854 sleToken->setFieldU64(sfMPTAmount, 90);
855 sleIssuance->setFieldU64(sfOutstandingAmount, 190);
856 ac.view().update(sleToken);
857 ac.view().update(sleIssuance);
858 return true;
859 },
860 XRPAmount{},
861 STTx{
862 ttCLAWBACK,
863 [&](STObject& tx) {
864 tx[sfAccount] = issuer.id();
865 tx[sfHolder] = holder.id();
866 tx[sfAmount] = STAmount{MPTIssue{id}, 10};
867 }},
869 }
870
871 // Valid MPToken change but a zero MPT clawback amount.
872 {
873 Env env(*this, all_);
874 Account const issuer{"issuer"};
875 Account const holder{"holder"};
876 Account const other{"other"};
877 env.fund(XRP(1'000), issuer, holder, other);
878 MPTTester const mpt(
879 {.env = env, .issuer = issuer, .holders = {holder}, .pay = 100, .maxAmt = 100});
880 auto const id = mpt.issuanceID();
881
883 std::move(env),
884 holder,
885 other,
886 {{"Invariant failed: MPT clawback amount is invalid"}},
887 [id](Account const& holder, Account const&, ApplyContext& ac) {
888 auto const sleToken = ac.view().peek(keylet::mptoken(id, holder));
889 auto const sleIssuance = ac.view().peek(keylet::mptokenIssuance(id));
890 if (!sleToken || !sleIssuance)
891 return false;
892 sleToken->setFieldU64(sfMPTAmount, 90);
893 sleIssuance->setFieldU64(sfOutstandingAmount, 90);
894 ac.view().update(sleToken);
895 ac.view().update(sleIssuance);
896 return true;
897 },
898 XRPAmount{},
899 STTx{
900 ttCLAWBACK,
901 [&](STObject& tx) {
902 tx[sfAccount] = issuer.id();
903 tx[sfHolder] = holder.id();
904 tx[sfAmount] = STAmount{MPTIssue{id}, 0};
905 }},
907 }
908
909 // More MPTokens created than expected
911 std::make_pair(ttAMM_WITHDRAW, 2),
912 std::make_pair(ttAMM_CLAWBACK, 2),
913 std::make_pair(ttAMM_CREATE, 3),
914 std::make_pair(ttCHECK_CASH, 2),
915 };
916 for (auto const& [tx, nTokens] : tests)
917 {
919 {{std::string("MPToken created for the MPT issuer")}},
920 [&](Account const& a1, Account const& a2, ApplyContext& ac) {
921 auto const sle = ac.view().peek(keylet::account(a1.id()));
922 if (!sle)
923 return false;
924
925 auto seq = sle->getFieldU32(sfSequence);
926 for (int i = 0; i < nTokens; ++i)
927 {
928 MPTIssue const mpt{makeMptID(seq + i, a1)};
929 auto sleNew =
931 ac.view().insert(sleNew);
932
934 ac.view().insert(sleNew);
935 }
936
937 return true;
938 },
939 XRPAmount{},
940 STTx{tx, [](STObject& tx) {}},
942 }
943
944 // More MPTokens deleted than expected
945 for (auto const& tx : {ttAMM_WITHDRAW, ttAMM_CLAWBACK})
946 {
947 MPTID id;
948 Account const a3("A3");
950 {{"MPT authorize succeeded but created/deleted bad number of mptokens"}},
951 [&](Account const& a1, Account const& a2, ApplyContext& ac) {
952 for (auto const& a : {a1, a2, a3})
953 {
954 auto const sle = ac.view().peek(keylet::mptoken(id, a));
955 if (!sle)
956 return false;
957 ac.view().erase(sle);
958 }
959 return true;
960 },
961 XRPAmount{},
962 STTx{tx, [](STObject& tx) {}},
964 [&](Account const& a1, Account const& a2, Env& env) {
965 Account const gw("gw");
966 env.fund(XRP(1'000), gw, a3);
967 MPTTester const mpt({.env = env, .issuer = gw, .holders = {a1, a2, a3}});
968 id = mpt.issuanceID();
969 return true;
970 });
971 }
972
973 // LoanSet / VaultWithdraw MayAuthorizeMpt caps (fixCleanup3_4_0) and
974 // the LoanBrokerDelete cap (fixCleanup3_5_0): LoanSet allows at most
975 // two creates and no deletes; VaultWithdraw and LoanBrokerDelete allow
976 // at most one of each. Fabricate one extra mutation so a too-loose cap
977 // would miss these.
978 {
979 auto const insertHolderTokens =
980 [](Account const& issuer, Account const& holder, ApplyContext& ac, int n) {
981 auto const sle = ac.view().peek(keylet::account(issuer.id()));
982 if (!sle)
983 return false;
984 auto seq = sle->getFieldU32(sfSequence);
985 for (int i = 0; i < n; ++i)
986 {
987 MPTIssue const mpt{makeMptID(seq + i, issuer)};
988 auto const sleNew =
990 (*sleNew)[sfAccount] = holder.id();
991 (*sleNew)[sfMPTokenIssuanceID] = mpt.getMptID();
992 ac.view().insert(sleNew);
993 }
994 return true;
995 };
996
998 {{ttLOAN_SET, 3}, {ttVAULT_WITHDRAW, 2}, {ttLOAN_BROKER_DELETE, 2}},
999 };
1000 for (auto const& [txnType, nTokens] : createOverCap)
1001 {
1003 {{"MPT authorize succeeded but created/deleted bad number mptokens"}},
1004 [&](Account const& a1, Account const& a2, ApplyContext& ac) {
1005 return insertHolderTokens(a1, a2, ac, nTokens);
1006 },
1007 XRPAmount{},
1008 STTx{txnType, [](STObject&) {}},
1010 }
1011
1012 MPTID id;
1013 auto const precloseTwoHolders = [&id](Account const& a1, Account const& a2, Env& env) {
1014 Account const gw("gw");
1015 env.fund(XRP(1'000), gw);
1016 MPTTester const mpt({.env = env, .issuer = gw, .holders = {a1, a2}});
1017 id = mpt.issuanceID();
1018 return true;
1019 };
1021 {{ttLOAN_SET, 1}, {ttVAULT_WITHDRAW, 2}, {ttLOAN_BROKER_DELETE, 2}},
1022 };
1023 for (auto const& [txnType, nTokens] : deleteOverCap)
1024 {
1026 {{"MPT authorize succeeded but created/deleted bad number mptokens"}},
1027 [&](Account const& a1, Account const& a2, ApplyContext& ac) {
1028 std::array const holders{a1, a2};
1029 for (int i = 0; i < nTokens; ++i)
1030 {
1031 auto const sle = ac.view().peek(keylet::mptoken(id, holders[i]));
1032 if (!sle)
1033 return false;
1034 ac.view().erase(sle);
1035 }
1036 return true;
1037 },
1038 XRPAmount{},
1039 STTx{txnType, [](STObject&) {}},
1041 precloseTwoHolders);
1042 }
1043 }
1044
1045 // sfReferenceHolding can only be set on creation by VaultCreate. A
1046 // non-VaultCreate transaction that creates an MPTokenIssuance with
1047 // sfReferenceHolding present must trip the invariant.
1049 {
1050 {
1051 "sfReferenceHolding set on a new MPTokenIssuance by a "
1052 "non-VaultCreate transaction",
1053 },
1054 },
1055 [](Account const& a1, Account const&, ApplyContext& ac) {
1056 auto const sleAcct = ac.view().peek(keylet::account(a1.id()));
1057 if (!sleAcct)
1058 return false;
1059 MPTIssue const mpt{makeMptID(sleAcct->getFieldU32(sfSequence), a1)};
1060 auto const sleNew = std::make_shared<SLE>(keylet::mptokenIssuance(mpt.getMptID()));
1061 sleNew->setFieldH256(sfReferenceHolding, UInt256{1});
1062 ac.view().insert(sleNew);
1063 return true;
1064 },
1065 XRPAmount{},
1066 STTx{ttACCOUNT_SET, [](STObject&) {}});
1067
1068 // sfReferenceHolding is immutable: changing the field on an
1069 // existing MPTokenIssuance must trip the invariant. Set up a real
1070 // vault via preclose (so the share issuance carries
1071 // sfReferenceHolding), then mutate it in precheck to produce a
1072 // before/after pair.
1073 {
1074 UInt256 vaultKey;
1076 {
1077 {
1078 "sfReferenceHolding was modified on an existing "
1079 "MPTokenIssuance",
1080 },
1081 },
1082 [&](Account const&, Account const&, ApplyContext& ac) {
1083 auto const sleVault = ac.view().peek(keylet::vault(vaultKey));
1084 if (!sleVault)
1085 return false;
1086 auto const sleIssuance =
1087 ac.view().peek(keylet::mptokenIssuance(sleVault->at(sfShareMPTID)));
1088 if (!sleIssuance)
1089 return false;
1090 sleIssuance->setFieldH256(sfReferenceHolding, UInt256{2});
1091 ac.view().update(sleIssuance);
1092 return true;
1093 },
1094 XRPAmount{},
1095 STTx{ttACCOUNT_SET, [](STObject&) {}},
1097 [&](Account const& a1, Account const&, Env& env) {
1098 Account const issuer{"issuer"};
1099 env.fund(XRP(10'000), issuer);
1100 env.close();
1101 MPTTester mptt{env, issuer, kMptInitNoFund};
1102 mptt.create({.flags = tfMPTCanTransfer | tfMPTCanLock});
1103 PrettyAsset const asset = mptt.issuanceID();
1104 mptt.authorize({.account = a1});
1105 env.close();
1106
1107 Vault const vault{env};
1108 auto [tx, keylet] = vault.create({.owner = a1, .asset = asset});
1109 env(tx);
1110 env.close();
1111 vaultKey = keylet.key;
1112 return true;
1113 });
1114 }
1115
1116 // lsfMPTLocked is exempt because tfMPTUnlock clears it legitimately.
1117 // Pre-fixCleanup3_5_0: clearing another issuance flag is allowed.
1118 // Post-fixCleanup3_5_0: clearing another issuance flag trips the
1119 // invariant.
1120 {
1121 std::uint32_t allFlags = 0;
1122 for (auto const flag : std::views::values(getMPTokenIssuanceFlags()))
1123 allFlags |= flag;
1124 allFlags &= ~lsfMPTLocked;
1125
1126 MPTID id{};
1127 Preclose const setup = [&](Account const&, Account const&, Env& env) {
1128 Account const issuer{"issuer"};
1129 env.fund(XRP(10'000), issuer);
1130 env.close();
1131 MPTTester mptt{env, issuer, kMptInitNoFund};
1132 mptt.create({.flags = allFlags});
1133 id = mptt.issuanceID();
1134 env.close();
1135 return true;
1136 };
1137 STTx const tx{ttACCOUNT_SET, [](STObject&) {}};
1138
1139 for (auto const flag : std::views::values(getMPTokenIssuanceFlags()))
1140 {
1141 if (flag == lsfMPTLocked)
1142 continue;
1143 Precheck const clearFlag = [&, flag](
1144 Account const&, Account const&, ApplyContext& ac) {
1145 auto const sleIssuance = ac.view().peek(keylet::mptokenIssuance(id));
1146 if (!sleIssuance)
1147 return false;
1148 sleIssuance->setFieldU32(sfFlags, sleIssuance->getFlags() & ~flag);
1149 ac.view().update(sleIssuance);
1150 return true;
1151 };
1152
1154 makeEnv(all_ - fixCleanup3_5_0),
1155 {},
1156 clearFlag,
1157 XRPAmount{},
1158 tx,
1160 setup);
1162 makeEnv(all_),
1163 {{"immutable MPTokenIssuance flag cleared"}},
1164 clearFlag,
1165 XRPAmount{},
1166 tx,
1168 setup);
1169 }
1170 }
1171
1172 // A vault pseudo-account's MPToken cannot be deleted by anything
1173 // other than a VaultDelete transaction. Set up a vault, then have
1174 // an arbitrary tx erase the pseudo's MPToken in precheck.
1175 {
1176 UInt256 vaultKey;
1178 {
1179 {
1180 "vault pseudo-account holding deleted by a "
1181 "non-VaultDelete transaction",
1182 },
1183 },
1184 [&](Account const&, Account const&, ApplyContext& ac) {
1185 auto const sleVault = ac.view().peek(keylet::vault(vaultKey));
1186 if (!sleVault)
1187 return false;
1188 auto const sleIssuance =
1189 ac.view().peek(keylet::mptokenIssuance(sleVault->at(sfShareMPTID)));
1190 if (!sleIssuance || !sleIssuance->isFieldPresent(sfReferenceHolding))
1191 return false;
1192 auto const sleHolding = ac.view().peek(
1193 keylet::unchecked(sleIssuance->getFieldH256(sfReferenceHolding)));
1194 if (!sleHolding)
1195 return false;
1196 ac.view().erase(sleHolding);
1197 return true;
1198 },
1199 XRPAmount{},
1200 STTx{ttACCOUNT_SET, [](STObject&) {}},
1202 [&](Account const& a1, Account const&, Env& env) {
1203 Account const issuer{"issuer"};
1204 env.fund(XRP(10'000), issuer);
1205 env.close();
1206 MPTTester mptt{env, issuer, kMptInitNoFund};
1207 mptt.create({.flags = tfMPTCanTransfer | tfMPTCanLock});
1208 PrettyAsset const asset = mptt.issuanceID();
1209 mptt.authorize({.account = a1});
1210 env.close();
1211
1212 Vault const vault{env};
1213 auto [tx, keylet] = vault.create({.owner = a1, .asset = asset});
1214 env(tx);
1215 env.close();
1216 vaultKey = keylet.key;
1217 return true;
1218 });
1219 }
1220
1221 // Invalid transfer
1222 std::array<std::pair<TxType, bool>, 3> const invalidTransferTests = {
1223 std::make_pair(ttAMM_WITHDRAW, false),
1224 std::make_pair(ttPAYMENT, false),
1225 std::make_pair(ttPAYMENT, true),
1226 };
1227 // The two amendments that gate enforcement, in all four combinations.
1228 FeatureBitset const gatesEnabled{featureMPTokensV2, fixCleanup3_4_0};
1229 for (auto const gates : {
1230 gatesEnabled,
1231 gatesEnabled - featureMPTokensV2,
1232 gatesEnabled - fixCleanup3_4_0,
1233 FeatureBitset{},
1234 })
1235 {
1236 for (auto const& [tx, crossCurrencyPayment] : invalidTransferTests)
1237 {
1238 for (auto const flag : {
1239 static_cast<std::uint32_t>(lsfMPTLocked),
1240 ~lsfMPTCanTransfer,
1241 ~lsfMPTCanTrade,
1242 0u,
1243 })
1244 {
1245 MPTID id{};
1246 // Issuance flags cannot be cleared after creation (and
1247 // ValidMPTIssuance now rejects it), so the CanTransfer /
1248 // CanTrade rows create the issuance without the bit
1249 // instead of stripping it in precheck.
1250 std::uint32_t const createFlags =
1251 (flag == 0u || flag == lsfMPTLocked) ? kMptDexFlags : (kMptDexFlags & flag);
1252 auto const isSuccess = !gates.any() || flag == 0 ||
1253 (tx == ttPAYMENT && !crossCurrencyPayment && (flag == ~lsfMPTCanTrade)) ||
1254 (tx == ttAMM_WITHDRAW &&
1255 (flag == ~lsfMPTCanTrade || flag == ~lsfMPTCanTransfer));
1256 std::pair<TER, TER> const error = isSuccess
1260 {{isSuccess ? "" : "invalid MPToken transfer between holders"}},
1261 [&](Account const& a1, Account const& a2, ApplyContext& ac) {
1262 auto const update = [&](AccountID const& a, std::uint64_t v) {
1263 auto const sle = ac.view().peek(keylet::mptoken(id, a));
1264 if (!sle)
1265 return false;
1266 sle->at(sfMPTAmount) = v;
1267 ac.view().update(sle);
1268 return true;
1269 };
1270 auto const issuanceSle = ac.view().peek(keylet::mptokenIssuance(id));
1271 if (!issuanceSle)
1272 return false;
1273 if (flag == lsfMPTLocked)
1274 {
1275 issuanceSle->at(sfFlags) = issuanceSle->at(sfFlags) | lsfMPTLocked;
1276 }
1277 issuanceSle->at(sfOutstandingAmount) = 200;
1278 ac.view().update(issuanceSle);
1279 return update(a1, 101) && update(a2, 99);
1280 },
1281 XRPAmount{},
1282 STTx{
1283 tx,
1284 [&](STObject& tx) {
1285 if (crossCurrencyPayment)
1286 {
1287 tx.setFieldAmount(
1288 sfSendMax, STAmount(MPTAmount{100}, MPTIssue{id}));
1289 }
1290 }},
1291 {error.first, error.second},
1292 [&](Account const& a1, Account const& a2, Env& env) {
1293 Account const gw("gw");
1294 env.fund(XRP(1'000), gw);
1295 MPTTester const usd({
1296 .env = env,
1297 .issuer = gw,
1298 .holders = {a1, a2},
1299 .pay = 100,
1300 .flags = createFlags,
1301 });
1302 id = usd.issuanceID();
1303 // Either gate enforces, so both must be off to stay
1304 // advisory. Disable after setting up the MPT; the
1305 // next env.close() is what makes it take effect.
1306 if (!gates[featureMPTokensV2])
1307 env.disableFeature(featureMPTokensV2);
1308 if (!gates[fixCleanup3_4_0])
1309 env.disableFeature(fixCleanup3_4_0);
1310 return true;
1311 });
1312 }
1313 }
1314 }
1315
1316 // An orphan has a zero balance, so only deletion is legitimate (see
1317 // "Skipping Deleted MPTs" in testConfidentialMPTTransfer).
1318 {
1319 MPTID orphanID;
1320 auto const setupOrphan = [&](Account const& a1, Account const& a2, Env& env) {
1321 MPTTester mpt(env, a1, {.holders = {a2}, .fund = false});
1322 mpt.create({.flags = tfMPTCanTransfer});
1323 orphanID = mpt.issuanceID();
1324 // A2 is authorized but never paid, so its balance is zero and
1325 // the issuance can be destroyed while its MPToken lives on.
1326 mpt.authorize({.account = a2});
1327 mpt.destroy();
1328 return true;
1329 };
1330 // ValidMPTBalanceChanges also reports this, so assert on the
1331 // orphan message, which only the missing-issuance branch produces.
1333 {{"orphaned MPToken balance changed"}},
1334 [&](Account const&, Account const& a2, ApplyContext& ac) {
1335 auto const sleTok = ac.view().peek(keylet::mptoken(orphanID, a2.id()));
1336 if (!sleTok || (*sleTok)[sfMPTAmount] != 0)
1337 return false;
1338 (*sleTok)[sfMPTAmount] = (*sleTok)[sfMPTAmount] + 10;
1339 ac.view().update(sleTok);
1340 return true;
1341 },
1342 XRPAmount{},
1343 STTx{ttMPTOKEN_AUTHORIZE, [](STObject&) {}},
1345 setupOrphan);
1346 // Negative control: erasing the orphan is how it gets cleaned up.
1348 {},
1349 [&](Account const&, Account const& a2, ApplyContext& ac) {
1350 auto const sleTok = ac.view().peek(keylet::mptoken(orphanID, a2.id()));
1351 if (!sleTok)
1352 return false;
1353 ac.view().erase(sleTok);
1354 return true;
1355 },
1356 XRPAmount{},
1357 STTx{ttMPTOKEN_AUTHORIZE, [](STObject&) {}},
1359 setupOrphan);
1360 // The same erase on a failure. The orphan branch continues, so only
1361 // the pre-loop deletion check can report this one.
1363 {{"MPToken deleted on failure"}},
1364 [&](Account const&, Account const& a2, ApplyContext& ac) {
1365 auto const sleTok = ac.view().peek(keylet::mptoken(orphanID, a2.id()));
1366 if (!sleTok)
1367 return false;
1368 ac.view().erase(sleTok);
1369 return true;
1370 },
1371 XRPAmount{},
1372 STTx{ttMPTOKEN_AUTHORIZE, [](STObject&) {}},
1374 setupOrphan,
1377 tecEXPIRED);
1378 }
1379
1380 // Vault-share freeze invariant: isVaultPseudoAccountFrozen descends
1381 // through sfReferenceHolding to test the vault's underlying asset for
1382 // each changed holder.
1383 {
1384 Account const gw{"gw"};
1385 MPTID shareID{};
1386
1387 // Vault setup: a1 and a2 both deposit IOU and hold vault shares.
1388 auto const setupVault = [&](Account const& a1,
1389 Account const& a2,
1391 env.fund(XRP(1'000), gw);
1392 env.trust(gw["IOU"](10'000), a1);
1393 env.trust(gw["IOU"](10'000), a2);
1394 env.close();
1395 env(pay(gw, a1, gw["IOU"](500)));
1396 env(pay(gw, a2, gw["IOU"](500)));
1397 env.close();
1398
1399 Vault const vault{env};
1400 auto [createTx, vaultKeylet] = vault.create({.owner = a1, .asset = gw["IOU"]});
1401 env(createTx);
1402 env.close();
1403 env(vault.deposit(
1404 {.depositor = a1, .id = vaultKeylet.key, .amount = gw["IOU"](100)}));
1405 env(vault.deposit(
1406 {.depositor = a2, .id = vaultKeylet.key, .amount = gw["IOU"](100)}));
1407 env.close();
1408
1409 return {env.le(vaultKeylet)->at(sfShareMPTID), env.le(vaultKeylet)->at(sfAccount)};
1410 };
1411
1412 // Simulate a vault-share transfer: a1 sends 10 shares to a2.
1413 auto const precheck =
1414 [&](Account const& a1, Account const& a2, ApplyContext& ac) -> bool {
1415 auto const sle1 = ac.view().peek(keylet::mptoken(shareID, a1.id()));
1416 auto const sle2 = ac.view().peek(keylet::mptoken(shareID, a2.id()));
1417 if (!sle1 || !sle2)
1418 return false;
1419 (*sle1)[sfMPTAmount] -= 10;
1420 (*sle2)[sfMPTAmount] += 10;
1421 ac.view().update(sle1);
1422 ac.view().update(sle2);
1423 return true;
1424 };
1425
1426 // Case: vault pseudo-account's IOU trustline is frozen.
1427 {
1428 auto const preclose = [&](Account const& a1, Account const& a2, Env& env) -> bool {
1429 auto [sid, vid] = setupVault(a1, a2, env);
1430 shareID = sid;
1431 env(trust(gw, gw["IOU"](0), Account{"vaultPseudo", vid}, tfSetFreeze));
1432 env.close();
1433 return true;
1434 };
1435
1437 Env{*this, all_},
1438 {{"invalid MPToken transfer between holders"}},
1439 precheck,
1440 XRPAmount{},
1441 STTx{ttPAYMENT, [](STObject&) {}},
1443 preclose);
1444 }
1445
1446 // Case: receiver's (a2's) IOU trustline is frozen.
1447 {
1448 auto const preclose = [&](Account const& a1, Account const& a2, Env& env) -> bool {
1449 auto [sid, vid] = setupVault(a1, a2, env);
1450 shareID = sid;
1451 env(trust(gw, gw["IOU"](0), a2, tfSetFreeze));
1452 env.close();
1453 return true;
1454 };
1455
1457 Env{*this, all_},
1458 {{"invalid MPToken transfer between holders"}},
1459 precheck,
1460 XRPAmount{},
1461 STTx{ttPAYMENT, [](STObject&) {}},
1463 preclose);
1464 }
1465 }
1466 }
1467
1468 void
1470 {
1471 using namespace test::jtx;
1472 testcase << "ValidConfidentialMPToken";
1473
1474 MPTID mptID;
1475
1476 // Generate an MPT with privacy, issue 100 tokens to A2.
1477 // Perform a confidential conversion to populate encrypted state.
1478 auto const precloseConfidential =
1479 [&mptID](Account const& a1, Account const& a2, Env& env) -> bool {
1480 MPTTester mpt(env, a1, {.holders = {a2}, .fund = false});
1481 mpt.create({.flags = tfMPTCanTransfer | tfMPTCanHoldConfidentialBalance});
1482 mptID = mpt.issuanceID();
1483
1484 mpt.authorize({.account = a2});
1485 mpt.pay(a1, a2, 100);
1486
1487 mpt.generateKeyPair(a1);
1488 mpt.set({.account = a1, .issuerPubKey = mpt.getPubKey(a1)});
1489
1490 mpt.generateKeyPair(a2);
1491 mpt.convert({
1492 .account = a2,
1493 .amt = 100,
1494 .holderPubKey = mpt.getPubKey(a2),
1495 });
1496 return true;
1497 };
1498
1499 // badDelete
1501 {"MPToken deleted with encrypted fields while COA > 0"},
1502 [&mptID](Account const& a1, Account const& a2, ApplyContext& ac) {
1503 auto const sleToken = ac.view().peek(keylet::mptoken(mptID, a2.id()));
1504 if (!sleToken)
1505 return false;
1506 // Force an erase of the object while the COA remains 100
1507 ac.view().erase(sleToken);
1508 return true;
1509 },
1510 XRPAmount{},
1511 STTx{ttMPTOKEN_AUTHORIZE, [](STObject&) {}},
1513 precloseConfidential);
1514
1515 // badConsistency
1517 {"MPToken encrypted field existence inconsistency"},
1518 [&mptID](Account const& a1, Account const& a2, ApplyContext& ac) {
1519 auto const sleToken = ac.view().peek(keylet::mptoken(mptID, a2.id()));
1520 if (!sleToken)
1521 return false;
1522 // Remove one of the required encrypted fields to create a mismatch
1523 sleToken->makeFieldAbsent(sfIssuerEncryptedBalance);
1524 ac.view().update(sleToken);
1525 return true;
1526 },
1527 XRPAmount{},
1528 STTx{ttMPTOKEN_AUTHORIZE, [](STObject&) {}},
1530 precloseConfidential);
1531
1533 {"MPToken encrypted field existence inconsistency"},
1534 [&mptID](Account const& a1, Account const& a2, ApplyContext& ac) {
1535 auto const sleToken = ac.view().peek(keylet::mptoken(mptID, a2.id()));
1536 if (!sleToken)
1537 return false;
1538 sleToken->makeFieldAbsent(sfIssuerEncryptedBalance);
1539 sleToken->makeFieldAbsent(sfConfidentialBalanceInbox);
1540 sleToken->makeFieldAbsent(sfConfidentialBalanceSpending);
1541 sleToken->setFieldVL(sfAuditorEncryptedBalance, Blob{0x00});
1542 ac.view().update(sleToken);
1543 return true;
1544 },
1545 XRPAmount{},
1546 STTx{ttMPTOKEN_AUTHORIZE, [](STObject&) {}},
1548 precloseConfidential);
1549
1550 // requiresPrivacyFlag
1551 auto const precloseNoPrivacy = [&mptID](
1552 Account const& a1, Account const& a2, Env& env) -> bool {
1553 MPTTester mpt(env, a1, {.holders = {a2}, .fund = false});
1554 // completely omitted the tfMPTCanHoldConfidentialBalance flag here.
1555 mpt.create({.flags = tfMPTCanTransfer});
1556 mptID = mpt.issuanceID();
1557 mpt.authorize({.account = a2});
1558 mpt.pay(a1, a2, 100);
1559 return true;
1560 };
1561
1563 {
1564 "MPToken has encrypted fields but Issuance does not have "
1565 "lsfMPTCanHoldConfidentialBalance "
1566 "set",
1567 },
1568 [&mptID](Account const& a1, Account const& a2, ApplyContext& ac) {
1569 auto const sleToken = ac.view().peek(keylet::mptoken(mptID, a2.id()));
1570 if (!sleToken)
1571 return false;
1572 // Inject all three encrypted fields consistently (inbox+spending+issuer must be
1573 // in sync or badConsistency fires first and masks requiresPrivacyFlag).
1574 sleToken->setFieldVL(sfConfidentialBalanceInbox, Blob{0x00});
1575 sleToken->setFieldVL(sfConfidentialBalanceSpending, Blob{0x00});
1576 sleToken->setFieldVL(sfIssuerEncryptedBalance, Blob{0x00});
1577 ac.view().update(sleToken);
1578 return true;
1579 },
1580 XRPAmount{},
1581 STTx{ttMPTOKEN_AUTHORIZE, [](STObject&) {}},
1583 precloseNoPrivacy);
1584
1585 // badCOA
1587 {"Confidential outstanding amount exceeds total outstanding amount"},
1588 [&mptID](Account const& a1, Account const& a2, ApplyContext& ac) {
1589 auto const sleIssuance = ac.view().peek(keylet::mptokenIssuance(mptID));
1590 if (!sleIssuance)
1591 return false;
1592 // Total outstanding is natively 100; bloat the COA over 100
1593 sleIssuance->setFieldU64(sfConfidentialOutstandingAmount, 200);
1594 ac.view().update(sleIssuance);
1595 return true;
1596 },
1597 XRPAmount{},
1598 STTx{ttMPTOKEN_ISSUANCE_SET, [](STObject&) {}},
1600 precloseConfidential);
1601
1602 // Conservation Violation
1604 {"Token conservation violation for MPT"},
1605 [&mptID](Account const& a1, Account const& a2, ApplyContext& ac) {
1606 auto const sleIssuance = ac.view().peek(keylet::mptokenIssuance(mptID));
1607 if (!sleIssuance)
1608 return false;
1609
1610 sleIssuance->setFieldU64(
1611 sfConfidentialOutstandingAmount,
1612 sleIssuance->getFieldU64(sfConfidentialOutstandingAmount) - 10);
1613 ac.view().update(sleIssuance);
1614
1615 return true;
1616 },
1617 XRPAmount{},
1618 STTx{ttMPTOKEN_AUTHORIZE, [](STObject&) {}},
1620 precloseConfidential);
1621
1622 // Send/MergeInbox must not change OutstandingAmount (coaDelta == 0)
1624 {
1625 "Invariant failed: OutstandingAmount changed "
1626 "by confidential transaction that should not "
1627 "modify it for MPT",
1628 },
1629 [&mptID](Account const& a1, Account const& a2, ApplyContext& ac) {
1630 auto const sleIssuance = ac.view().peek(keylet::mptokenIssuance(mptID));
1631 if (!sleIssuance)
1632 return false;
1633 sleIssuance->setFieldU64(
1634 sfOutstandingAmount, sleIssuance->getFieldU64(sfOutstandingAmount) + 1);
1635 ac.view().update(sleIssuance);
1636 return true;
1637 },
1638 XRPAmount{},
1639 STTx{ttCONFIDENTIAL_MPT_SEND, [](STObject&) {}},
1641 precloseConfidential);
1642
1643 // Send/MergeInbox and zero-COA-delta confidential transactions must not
1644 // change public holder MPTAmount.
1646 {
1647 "Invariant failed: MPTAmount changed by confidential "
1648 "transaction that should not modify this field.",
1649 },
1650 [&mptID](Account const& a1, Account const& a2, ApplyContext& ac) {
1651 auto const sleToken = ac.view().peek(keylet::mptoken(mptID, a2.id()));
1652 if (!sleToken)
1653 return false;
1654 sleToken->setFieldU64(sfMPTAmount, sleToken->getFieldU64(sfMPTAmount) + 1);
1655 ac.view().update(sleToken);
1656 return true;
1657 },
1658 XRPAmount{},
1659 STTx{ttCONFIDENTIAL_MPT_SEND, [](STObject&) {}},
1660 // Second pass is tef: the bumped MPTAmount also trips
1661 // ValidMPTTransfer's on-failure check, which escalates the tec.
1663 precloseConfidential);
1664
1665 // badVersion
1667 {
1668 "MPToken sfConfidentialBalanceVersion not updated when "
1669 "sfConfidentialBalanceSpending "
1670 "changed",
1671 },
1672 [&mptID](Account const& a1, Account const& a2, ApplyContext& ac) {
1673 Blob const kChangedConfidentialSpending = {0xBA, 0xDD};
1674 auto const sleToken = ac.view().peek(keylet::mptoken(mptID, a2.id()));
1675 if (!sleToken)
1676 return false;
1677 sleToken->setFieldVL(sfConfidentialBalanceSpending, kChangedConfidentialSpending);
1678
1679 // DO NOT update sfConfidentialBalanceVersion
1680 ac.view().update(sleToken);
1681 return true;
1682 },
1683 XRPAmount{},
1684 STTx{ttMPTOKEN_AUTHORIZE, [](STObject&) {}},
1686 precloseConfidential);
1687
1688 // Skipping Deleted MPTs (Issuance deleted)
1689 auto const precloseOrphan = [&mptID](
1690 Account const& a1, Account const& a2, Env& env) -> bool {
1691 MPTTester mpt(env, a1, {.holders = {a2}, .fund = false});
1692 mpt.create({.flags = tfMPTCanTransfer | tfMPTCanHoldConfidentialBalance});
1693 mptID = mpt.issuanceID();
1694 mpt.authorize({.account = a2});
1695
1696 // Generate privacy keys and convert 0 amount so Bob has the encrypted fields
1697 mpt.generateKeyPair(a1);
1698 mpt.set({.account = a1, .issuerPubKey = mpt.getPubKey(a1)});
1699 mpt.generateKeyPair(a2);
1700 mpt.convert({
1701 .account = a2,
1702 .amt = 0,
1703 .holderPubKey = mpt.getPubKey(a2),
1704 });
1705
1706 // Immediately destroy the issuance. A2's empty, encrypted token object lives on.
1707 mpt.destroy();
1708 return true;
1709 };
1710
1712 {},
1713 [&mptID](Account const& a1, Account const& a2, ApplyContext& ac) {
1714 auto const sleToken = ac.view().peek(keylet::mptoken(mptID, a2.id()));
1715 if (!sleToken)
1716 return false;
1717 // Safely able to erase the deleted token.
1718 ac.view().erase(sleToken);
1719 return true;
1720 },
1721 XRPAmount{},
1722 STTx{ttMPTOKEN_AUTHORIZE, [](STObject&) {}},
1724 precloseOrphan);
1725 }
1726
1727 // deletedHoldings_ in ValidMPTIssuance captures every erased MPToken
1728 // per-holder, so finalize()'s fixCleanup3_5_0 balance check must reject
1729 // a funded MPToken erased alongside an empty sibling regardless of the
1730 // order the two are visited in.
1731 void
1733 {
1734 using namespace test::jtx;
1735 testcase << "MPToken deleted with non-zero balance, two holders";
1736
1737 MPTID mptID;
1738 Account const carol{"carol"};
1739
1740 // Single-holder setup used by the baseline and the amendment-gate
1741 // cases.
1742 auto const setupSingle = [&](Account const& a1, Account const& a2, Env& env) -> bool {
1743 MPTTester mpt(env, a1, {.holders = {a2}, .fund = false});
1744 mpt.create({.flags = tfMPTCanTransfer});
1745 mptID = mpt.issuanceID();
1746 mpt.authorize({.account = a2});
1747 mpt.pay(a1, a2, 100);
1748 return true;
1749 };
1750
1751 Precheck const eraseSingle = [&](Account const&, Account const& a2, ApplyContext& ac) {
1752 auto const sleA2 = ac.view().peek(keylet::mptoken(mptID, a2.id()));
1753 if (!sleA2)
1754 return false;
1755 ac.view().erase(sleA2);
1756 return true;
1757 };
1758
1759 Precheck const eraseBoth = [&](Account const&, Account const& a2, ApplyContext& ac) {
1760 auto const sleA2 = ac.view().peek(keylet::mptoken(mptID, a2.id()));
1761 auto const sleCarol = ac.view().peek(keylet::mptoken(mptID, carol.id()));
1762 if (!sleA2 || !sleCarol)
1763 return false;
1764 ac.view().erase(sleA2);
1765 ac.view().erase(sleCarol);
1766 return true;
1767 };
1768
1769 // Cases below expecting `tecINVARIANT_FAILED` use ttACCOUNT_SET; the
1770 // success case (fixCleanup3_5_0 disabled) uses ttMPTOKEN_AUTHORIZE
1771 // to sidestep unrelated invariants that would otherwise mask the
1772 // tesSUCCESS signal.
1773
1774 // Baseline: a single funded MPToken erased on its own.
1776 {{"MPToken deleted with non-zero balance"}},
1777 eraseSingle,
1778 XRPAmount{},
1779 STTx{ttACCOUNT_SET, [](STObject&) {}},
1781 setupSingle);
1782
1783 // Two-holder erase: whichever key sorts last is visited last, so
1784 // funding each holder in turn guarantees one run where the funded
1785 // MPToken is visited first and an empty sibling follows it.
1786 for (bool const fundCarol : {false, true})
1787 {
1788 auto const setupTwo = [&, fundCarol](
1789 Account const& a1, Account const& a2, Env& env) -> bool {
1790 env.fund(XRP(1'000), carol);
1791 MPTTester mpt(env, a1, {.holders = {a2, carol}, .fund = false});
1792 mpt.create({.flags = tfMPTCanTransfer});
1793 mptID = mpt.issuanceID();
1794 mpt.authorize({.account = a2});
1795 mpt.authorize({.account = carol});
1796 mpt.pay(a1, fundCarol ? carol : a2, 100);
1797 return true;
1798 };
1799
1801 {{"MPToken deleted with non-zero balance"}},
1802 eraseBoth,
1803 XRPAmount{},
1804 STTx{ttACCOUNT_SET, [](STObject&) {}},
1806 setupTwo);
1807 }
1808
1809 // fixCleanup3_5_0 enabled, fixCleanup3_2_0 disabled: the two
1810 // amendments are independent, so this is the only configuration in
1811 // which the `|| isFeatureEnabled(fixCleanup3_5_0)` half of the
1812 // deletedHoldings_ capture gate in ValidMPTIssuance::visitEntry is
1813 // load-bearing.
1815 makeEnv(all_ - fixCleanup3_2_0),
1816 {{"MPToken deleted with non-zero balance"}},
1817 eraseSingle,
1818 XRPAmount{},
1819 STTx{ttACCOUNT_SET, [](STObject&) {}},
1821 setupSingle);
1822
1823 // fixCleanup3_5_0 disabled: erasing a funded MPToken must not trip
1824 // the new check. This pins the fixCleanup3_5_0 gate in finalize().
1826 makeEnv(all_ - fixCleanup3_5_0),
1827 {},
1828 eraseSingle,
1829 XRPAmount{},
1830 STTx{ttMPTOKEN_AUTHORIZE, [](STObject&) {}},
1832 setupSingle);
1833 }
1834
1835public:
1836 void
1837 run() override
1838 {
1840 testMPT();
1842 }
1843};
1844
1845BEAST_DEFINE_TESTSUITE(InvariantsMPT, app, xrpl);
1846
1847} // namespace xrpl::test
LogOs< char > log
Logging output stream.
Definition suite.h:150
TestcaseT testcase
Memberspace for declaring test cases.
Definition suite.h:155
State information when applying a tx.
ApplyView & view()
virtual SLE::pointer peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
virtual void insert(SLE::Ref sle)=0
Insert a new state SLE.
virtual void erase(SLE::Ref sle)=0
Remove a peeked SLE.
virtual void update(SLE::Ref sle)=0
Indicate changes to a peeked SLE.
A currency issued by an account.
Definition Issue.h:18
constexpr MPTID const & getMptID() const
Definition MPTIssue.h:43
Identifies fields.
Definition SField.h:131
void negate()
Definition STAmount.h:586
static constexpr SeqProxy rawSequence(std::uint32_t v)
Factory function to return a sequence-based SeqProxy.
Definition SeqProxy.h:62
std::function< bool(test::jtx::Account const &a, test::jtx::Account const &b, ApplyContext &ac)> Precheck
test::jtx::Env makeEnv(FeatureBitset features)
void doInvariantCheck(std::vector< std::string > const &expectLogs, Precheck const &precheck, XRPAmount fee=XRPAmount{}, STTx tx=STTx{ttACCOUNT_SET, [](STObject &) {}}, std::initializer_list< TER > ters={tecINVARIANT_FAILED, tefINVARIANT_FAILED}, Preclose const &preclose={}, TxAccount setTxAccount=TxAccount::None, std::source_location const &loc=std::source_location::current(), TER initialResult=tesSUCCESS)
Run a specific test case to put the ledger into a state that will be detected by an invariant.
std::function< bool(test::jtx::Account const &a, test::jtx::Account const &b, test::jtx::Env &env)> Preclose
void run() override
Runs the suite.
Immutable cryptographic account descriptor.
Definition jtx/Account.h:21
AccountID id() const
Returns the Account ID.
A transaction testing environment.
Definition Env.h:161
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition Env.cpp:133
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition Env.cpp:323
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition Env.cpp:354
Test helper for creating, mutating, and asserting MPT and confidential MPT ledger state.
Definition mpt.h:512
MPTID const & issuanceID() const
Definition mpt.h:777
void create(MPTCreate const &arg=MPTCreate{}, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:346
void authorize(MPTAuthorize const &arg=MPTAuthorize{}, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:459
T current(T... args)
T make_pair(T... args)
T make_shared(T... args)
Keylet computation functions.
Definition Indexes.h:39
Keylet check(AccountID const &id, SeqProxy const &seq) noexcept
A Check.
Definition Indexes.cpp:372
Keylet unchecked(UInt256 const &key) noexcept
Any ledger entry.
Definition Indexes.cpp:409
Keylet vault(AccountID const &owner, SeqProxy const &seq) noexcept
Definition Indexes.cpp:565
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
auto const kMptDexFlags
Definition mpt.h:47
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition pay.cpp:14
XrpT const XRP
Converts to XRP Issue or STAmount.
Definition amount.cpp:92
FeatureBitset testableAmendments()
Definition Env.h:92
json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
Definition trust.cpp:18
static MPTInit const kMptInitNoFund
Definition mpt.h:201
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
STTx createTx(bool disabling, LedgerIndex seq, PublicKey const &txKey)
Create ttUNL_MODIFY Tx.
constexpr XRPAmount
Convert XRP to drops (integral types).
Definition TxTest.h:53
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
@ tefINVARIANT_FAILED
Definition TER.h:177
BaseUInt< 256 > UInt256
Definition base_uint.h:581
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
MPTID makeMptID(std::uint32_t const sequence, AccountID const &account)
Definition Indexes.cpp:219
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:34
TERSubset< CanCvtToTER > TER
Definition TER.h:657
@ tecINCOMPLETE
Definition TER.h:346
@ tecINVARIANT_FAILED
Definition TER.h:324
@ tecEXPIRED
Definition TER.h:325
@ tecKILLED
Definition TER.h:327
std::vector< unsigned char > Blob
Storage for linear binary data.
Definition Blob.h:11
constexpr std::uint64_t kMaxMpTokenAmount
The maximum amount of MPTokenIssuance.
Definition Protocol.h:297
@ tesSUCCESS
Definition TER.h:253