3#include <test/jtx/Account.h>
4#include <test/jtx/Env.h>
5#include <test/jtx/delegate.h>
6#include <test/jtx/owners.h>
7#include <test/jtx/tag.h>
8#include <test/jtx/ter.h>
9#include <test/jtx/ticket.h>
10#include <test/jtx/txflags.h>
12#include <xrpl/protocol/ConfidentialTransfer.h>
13#include <xrpl/protocol/TxFlags.h>
14#include <xrpl/protocol/UintTypes.h>
15#include <xrpl/protocol/XRPAmount.h>
375 Slice const& currentEncSpending,
378 Slice const& senderEncAmt);
416 operator MPT()
const;
422 createJV(MPTCreate
const& arg = MPTCreate{});
425 destroy(MPTDestroy
const& arg = MPTDestroy{});
428 destroyJV(MPTDestroy
const& arg = MPTDestroy{});
431 authorize(MPTAuthorize
const& arg = MPTAuthorize{});
434 authorizeJV(MPTAuthorize
const& arg = MPTAuthorize{});
440 set(MPTSet
const&
set = {});
446 convert(MPTConvert
const& arg = MPTConvert{});
457 convertJV(MPTConvert
const& arg, std::uint32_t seq);
460 mergeInbox(MPTMergeInbox
const& arg = MPTMergeInbox{});
462 [[nodiscard]] json::Value
463 mergeInboxJV(MPTMergeInbox
const& arg = MPTMergeInbox{})
const;
466 send(MPTConfidentialSend
const& arg = MPTConfidentialSend{});
483 MPTConfidentialSend
const& arg,
485 std::optional<ConfidentialSendChainState> chain = std::nullopt);
500 [[nodiscard]] ConfidentialSendChainState
504 convertBack(MPTConvertBack
const& arg = MPTConvertBack{});
520 confidentialClaw(MPTConfidentialClawback
const& arg = MPTConfidentialClawback{});
535 checkFlags(uint32_t
const expectedFlags, std::optional<Account>
const&
holder = std::nullopt)
575 [[nodiscard]]
MPTID const&
578 if (!
env_.test.BEAST_EXPECT(
id_))
599 operator Asset()
const;
637 Slice const& blindingFactor,
658 return ~static_cast<MPT>(
mpt);
668 template <
typename A>
672 auto const expectedFlags =
Txflags(arg.flags.value_or(0));
675 if constexpr (
requires { arg.fee; })
682 if constexpr (
requires { arg.ticketSeq; })
683 ticketSeq = arg.ticketSeq;
686 if constexpr (
requires { arg.delegate; })
687 delegateAcct = arg.delegate;
690 if constexpr (
requires { arg.destinationTag; })
691 dstTag = arg.destinationTag;
693 if (ticketSeq && delegateAcct)
706 else if (delegateAcct)
712 env_(jv, expectedFlags, expectedTer,
Dtag(*dstTag));
716 env_(jv, expectedFlags, expectedTer);
718 auto const err =
env_.ter();
726 env_.require(
Owners(it.second, *arg.holderCount));
737 template <
typename T>
745 Buffer& blindingFactor)
const;
Like std::vector<char> but better.
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
std::shared_ptr< STLedgerEntry const > const_pointer
An immutable linear range of bytes.
Immutable cryptographic account descriptor.
A transaction testing environment.
Test helper for creating, mutating, and asserting MPT and confidential MPT ledger state.
void fillConversionCiphertexts(T const &arg, json::Value &jv, Buffer &holderCiphertext, Buffer &issuerCiphertext, std::optional< Buffer > &auditorCiphertext, Buffer &blindingFactor) const
static constexpr auto holderEncryptedInbox
std::optional< uint64_t > decryptAmount(Account const &account, Buffer const &amt) const
@ HolderEncryptedSpending
@ AuditorEncryptedBalance
std::unordered_map< std::string, Account > const holders_
Buffer getConvertBackProof(Account const &holder, std::uint64_t const amount, uint256 const &contextHash, PedersenProofParams const &pcParams) const
void send(MPTConfidentialSend const &arg=MPTConfidentialSend{})
Buffer encryptAmount(Account const &account, uint64_t const amt, Buffer const &blindingFactor) const
bool forObject(std::function< bool(SLEP const &sle)> const &cb, std::optional< Account > const &holder=std::nullopt) const
void set(MPTSet const &set={})
bool checkMPTokenAmount(Account const &holder, std::int64_t expectedAmount) const
std::optional< MPTID > id_
json::Value convertJV(MPTConvert const &arg, std::uint32_t seq)
Build a confidential convert JV without submitting it.
static Buffer getPedersenCommitment(std::uint64_t const amount, Buffer const &pedersenBlindingFactor)
static json::Value destroyJV(MPTDestroy const &arg=MPTDestroy{})
std::optional< Buffer > getEncryptedBalance(Account const &account, EncryptedBalanceType option=holderEncryptedInbox) const
void convertBack(MPTConvertBack const &arg=MPTConvertBack{})
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::optional< uint64_t > getDecryptedBalance(Account const &account, EncryptedBalanceType balanceType) const
Account const & holder(std::string const &h) const
static json::Value authorizeJV(MPTAuthorize const &arg=MPTAuthorize{})
void create(MPTCreate const &arg=MPTCreate{})
bool isTransferFeePresent() const
std::optional< Buffer > getPrivKey(Account const &account) const
friend BookSpec operator~(MPTTester const &mpt)
bool checkMetadata(std::string const &metadata) const
void confidentialClaw(MPTConfidentialClawback const &arg=MPTConfidentialClawback{})
bool checkFlags(uint32_t const expectedFlags, std::optional< Account > const &holder=std::nullopt) const
bool isMetadataPresent() const
MPT operator[](std::string const &name) const
static constexpr auto issuerEncryptedBalance
void authorizeHolders(Holders const &holders)
std::uint32_t getMPTokenVersion(Account const account) const
Account const & issuer() const
std::optional< std::int64_t > getIssuanceOutstandingBalance() const
static json::Value createJV(MPTCreate const &arg=MPTCreate{})
void authorize(MPTAuthorize const &arg=MPTAuthorize{})
std::optional< Buffer > getSchnorrProof(Account const &account, uint256 const &ctxHash) const
json::Value sendJV(MPTConfidentialSend const &arg, std::uint32_t seq, std::optional< ConfidentialSendChainState > chain=std::nullopt)
Build a confidential send JV.
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.
static json::Value setJV(MPTSet const &set={})
MPTID const & issuanceID() const
static constexpr auto holderEncryptedSpending
std::unordered_map< AccountID, Buffer > pubKeys_
std::unordered_map< AccountID, Buffer > privKeys_
std::optional< Buffer > getClawbackProof(Account const &holder, std::uint64_t amount, Buffer const &privateKey, uint256 const &txHash) const
std::int64_t getBalance(Account const &account) const
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
std::optional< Account > const auditor_
json::Value mergeInboxJV(MPTMergeInbox const &arg=MPTMergeInbox{}) const
void claw(Account const &issuer, Account const &holder, std::int64_t amount, std::optional< TER > err=std::nullopt)
static constexpr auto auditorEncryptedBalance
MPTTester(Env &env, Account issuer, MPTInit const &constr={})
void generateKeyPair(Account const &account)
PrettyAmount mpt(std::int64_t amount) const
void destroy(MPTDestroy const &arg=MPTDestroy{})
std::int64_t getIssuanceConfidentialBalance() const
bool checkTransferFee(std::uint16_t transferFee) const
bool checkIssuanceConfidentialBalance(std::int64_t expectedAmount) const
bool checkDomainID(std::optional< uint256 > expected) const
void mergeInbox(MPTMergeInbox const &arg=MPTMergeInbox{})
PrettyAmount operator()(std::int64_t amount) const
void convert(MPTConvert const &arg=MPTConvert{})
std::uint32_t getFlags(std::optional< Account > const &holder) const
static std::unordered_map< std::string, Account > makeHolders(std::vector< Account > const &holders)
std::optional< Buffer > getPubKey(Account const &account) const
bool checkMPTokenOutstandingAmount(std::int64_t expectedAmount) const
TER submit(A const &arg, json::Value jv)
json::Value convertBackJV(MPTConvertBack const &arg, std::uint32_t seq)
Build a confidential convertBack JV without submitting it.
Converts to MPT Issue or STAmount.
MptBalance(MPTTester &tester, Account const &account, std::int64_t amount)
MPTTester const & tester_
std::int64_t const amount_
void operator()(Env &env) const
MptFlags(MPTTester &tester, std::uint32_t flags, std::optional< Account > const &holder=std::nullopt)
void operator()(Env &env) const
std::optional< Account > holder_
Match the number of items in the account's owner directory.
std::function< bool()> cb_
RequireAny(std::function< bool()> const &cb)
void operator()(Env &env) const
Set the expected result code for a JTx The test will fail if the code doesn't match.
Set a ticket sequence on a JTx.
Buffer gMakeZeroBuffer(std::size_t size)
Create a zero-initialized buffer for malformed cryptography test inputs.
XrpT const XRP
Converts to XRP Issue or STAmount.
std::vector< Account > Holders
std::optional< ConfidentialSendChainState > computeNextSendChainState(std::uint64_t currentSpending, Slice const ¤tEncSpending, 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.
static MPTInit const kMptInitNoFund
std::string to_string(BaseUInt< Bits, Tag > const &a)
BaseUInt< 192 > MPTID
MPTID is a 192-bit value representing MPT Issuance ID, which is a concatenation of a 32-bit sequence ...
TERSubset< CanCvtToTER > TER
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
When building multiple confidential sends from the same account inside a single batch transaction,...
std::uint32_t version
sfConfidentialBalanceVersion after the previous send.
std::uint64_t spending
Decrypted spending balance after the previous send.
Buffer encSpending
Encrypted spending balance after the previous send.
Set the destination tag on a JTx.
Arguments for building an MPTokenAuthorize test transaction.
std::optional< std::uint32_t > ownerCount
std::optional< std::uint32_t > holderCount
std::optional< Account > holder
std::optional< Account > account
std::optional< std::uint32_t > flags
Arguments for building a ConfidentialMPTClawback test transaction.
std::optional< std::uint32_t > holderCount
std::optional< std::uint32_t > ownerCount
std::optional< std::uint32_t > ticketSeq
std::optional< std::string > proof
std::optional< std::uint64_t > amt
std::optional< XRPAmount > fee
std::optional< Account > delegate
std::optional< std::uint32_t > flags
std::optional< Account > account
std::optional< Account > holder
Arguments for building a ConfidentialMPTSend test transaction.
std::optional< XRPAmount > fee
std::optional< std::vector< std::string > > credentials
std::optional< Buffer > balanceCommitment
std::optional< std::uint32_t > ticketSeq
std::optional< std::uint32_t > holderCount
std::optional< std::uint64_t > amt
std::optional< bool > fillAuditorEncryptedAmt
std::optional< std::uint32_t > destinationTag
std::optional< Account > account
std::optional< Buffer > auditorEncryptedAmt
std::optional< Account > dest
std::optional< std::uint32_t > flags
std::optional< Buffer > blindingFactor
std::optional< Buffer > amountCommitment
std::optional< Account > delegate
std::optional< std::string > proof
std::optional< Buffer > senderEncryptedAmt
std::optional< Buffer > destEncryptedAmt
std::optional< Buffer > issuerEncryptedAmt
std::optional< std::uint32_t > ownerCount
Arguments for building a ConfidentialMPTConvertBack test transaction.
std::optional< Buffer > auditorEncryptedAmt
std::optional< Account > delegate
std::optional< std::uint32_t > holderCount
std::optional< Buffer > issuerEncryptedAmt
std::optional< std::uint32_t > ownerCount
std::optional< std::uint64_t > amt
std::optional< Account > account
std::optional< XRPAmount > fee
std::optional< std::uint32_t > ticketSeq
std::optional< std::uint32_t > flags
std::optional< Buffer > holderEncryptedAmt
std::optional< Buffer > proof
std::optional< Buffer > blindingFactor
std::optional< Buffer > pedersenCommitment
std::optional< bool > fillAuditorEncryptedAmt
Arguments for building a ConfidentialMPTConvert test transaction.
std::optional< bool > fillAuditorEncryptedAmt
std::optional< std::uint32_t > ownerCount
std::optional< std::uint64_t > amt
std::optional< Buffer > holderEncryptedAmt
std::optional< Buffer > auditorEncryptedAmt
std::optional< bool > fillSchnorrProof
std::optional< std::uint32_t > holderCount
std::optional< Buffer > holderPubKey
std::optional< std::uint32_t > flags
std::optional< Account > account
std::optional< Buffer > blindingFactor
std::optional< XRPAmount > fee
std::optional< std::string > proof
std::optional< Account > delegate
std::optional< Buffer > issuerEncryptedAmt
std::optional< std::uint32_t > ticketSeq
Arguments for building an MPTokenIssuanceCreate test transaction.
std::optional< std::uint8_t > assetScale
static std::vector< Account > allHolders
std::optional< std::uint32_t > mutableFlags
std::optional< std::uint32_t > holderCount
std::optional< std::string > metadata
std::optional< std::uint32_t > flags
std::optional< uint256 > domainID
std::optional< std::uint64_t > maxAmt
std::optional< std::uint32_t > ownerCount
std::optional< Account > issuer
std::optional< std::pair< std::vector< Account >, std::uint64_t > > pay
std::optional< std::uint16_t > transferFee
std::optional< std::vector< Account > > authorize
Arguments for building an MPTokenIssuanceDestroy test transaction.
std::optional< Account > issuer
std::optional< std::uint32_t > flags
std::optional< std::uint32_t > holderCount
std::optional< std::uint32_t > ownerCount
Full constructor arguments for MPTTester initialization.
std::optional< std::uint32_t > mutableFlags
std::uint16_t transferFee
std::optional< std::uint64_t > maxAmt
std::optional< Account > auditor
std::optional< std::uint64_t > pay
Arguments for initializing funded MPT test accounts and issuance.
std::optional< MPTCreate > create
std::optional< Account > auditor
PrettyAmount const xrpHolders
Arguments for building a ConfidentialMPTMergeInbox test transaction.
std::optional< std::uint32_t > ownerCount
std::optional< std::uint32_t > holderCount
std::optional< std::uint32_t > flags
std::optional< XRPAmount > fee
std::optional< std::uint32_t > ticketSeq
std::optional< Account > account
std::optional< Account > delegate
Arguments for building an MPTokenIssuanceSet test transaction.
std::optional< uint256 > domainID
std::optional< Account > account
std::optional< std::uint32_t > holderCount
std::optional< Buffer > auditorPubKey
std::optional< std::uint32_t > ticketSeq
std::optional< std::uint16_t > transferFee
std::optional< std::uint32_t > flags
std::optional< std::variant< Account, AccountID > > holder
std::optional< std::uint32_t > mutableFlags
std::optional< std::string > metadata
std::optional< std::uint32_t > ownerCount
std::optional< Buffer > issuerPubKey
std::optional< Account > delegate
Stores the parameters that are exclusively used to generate a Pedersen linkage proof.
Buffer const pedersenCommitment
The Pedersen commitment used by the proof.
Buffer const blindingFactor
The blinding factor used to create the Pedersen commitment.
Buffer const encryptedAmt
The encrypted amount linked to the Pedersen commitment.
uint64_t const amt
Either the spending balance or the value being transferred.
Represents an XRP, IOU, or MPT quantity This customizes the string conversion and supports XRP conver...