xrpld
Loading...
Searching...
No Matches
mpt.h
1#pragma once
2
3#include <test/jtx/Account.h>
4#include <test/jtx/Env.h>
5#include <test/jtx/amount.h>
6#include <test/jtx/delegate.h>
7#include <test/jtx/owners.h>
8#include <test/jtx/tag.h>
9#include <test/jtx/ter.h>
10#include <test/jtx/ticket.h>
11#include <test/jtx/txflags.h>
12
13#include <xrpl/basics/Buffer.h>
14#include <xrpl/basics/Slice.h>
15#include <xrpl/basics/base_uint.h>
16#include <xrpl/basics/contract.h>
17#include <xrpl/beast/unit_test/suite.h>
18#include <xrpl/core/ServiceRegistry.h>
19#include <xrpl/json/json_value.h>
20#include <xrpl/protocol/AccountID.h>
21#include <xrpl/protocol/Asset.h>
22#include <xrpl/protocol/ConfidentialTransfer.h>
23#include <xrpl/protocol/SField.h>
24#include <xrpl/protocol/TER.h>
25#include <xrpl/protocol/TxFlags.h>
26#include <xrpl/protocol/UintTypes.h>
27#include <xrpl/protocol/XRPAmount.h>
28#include <xrpl/protocol/jss.h>
29
30#include <cstddef>
31#include <cstdint>
32#include <cstring>
33#include <functional>
34#include <optional>
35#include <source_location>
36#include <stdexcept>
37#include <string>
38#include <unordered_map>
39#include <utility>
40#include <variant>
41#include <vector>
42
43namespace xrpl::test::jtx {
44
45class MPTTester;
46
47auto const kMptDexFlags = tfMPTCanTrade | tfMPTCanTransfer;
48
61[[nodiscard]] inline Buffer
63{
64 Buffer b(size);
65 if (size > 0)
66 std::memset(b.data(), 0, size);
67 return b;
68}
69
74{
75private:
79 // Test call site (forwarded from the MPTTester method).
81 // The site where this check object was constructed (usually in mpt.cpp).
83
84public:
86 MPTTester& tester,
87 std::uint32_t flags,
88 std::optional<Account> const& holder = std::nullopt,
91 : tester_(tester), flags_(flags), holder_(holder), testLoc_(testLoc), checkLoc_(checkLoc)
92 {
93 }
94
95 void
96 operator()(Env& env) const;
97};
98
103{
104private:
108 // Test call site (forwarded from the MPTTester method).
110 // The site where this check object was constructed (usually in mpt.cpp).
112
113public:
115 MPTTester& tester,
116 Account const& account,
117 std::int64_t amount,
120 : tester_(tester)
121 , account_(account)
122 , amount_(amount)
123 , testLoc_(testLoc)
124 , checkLoc_(checkLoc)
125 {
126 }
127
128 void
129 operator()(Env& env) const;
130};
131
136{
137private:
139 // Test call site (forwarded from the MPTTester method).
141 // The site where this check object was constructed (usually in mpt.cpp).
143
144public:
146 std::function<bool()> const& cb,
149 : cb_(cb), testLoc_(testLoc), checkLoc_(checkLoc)
150 {
151 }
152
153 void
154 operator()(Env& env) const;
155};
156
158
163{
172 // authorize if seated.
173 // if empty vector then authorize all holders
175 // pay if seated. if authorize is not seated then authorize.
176 // if empty vector then pay to either authorize or all holders.
180 bool authHolder = false;
182 std::optional<TER> err = std::nullopt;
183};
184
189{
190 // Default-initialized so designated-initializer call sites that omit
191 // `holders` don't trip GCC's -Werror=missing-field-initializers.
192 Holders holders = {}; // NOLINT(readability-redundant-member-init)
194 PrettyAmount const xrp = XRP(10'000);
195 PrettyAmount const xrpHolders = XRP(10'000);
196 bool fund = true;
197 bool close = true;
198 // create MPTIssuanceID if seated and follow rules for MPTCreate args
200};
201static MPTInit const kMptInitNoFund{.fund = false};
202
207{
210 Holders holders = {}; // NOLINT(readability-redundant-member-init)
216 bool authHolder = false;
217 bool fund = false;
218 bool close = true;
220 std::optional<TER> err = std::nullopt;
221};
222
235
249
271
276{
278 std::optional<MPTID> id = std::nullopt;
282 // indicates whether to autofill schnorr proof.
283 // default : auto generate proof if holderPubKey is present.
284 // true: force proof generation.
285 // false: force proof omission.
291
299 std::optional<TER> err = std::nullopt;
300};
301
317
348
373
392
410
428
434{
439
443 uint64_t const amt;
444
449
454};
455
484
501 std::uint64_t currentSpending,
502 Slice const& currentEncSpending,
503 std::uint32_t currentVersion,
504 std::uint64_t sendAmt,
505 Slice const& senderEncAmt);
506
512{
518 bool close_;
519 // Keys generated for each account. Buffer vector's index is the key epoch: index 0 is
520 // the initial pair and each rotation appends.
523
524public:
531
536
537 // NOLINTBEGIN(readability-trailing-comma) fix-it drops comma after `{}`
538 MPTTester(
539 Env& env,
541 MPTInit const& constr = {},
543 MPTTester(
544 MPTInitDef const& constr,
546 MPTTester(
547 Env& env,
549 MPTID const& id,
550 std::vector<Account> const& holders = {},
551 bool close = true);
552 operator MPT() const;
553
554 void
555 create(
556 MPTCreate const& arg = MPTCreate{},
558
559 static json::Value
560 createJV(MPTCreate const& arg = MPTCreate{});
561
562 void
563 destroy(
564 MPTDestroy const& arg = MPTDestroy{},
565 std::source_location const& loc = std::source_location::current());
566
567 static json::Value
568 destroyJV(MPTDestroy const& arg = MPTDestroy{});
569
570 void
571 authorize(
572 MPTAuthorize const& arg = MPTAuthorize{},
573 std::source_location const& loc = std::source_location::current());
574
575 static json::Value
576 authorizeJV(MPTAuthorize const& arg = MPTAuthorize{});
577
578 void
580 Holders const& holders,
581 std::source_location const& loc = std::source_location::current());
582
583 void
584 set(MPTSet const& set = {}, std::source_location const& loc = std::source_location::current());
585
586 static json::Value
587 setJV(MPTSet const& set = {});
588
589 void
590 convert(
591 MPTConvert const& arg = MPTConvert{},
592 std::source_location const& loc = std::source_location::current());
593
602 json::Value
603 convertJV(MPTConvert const& arg, std::uint32_t seq);
604
605 void
607 MPTMergeInbox const& arg = MPTMergeInbox{},
608 std::source_location const& loc = std::source_location::current());
609
610 [[nodiscard]] json::Value
611 mergeInboxJV(MPTMergeInbox const& arg = MPTMergeInbox{}) const;
612
613 void
614 send(
615 MPTConfidentialSend const& arg = MPTConfidentialSend{},
616 std::source_location const& loc = std::source_location::current());
617
631 json::Value
632 sendJV(
633 MPTConfidentialSend const& arg,
634 std::uint32_t seq,
635 std::optional<ConfidentialSendChainState> chain = std::nullopt);
636
650 [[nodiscard]] ConfidentialSendChainState
651 chainAfterSend(Account const& sender, std::uint64_t sendAmt, json::Value const& jv) const;
652
653 void
655 MPTConvertBack const& arg = MPTConvertBack{},
656 std::source_location const& loc = std::source_location::current());
657
668 json::Value
669 convertBackJV(MPTConvertBack const& arg, std::uint32_t seq);
670
671 void
673 MPTConfidentialClawback const& arg = MPTConfidentialClawback{},
674 std::source_location const& loc = std::source_location::current());
675
676 void
678 MPTMirrorUpdate const& arg = MPTMirrorUpdate{},
679 std::source_location const& loc = std::source_location::current());
680
681 void
683 MPTHolderKeyUpdate const& arg = MPTHolderKeyUpdate{},
684 std::source_location const& loc = std::source_location::current());
685 // NOLINTEND(readability-trailing-comma)
686
687 [[nodiscard]] bool
688 checkDomainID(std::optional<UInt256> expected) const;
689
690 [[nodiscard]] bool
691 checkMPTokenAmount(Account const& holder, std::int64_t expectedAmount) const;
692
693 [[nodiscard]] bool
694 checkMPTokenOutstandingAmount(std::int64_t expectedAmount) const;
695
696 [[nodiscard]] bool
697 checkIssuanceConfidentialBalance(std::int64_t expectedAmount) const;
698
699 [[nodiscard]] bool
700 checkFlags(uint32_t const expectedFlags, std::optional<Account> const& holder = std::nullopt)
701 const;
702
703 [[nodiscard]] bool
704 checkMetadata(std::string const& metadata) const;
705
706 [[nodiscard]] bool
707 isMetadataPresent() const;
708
709 [[nodiscard]] bool
710 checkTransferFee(std::uint16_t transferFee) const;
711
712 [[nodiscard]] bool
713 isTransferFeePresent() const;
714
715 [[nodiscard]] bool
716 checkImmutableFlags(std::uint32_t expectedFlags) const;
717
718 // Checks both key epochs on the issuance. Pass std::nullopt for an epoch
719 // that is expected to be absent, which means the key is never rotated.
720 [[nodiscard]] bool
722 std::optional<std::uint32_t> issuerKeyEpoch,
723 std::optional<std::uint32_t> auditorKeyEpoch) const;
724
725 // Checks both mirror epochs on a holder's MPToken. Pass std::nullopt for an
726 // epoch that is expected to be absent, which means the mirror was written
727 // under the issuance's epoch 0 key.
728 [[nodiscard]] bool
730 Account const& holder,
731 std::optional<std::uint32_t> issuerKeyMirrorEpoch,
732 std::optional<std::uint32_t> auditorKeyMirrorEpoch) const;
733
734 // Checks that the issuance carries the encryption keys of the given
735 // accounts. Pass std::nullopt for a key that is expected to be absent,
736 // which means the key is never registered.
737 [[nodiscard]] bool
739 std::optional<Account> const& issuerKeyOwner,
740 std::optional<Account> const& auditorKeyOwner) const;
741
742 [[nodiscard]] bool
743 checkInitialIssuerKey(std::optional<Buffer> const& expected) const;
744
745 [[nodiscard]] bool
746 checkIssuerMirrorEncryptionKey(std::optional<Buffer> const& expected, Account const& holder)
747 const;
748
749 [[nodiscard]] Account const&
750 issuer() const
751 {
752 return issuer_;
753 }
754 [[nodiscard]] Account const&
755 holder(std::string const& h) const;
756
757 void
758 pay(Account const& src,
759 Account const& dest,
760 std::int64_t amount,
761 std::optional<TER> err = std::nullopt,
764
765 void
766 claw(
767 Account const& issuer,
768 Account const& holder,
769 std::int64_t amount,
770 std::optional<TER> err = std::nullopt,
772
773 [[nodiscard]] PrettyAmount
774 mpt(std::int64_t amount) const;
775
776 [[nodiscard]] MPTID const&
778 {
779 if (!env_.test.BEAST_EXPECT(id_))
780 Throw<std::logic_error>("Uninitialized issuanceID");
781 return *id_; // NOLINT(bugprone-unchecked-optional-access)
782 }
783
784 [[nodiscard]] std::int64_t
785 getBalance(Account const& account) const;
786
787 [[nodiscard]] std::int64_t
789
790 [[nodiscard]] std::optional<Buffer>
792 const;
793
794 MPT
795 operator[](std::string const& name) const;
796
798 operator()(std::int64_t amount) const;
799
800 operator Asset() const;
801
802 // Generates the account's next key pair and returns the key epoch it landed
803 // at, leaving the earlier ones retrievable.
805 generateKeyPair(Account const& account);
806
807 // Returns the account's public key at the given key epoch, or its latest key when
808 // no epoch is given.
809 [[nodiscard]] std::optional<Buffer>
810 getPubKey(Account const& account, std::optional<std::uint32_t> epoch = std::nullopt) const;
811
812 // Returns the account's private key at the given key epoch, or its latest key when
813 // no epoch is given.
814 [[nodiscard]] std::optional<Buffer>
815 getPrivKey(Account const& account, std::optional<std::uint32_t> epoch = std::nullopt) const;
816
817 [[nodiscard]] Buffer
818 encryptAmount(Account const& account, uint64_t const amt, Buffer const& blindingFactor) const;
819
820 // Decrypts with the account's key at the given key epoch, or its latest key
821 // when no epoch is given.
822 [[nodiscard]] std::optional<uint64_t>
824 Account const& account,
825 Buffer const& amt,
826 std::optional<std::uint32_t> epoch = std::nullopt) const;
827
828 [[nodiscard]] std::optional<uint64_t>
829 getDecryptedBalance(Account const& account, EncryptedBalanceType balanceType) const;
830
831 [[nodiscard]] std::optional<std::int64_t>
833
834 [[nodiscard]] std::optional<Buffer>
836 Account const& holder,
837 std::uint64_t amount,
838 Buffer const& privateKey,
839 UInt256 const& txHash) const;
840
841 [[nodiscard]] std::optional<Buffer>
842 getSchnorrProof(Account const& account, UInt256 const& ctxHash) const;
843
844 [[nodiscard]] std::optional<Buffer>
846 Account const& sender,
847 std::uint64_t const amount,
848 std::vector<ConfidentialRecipient> const& recipients,
849 Slice const& blindingFactor,
850 UInt256 const& contextHash,
851 PedersenProofParams const& amountParams,
852 PedersenProofParams const& balanceParams) const;
853
854 [[nodiscard]] std::optional<Buffer>
856 Account const& holder,
857 std::uint64_t const amount,
858 UInt256 const& contextHash,
859 PedersenProofParams const& pcParams) const;
860
861 [[nodiscard]] std::uint32_t
862 getMPTokenVersion(Account const account) const;
863
864 static Buffer
865 getPedersenCommitment(std::uint64_t const amount, Buffer const& pedersenBlindingFactor);
866
867 friend BookSpec
869 {
870 return ~static_cast<MPT>(mpt);
871 }
872
873private:
875 bool
876 forObject(
877 std::function<bool(SLEP const& sle)> const& cb,
878 std::optional<Account> const& holder = std::nullopt) const;
879
880 // Reads one of the holder's mirror key epochs off their MPToken.
881 [[nodiscard]] std::optional<std::uint32_t>
882 getMirrorEpoch(Account const& holder, SF_UINT32 const& field) const;
883
884 template <typename A>
885 TER
887 {
888 auto const expectedFlags = Txflags(arg.flags.value_or(0));
889 auto const expectedTer = Ter(arg.err.value_or(tesSUCCESS));
890
891 if constexpr (requires { arg.fee; })
892 {
893 if (arg.fee)
894 jv.value[jss::Fee] = to_string(*arg.fee);
895 }
896
898 if constexpr (requires { arg.ticketSeq; })
899 ticketSeq = arg.ticketSeq;
900
901 std::optional<Account> delegateAcct;
902 if constexpr (requires { arg.delegate; })
903 delegateAcct = arg.delegate;
904
906 if constexpr (requires { arg.destinationTag; })
907 dstTag = arg.destinationTag;
908
909 if (ticketSeq && delegateAcct)
910 {
911 env_(
912 jv,
913 expectedFlags,
914 expectedTer,
915 ticket::Use(*ticketSeq),
916 delegate::As(*delegateAcct));
917 }
918 else if (ticketSeq)
919 {
920 env_(jv, expectedFlags, expectedTer, ticket::Use(*ticketSeq));
921 }
922 else if (delegateAcct)
923 {
924 env_(jv, expectedFlags, expectedTer, delegate::As(*delegateAcct));
925 }
926 else if (dstTag)
927 {
928 env_(jv, expectedFlags, expectedTer, Dtag(*dstTag));
929 }
930 else
931 {
932 env_(jv, expectedFlags, expectedTer);
933 }
934 auto const err = env_.ter();
935 if (close_)
936 env_.close();
937 if (arg.ownerCount)
938 env_.require(Owners(issuer_, *arg.ownerCount));
939 if (arg.holderCount)
940 {
941 for (auto const& it : holders_)
942 env_.require(Owners(it.second, *arg.holderCount));
943 }
944 return err;
945 }
946
948 makeHolders(std::vector<Account> const& holders);
949
950 [[nodiscard]] std::uint32_t
952
960 void
962
963 [[nodiscard]] std::uint32_t
965 std::optional<std::uint32_t> const& ticketSeq,
966 std::optional<Account> const& account) const;
967
968 template <typename T>
969 void
971 T const& arg,
972 json::Value& jv,
973 Account const& account,
974 std::uint64_t const amount) const;
975
976 [[nodiscard]] bool
978 std::optional<Buffer> const& expected,
979 SF_VL const& field,
980 std::optional<Account> const& holder = std::nullopt) const;
981};
982
983} // namespace xrpl::test::jtx
Represents a JSON value.
Definition json_value.h:121
Like std::vector<char> but better.
Definition Buffer.h:19
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
Definition Buffer.h:148
std::shared_ptr< STLedgerEntry const > const_pointer
An immutable linear range of bytes.
Definition Slice.h:28
Immutable cryptographic account descriptor.
Definition jtx/Account.h:21
A transaction testing environment.
Definition Env.h:161
Test helper for creating, mutating, and asserting MPT and confidential MPT ledger state.
Definition mpt.h:512
std::unordered_map< AccountID, std::vector< Buffer > > pubKeys_
Definition mpt.h:521
static constexpr auto holderEncryptedInbox
Definition mpt.h:533
void mirrorUpdate(MPTMirrorUpdate const &arg=MPTMirrorUpdate{}, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:2290
std::optional< std::uint32_t > getMirrorEpoch(Account const &holder, SF_UINT32 const &field) const
Definition mpt.cpp:797
std::unordered_map< std::string, Account > const holders_
Definition mpt.h:515
Buffer encryptAmount(Account const &account, uint64_t const amt, Buffer const &blindingFactor) const
Definition mpt.cpp:1942
bool forObject(std::function< bool(SLEP const &sle)> const &cb, std::optional< Account > const &holder=std::nullopt) const
Definition mpt.cpp:679
void mergeInbox(MPTMergeInbox const &arg=MPTMergeInbox{}, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:2032
bool checkMPTokenAmount(Account const &holder, std::int64_t expectedAmount) const
Definition mpt.cpp:702
std::optional< MPTID > id_
Definition mpt.h:517
json::Value convertJV(MPTConvert const &arg, std::uint32_t seq)
Build a confidential convert JV without submitting it.
Definition mpt.cpp:1434
static Buffer getPedersenCommitment(std::uint64_t const amount, Buffer const &pedersenBlindingFactor)
Definition mpt.cpp:1110
static json::Value destroyJV(MPTDestroy const &arg=MPTDestroy{})
Definition mpt.cpp:412
void setIssuanceIdField(json::Value &jv, std::optional< MPTID > const &id) const
Sets sfMPTokenIssuanceID on jv, falling back to id_ if arg's id is not set.
Definition mpt.cpp:1219
std::optional< Buffer > getEncryptedBalance(Account const &account, EncryptedBalanceType option=holderEncryptedInbox) const
Definition mpt.cpp:1171
void convertBack(MPTConvertBack const &arg=MPTConvertBack{}, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:2139
std::optional< uint64_t > getDecryptedBalance(Account const &account, EncryptedBalanceType balanceType) const
Definition mpt.cpp:1990
bool checkMirrorEpochs(Account const &holder, std::optional< std::uint32_t > issuerKeyMirrorEpoch, std::optional< std::uint32_t > auditorKeyMirrorEpoch) const
Definition mpt.cpp:783
Account const & holder(std::string const &h) const
Definition mpt.cpp:435
static json::Value authorizeJV(MPTAuthorize const &arg=MPTAuthorize{})
Definition mpt.cpp:444
bool isTransferFeePresent() const
Definition mpt.cpp:757
std::optional< Buffer > getClawbackProof(Account const &holder, std::uint64_t amount, Buffer const &privateKey, UInt256 const &txHash) const
Definition mpt.cpp:986
friend BookSpec operator~(MPTTester const &mpt)
Definition mpt.h:868
bool checkMetadata(std::string const &metadata) const
Definition mpt.cpp:730
std::uint32_t generateKeyPair(Account const &account)
Definition mpt.cpp:1905
bool checkFlags(uint32_t const expectedFlags, std::optional< Account > const &holder=std::nullopt) const
Definition mpt.cpp:724
bool isMetadataPresent() const
Definition mpt.cpp:740
MPT operator[](std::string const &name) const
Definition mpt.cpp:1246
void holderKeyUpdate(MPTHolderKeyUpdate const &arg=MPTHolderKeyUpdate{}, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:2319
std::optional< Buffer > getSchnorrProof(Account const &account, UInt256 const &ctxHash) const
Definition mpt.cpp:1026
static constexpr auto issuerEncryptedBalance
Definition mpt.h:532
bool checkDomainID(std::optional< UInt256 > expected) const
Definition mpt.cpp:692
std::uint32_t getMPTokenVersion(Account const account) const
Definition mpt.cpp:2123
bool checkIssuerMirrorEncryptionKey(std::optional< Buffer > const &expected, Account const &holder) const
Definition mpt.cpp:853
Account const & issuer() const
Definition mpt.h:750
std::optional< std::int64_t > getIssuanceOutstandingBalance() const
Definition mpt.cpp:2109
static json::Value createJV(MPTCreate const &arg=MPTCreate{})
Definition mpt.cpp:322
MPTTester(Env &env, Account issuer, MPTInit const &constr={}, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:229
json::Value sendJV(MPTConfidentialSend const &arg, std::uint32_t seq, std::optional< ConfidentialSendChainState > chain=std::nullopt)
Build a confidential send JV.
Definition mpt.cpp:1605
ConfidentialSendChainState chainAfterSend(Account const &sender, std::uint64_t sendAmt, json::Value const &jv) const
Compute the projected sender state after a confidential send in a batch.
Definition mpt.cpp:1791
static json::Value setJV(MPTSet const &set={})
Definition mpt.cpp:538
MPTID const & issuanceID() const
Definition mpt.h:777
static constexpr auto holderEncryptedSpending
Definition mpt.h:534
std::optional< uint64_t > decryptAmount(Account const &account, Buffer const &amt, std::optional< std::uint32_t > epoch=std::nullopt) const
Definition mpt.cpp:1957
void send(MPTConfidentialSend const &arg=MPTConfidentialSend{}, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:1463
bool checkEncryptionKeys(std::optional< Account > const &issuerKeyOwner, std::optional< Account > const &auditorKeyOwner) const
Definition mpt.cpp:810
bool checkImmutableFlags(std::uint32_t expectedFlags) const
Definition mpt.cpp:763
std::int64_t getBalance(Account const &account) const
Definition mpt.cpp:956
TER submit(A const &arg, WithSourceLocation< json::Value > jv)
Definition mpt.h:886
void fillConversionCiphertexts(T const &arg, json::Value &jv, Account const &account, std::uint64_t const amount) const
Definition mpt.cpp:1259
std::optional< Buffer > getConfidentialSendProof(Account const &sender, std::uint64_t const amount, std::vector< ConfidentialRecipient > const &recipients, Slice const &blindingFactor, UInt256 const &contextHash, PedersenProofParams const &amountParams, PedersenProofParams const &balanceParams) const
Definition mpt.cpp:1049
std::optional< Buffer > getPubKey(Account const &account, std::optional< std::uint32_t > epoch=std::nullopt) const
Definition mpt.cpp:1930
std::optional< Account > const auditor_
Definition mpt.h:516
Account const issuer_
Definition mpt.h:514
json::Value mergeInboxJV(MPTMergeInbox const &arg=MPTMergeInbox{}) const
Definition mpt.cpp:2022
void authorizeHolders(Holders const &holders, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:529
SLE::const_pointer SLEP
Definition mpt.h:874
static constexpr auto auditorEncryptedBalance
Definition mpt.h:535
void pay(Account const &src, Account const &dest, std::int64_t amount, std::optional< TER > err=std::nullopt, std::optional< std::vector< std::string > > credentials=std::nullopt, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:861
std::unordered_map< AccountID, std::vector< Buffer > > privKeys_
Definition mpt.h:522
void claw(Account const &issuer, Account const &holder, std::int64_t amount, std::optional< TER > err=std::nullopt, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:916
void confidentialClaw(MPTConfidentialClawback const &arg=MPTConfidentialClawback{}, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:1831
PrettyAmount mpt(std::int64_t amount) const
Definition mpt.cpp:940
void create(MPTCreate const &arg=MPTCreate{}, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:346
void set(MPTSet const &set={}, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:581
std::int64_t getIssuanceConfidentialBalance() const
Definition mpt.cpp:974
std::uint32_t ticketOrSeq(std::optional< std::uint32_t > const &ticketSeq, std::optional< Account > const &account) const
Definition mpt.cpp:1236
bool checkTransferFee(std::uint16_t transferFee) const
Definition mpt.cpp:747
bool checkInitialIssuerKey(std::optional< Buffer > const &expected) const
Definition mpt.cpp:847
bool checkIssuanceConfidentialBalance(std::int64_t expectedAmount) const
Definition mpt.cpp:716
void authorize(MPTAuthorize const &arg=MPTAuthorize{}, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:459
bool checkEncryptionKey(std::optional< Buffer > const &expected, SF_VL const &field, std::optional< Account > const &holder=std::nullopt) const
Definition mpt.cpp:831
PrettyAmount operator()(std::int64_t amount) const
Definition mpt.cpp:1252
std::uint32_t getFlags(std::optional< Account > const &holder) const
Definition mpt.cpp:1205
bool checkKeyEpochs(std::optional< std::uint32_t > issuerKeyEpoch, std::optional< std::uint32_t > auditorKeyEpoch) const
Definition mpt.cpp:772
static std::unordered_map< std::string, Account > makeHolders(std::vector< Account > const &holders)
Definition mpt.cpp:217
bool checkMPTokenOutstandingAmount(std::int64_t expectedAmount) const
Definition mpt.cpp:709
void convert(MPTConvert const &arg=MPTConvert{}, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:1301
std::optional< Buffer > getPrivKey(Account const &account, std::optional< std::uint32_t > epoch=std::nullopt) const
Definition mpt.cpp:1936
void destroy(MPTDestroy const &arg=MPTDestroy{}, std::source_location const &loc=std::source_location::current())
Definition mpt.cpp:425
std::optional< Buffer > getConvertBackProof(Account const &holder, std::uint64_t const amount, UInt256 const &contextHash, PedersenProofParams const &pcParams) const
Definition mpt.cpp:1136
json::Value convertBackJV(MPTConvertBack const &arg, std::uint32_t seq)
Build a confidential convertBack JV without submitting it.
Definition mpt.cpp:2227
Converts to MPT Issue or STAmount.
std::source_location testLoc_
Definition mpt.h:109
MptBalance(MPTTester &tester, Account const &account, std::int64_t amount, std::source_location const &testLoc=std::source_location::current(), std::source_location const &checkLoc=std::source_location::current())
Definition mpt.h:114
MPTTester const & tester_
Definition mpt.h:105
std::int64_t const amount_
Definition mpt.h:107
Account const & account_
Definition mpt.h:106
void operator()(Env &env) const
Definition mpt.cpp:201
std::source_location checkLoc_
Definition mpt.h:111
std::uint32_t flags_
Definition mpt.h:77
std::source_location checkLoc_
Definition mpt.h:82
MptFlags(MPTTester &tester, std::uint32_t flags, std::optional< Account > const &holder=std::nullopt, std::source_location const &testLoc=std::source_location::current(), std::source_location const &checkLoc=std::source_location::current())
Definition mpt.h:85
void operator()(Env &env) const
Definition mpt.cpp:191
std::optional< Account > holder_
Definition mpt.h:78
MPTTester & tester_
Definition mpt.h:76
std::source_location testLoc_
Definition mpt.h:80
Match the number of items in the account's owner directory.
Definition owners.h:55
std::function< bool()> cb_
Definition mpt.h:138
std::source_location testLoc_
Definition mpt.h:140
RequireAny(std::function< bool()> const &cb, std::source_location const &testLoc=std::source_location::current(), std::source_location const &checkLoc=std::source_location::current())
Definition mpt.h:145
void operator()(Env &env) const
Definition mpt.cpp:211
std::source_location checkLoc_
Definition mpt.h:142
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition ter.h:18
Set the flags on a JTx.
Definition txflags.h:14
Set a ticket sequence on a JTx.
Definition ticket.h:36
T current(T... args)
T memset(T... args)
auto const kMptDexFlags
Definition mpt.h:47
Buffer gMakeZeroBuffer(std::size_t size)
Create a zero-initialized buffer for malformed cryptography test inputs.
Definition mpt.h:62
XrpT const XRP
Converts to XRP Issue or STAmount.
Definition amount.cpp:92
std::vector< Account > Holders
Definition mpt.h:157
std::optional< ConfidentialSendChainState > computeNextSendChainState(std::uint64_t currentSpending, Slice const &currentEncSpending, std::uint32_t currentVersion, std::uint64_t sendAmt, Slice const &senderEncAmt)
Use this when building a second (or later) confidential send from the same account in the same batch.
Definition mpt.cpp:1809
static MPTInit const kMptInitNoFund
Definition mpt.h:201
TypedField< STInteger< std::uint32_t > > SF_UINT32
Definition SField.h:343
std::string to_string(BaseUInt< Bits, Tag > const &a)
Definition base_uint.h:658
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
TypedField< STBlob > SF_VL
Definition SField.h:361
TERSubset< CanCvtToTER > TER
Definition TER.h:657
@ tesSUCCESS
Definition TER.h:253
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
Definition contract.h:52
When building multiple confidential sends from the same account inside a single batch transaction,...
Definition mpt.h:468
std::uint32_t version
sfConfidentialBalanceVersion after the previous send.
Definition mpt.h:482
std::uint64_t spending
Decrypted spending balance after the previous send.
Definition mpt.h:472
Buffer encSpending
Encrypted spending balance after the previous send.
Definition mpt.h:477
Set the destination tag on a JTx.
Definition tag.h:14
Arguments for building an MPTokenAuthorize test transaction.
Definition mpt.h:240
std::optional< std::uint32_t > ownerCount
Definition mpt.h:244
std::optional< std::uint32_t > holderCount
Definition mpt.h:245
std::optional< Account > holder
Definition mpt.h:242
std::optional< Account > account
Definition mpt.h:241
std::optional< TER > err
Definition mpt.h:247
std::optional< std::uint32_t > flags
Definition mpt.h:246
Arguments for building a ConfidentialMPTClawback test transaction.
Definition mpt.h:378
std::optional< std::uint32_t > holderCount
Definition mpt.h:387
std::optional< std::uint32_t > ownerCount
Definition mpt.h:386
std::optional< std::uint32_t > ticketSeq
Definition mpt.h:385
std::optional< std::string > proof
Definition mpt.h:383
std::optional< std::uint64_t > amt
Definition mpt.h:382
std::optional< XRPAmount > fee
Definition mpt.h:389
std::optional< Account > delegate
Definition mpt.h:384
std::optional< std::uint32_t > flags
Definition mpt.h:388
std::optional< Account > account
Definition mpt.h:379
std::optional< Account > holder
Definition mpt.h:380
Arguments for building a ConfidentialMPTSend test transaction.
Definition mpt.h:322
std::optional< XRPAmount > fee
Definition mpt.h:345
std::optional< std::vector< std::string > > credentials
Definition mpt.h:334
std::optional< TER > err
Definition mpt.h:346
std::optional< Buffer > balanceCommitment
Definition mpt.h:338
std::optional< std::uint32_t > ticketSeq
Definition mpt.h:341
std::optional< std::uint32_t > holderCount
Definition mpt.h:343
std::optional< std::uint64_t > amt
Definition mpt.h:327
std::optional< bool > fillAuditorEncryptedAmt
Definition mpt.h:333
std::optional< std::uint32_t > destinationTag
Definition mpt.h:340
std::optional< Account > account
Definition mpt.h:323
std::optional< Buffer > auditorEncryptedAmt
Definition mpt.h:332
std::optional< Account > dest
Definition mpt.h:324
std::optional< std::uint32_t > flags
Definition mpt.h:344
std::optional< Buffer > blindingFactor
Definition mpt.h:336
std::optional< Buffer > amountCommitment
Definition mpt.h:337
std::optional< Account > delegate
Definition mpt.h:339
std::optional< std::string > proof
Definition mpt.h:328
std::optional< Buffer > senderEncryptedAmt
Definition mpt.h:329
std::optional< Buffer > destEncryptedAmt
Definition mpt.h:330
std::optional< Buffer > issuerEncryptedAmt
Definition mpt.h:331
std::optional< std::uint32_t > ownerCount
Definition mpt.h:342
Arguments for building a ConfidentialMPTConvertBack test transaction.
Definition mpt.h:353
std::optional< Buffer > auditorEncryptedAmt
Definition mpt.h:360
std::optional< Account > delegate
Definition mpt.h:365
std::optional< std::uint32_t > holderCount
Definition mpt.h:368
std::optional< Buffer > issuerEncryptedAmt
Definition mpt.h:359
std::optional< std::uint32_t > ownerCount
Definition mpt.h:367
std::optional< std::uint64_t > amt
Definition mpt.h:356
std::optional< Account > account
Definition mpt.h:354
std::optional< XRPAmount > fee
Definition mpt.h:370
std::optional< std::uint32_t > ticketSeq
Definition mpt.h:366
std::optional< std::uint32_t > flags
Definition mpt.h:369
std::optional< Buffer > holderEncryptedAmt
Definition mpt.h:358
std::optional< Buffer > proof
Definition mpt.h:357
std::optional< TER > err
Definition mpt.h:371
std::optional< Buffer > blindingFactor
Definition mpt.h:363
std::optional< Buffer > pedersenCommitment
Definition mpt.h:364
std::optional< bool > fillAuditorEncryptedAmt
Definition mpt.h:361
Arguments for building a ConfidentialMPTConvert test transaction.
Definition mpt.h:276
std::optional< bool > fillAuditorEncryptedAmt
Definition mpt.h:281
std::optional< std::uint32_t > ownerCount
Definition mpt.h:295
std::optional< std::uint64_t > amt
Definition mpt.h:279
std::optional< Buffer > holderEncryptedAmt
Definition mpt.h:288
std::optional< Buffer > auditorEncryptedAmt
Definition mpt.h:290
std::optional< bool > fillSchnorrProof
Definition mpt.h:286
std::optional< std::uint32_t > holderCount
Definition mpt.h:296
std::optional< Buffer > holderPubKey
Definition mpt.h:287
std::optional< TER > err
Definition mpt.h:299
std::optional< std::uint32_t > flags
Definition mpt.h:297
std::optional< Account > account
Definition mpt.h:277
std::optional< Buffer > blindingFactor
Definition mpt.h:292
std::optional< XRPAmount > fee
Definition mpt.h:298
std::optional< std::string > proof
Definition mpt.h:280
std::optional< Account > delegate
Definition mpt.h:293
std::optional< Buffer > issuerEncryptedAmt
Definition mpt.h:289
std::optional< std::uint32_t > ticketSeq
Definition mpt.h:294
Arguments for building an MPTokenIssuanceCreate test transaction.
Definition mpt.h:163
std::optional< std::uint8_t > assetScale
Definition mpt.h:167
static std::vector< Account > allHolders
Definition mpt.h:164
std::optional< std::uint32_t > immutableFlags
Definition mpt.h:179
std::optional< std::uint32_t > holderCount
Definition mpt.h:171
std::optional< std::string > metadata
Definition mpt.h:169
std::optional< std::uint32_t > flags
Definition mpt.h:178
std::optional< TER > err
Definition mpt.h:182
std::optional< std::uint64_t > maxAmt
Definition mpt.h:166
std::optional< UInt256 > domainID
Definition mpt.h:181
std::optional< std::uint32_t > ownerCount
Definition mpt.h:170
std::optional< Account > issuer
Definition mpt.h:165
std::optional< std::pair< std::vector< Account >, std::uint64_t > > pay
Definition mpt.h:177
std::optional< std::uint16_t > transferFee
Definition mpt.h:168
std::optional< std::vector< Account > > authorize
Definition mpt.h:174
Arguments for building an MPTokenIssuanceDestroy test transaction.
Definition mpt.h:227
std::optional< Account > issuer
Definition mpt.h:228
std::optional< std::uint32_t > flags
Definition mpt.h:232
std::optional< std::uint32_t > holderCount
Definition mpt.h:231
std::optional< std::uint32_t > ownerCount
Definition mpt.h:230
std::optional< TER > err
Definition mpt.h:233
Arguments for building a ConfidentialMPTHolderKeyUpdate test transaction.
Definition mpt.h:415
std::optional< Account > account
Definition mpt.h:416
std::optional< Buffer > inboxCiphertext
Definition mpt.h:420
std::optional< std::uint32_t > holderCount
Definition mpt.h:423
std::optional< Buffer > proof
Definition mpt.h:421
std::optional< TER > err
Definition mpt.h:426
std::optional< XRPAmount > fee
Definition mpt.h:425
std::optional< std::uint32_t > ownerCount
Definition mpt.h:422
std::optional< Buffer > spendingCiphertext
Definition mpt.h:419
std::optional< Buffer > holderPubKey
Definition mpt.h:418
std::optional< std::uint32_t > flags
Definition mpt.h:424
Full constructor arguments for MPTTester initialization.
Definition mpt.h:207
std::uint16_t transferFee
Definition mpt.h:212
std::optional< TER > err
Definition mpt.h:220
std::uint32_t flags
Definition mpt.h:214
std::optional< std::uint64_t > maxAmt
Definition mpt.h:219
std::optional< Account > auditor
Definition mpt.h:211
std::optional< std::uint32_t > immutableFlags
Definition mpt.h:215
std::optional< std::uint64_t > pay
Definition mpt.h:213
Arguments for initializing funded MPT test accounts and issuance.
Definition mpt.h:189
std::optional< MPTCreate > create
Definition mpt.h:199
std::optional< Account > auditor
Definition mpt.h:193
PrettyAmount const xrp
Definition mpt.h:194
PrettyAmount const xrpHolders
Definition mpt.h:195
Arguments for building a ConfidentialMPTMergeInbox test transaction.
Definition mpt.h:306
std::optional< TER > err
Definition mpt.h:315
std::optional< std::uint32_t > ownerCount
Definition mpt.h:311
std::optional< std::uint32_t > holderCount
Definition mpt.h:312
std::optional< std::uint32_t > flags
Definition mpt.h:313
std::optional< XRPAmount > fee
Definition mpt.h:314
std::optional< std::uint32_t > ticketSeq
Definition mpt.h:310
std::optional< Account > account
Definition mpt.h:307
std::optional< Account > delegate
Definition mpt.h:309
Arguments for building a ConfidentialMPTMirrorUpdate test transaction.
Definition mpt.h:397
std::optional< XRPAmount > fee
Definition mpt.h:404
std::optional< std::uint32_t > flags
Definition mpt.h:405
std::optional< Buffer > auditorEncryptedAmount
Definition mpt.h:402
std::optional< Account > holder
Definition mpt.h:399
std::optional< Account > account
Definition mpt.h:398
std::optional< Buffer > zkProof
Definition mpt.h:403
std::optional< TER > err
Definition mpt.h:408
std::optional< std::uint32_t > holderCount
Definition mpt.h:407
std::optional< Buffer > issuerEncryptedAmount
Definition mpt.h:401
std::optional< std::uint32_t > ownerCount
Definition mpt.h:406
Arguments for building an MPTokenIssuanceSet test transaction.
Definition mpt.h:254
std::optional< Account > account
Definition mpt.h:255
std::optional< std::uint32_t > holderCount
Definition mpt.h:259
std::optional< Buffer > auditorPubKey
Definition mpt.h:267
std::optional< std::uint32_t > ticketSeq
Definition mpt.h:268
std::optional< TER > err
Definition mpt.h:269
std::optional< std::uint32_t > immutableFlags
Definition mpt.h:261
std::optional< std::uint16_t > transferFee
Definition mpt.h:262
std::optional< std::uint32_t > flags
Definition mpt.h:260
std::optional< std::variant< Account, AccountID > > holder
Definition mpt.h:256
std::optional< std::string > metadata
Definition mpt.h:263
std::optional< std::uint32_t > ownerCount
Definition mpt.h:258
std::optional< Buffer > issuerPubKey
Definition mpt.h:266
std::optional< UInt256 > domainID
Definition mpt.h:265
std::optional< Account > delegate
Definition mpt.h:264
Stores the parameters that are exclusively used to generate a Pedersen linkage proof.
Definition mpt.h:434
Buffer const pedersenCommitment
The Pedersen commitment used by the proof.
Definition mpt.h:438
Buffer const blindingFactor
The blinding factor used to create the Pedersen commitment.
Definition mpt.h:453
Buffer const encryptedAmt
The encrypted amount linked to the Pedersen commitment.
Definition mpt.h:448
uint64_t const amt
Either the spending balance or the value being transferred.
Definition mpt.h:443
Represents an XRP, IOU, or MPT quantity This customizes the string conversion and supports XRP conver...
Wrapper that captures std::source_location when implicitly constructed.
Definition Env.h:69