rippled
Loading...
Searching...
No Matches
batch.h
1#ifndef XRPL_TEST_JTX_BATCH_H_INCLUDED
2#define XRPL_TEST_JTX_BATCH_H_INCLUDED
3
4#include <test/jtx/Account.h>
5#include <test/jtx/Env.h>
6#include <test/jtx/amount.h>
7#include <test/jtx/owners.h>
8#include <test/jtx/tags.h>
9
10#include <xrpl/protocol/TxFlags.h>
11
12#include "test/jtx/SignerUtils.h"
13
14#include <concepts>
15#include <cstdint>
16#include <optional>
17
18namespace xrpl {
19namespace test {
20namespace jtx {
21
23namespace batch {
24
28 jtx::Env const& env,
29 uint32_t const& numSigners,
30 uint32_t const& txns = 0);
31
34outer(
35 jtx::Account const& account,
36 uint32_t seq,
37 STAmount const& fee,
39
41class inner
42{
43private:
47
48public:
50 Json::Value const& txn,
51 std::uint32_t const& sequence,
53 : txn_(txn), seq_(sequence), ticket_(ticket)
54 {
55 txn_[jss::SigningPubKey] = "";
56 txn_[jss::Sequence] = seq_;
57 txn_[jss::Fee] = "0";
58 txn_[jss::Flags] = txn_[jss::Flags].asUInt() | tfInnerBatchTxn;
59
60 // Optionally set ticket sequence
61 if (ticket_.has_value())
62 {
63 txn_[jss::Sequence] = 0;
64 txn_[sfTicketSequence.jsonName] = *ticket_;
65 }
66 }
67
68 void
69 operator()(Env&, JTx& jtx) const;
70
73 {
74 return txn_[key];
75 }
76
77 void
79 {
80 txn_.removeMember(key);
81 }
82
83 Json::Value const&
84 getTxn() const
85 {
86 return txn_;
87 }
88};
89
91class sig
92{
93public:
95
96 sig(std::vector<Reg> signers_) : signers(std::move(signers_))
97 {
99 }
100
101 template <class AccountType, class... Accounts>
103 explicit sig(AccountType&& a0, Accounts&&... aN)
104 : signers{std::forward<AccountType>(a0), std::forward<Accounts>(aN)...}
105 {
107 }
108
109 void
110 operator()(Env&, JTx& jt) const;
111};
112
114class msig
115{
116public:
119
120 msig(Account const& masterAccount, std::vector<Reg> signers_)
121 : master(masterAccount), signers(std::move(signers_))
122 {
124 }
125
126 template <class AccountType, class... Accounts>
128 explicit msig(
129 Account const& masterAccount,
130 AccountType&& a0,
131 Accounts&&... aN)
132 : master(masterAccount)
133 , signers{std::forward<AccountType>(a0), std::forward<Accounts>(aN)...}
134 {
136 }
137
138 void
139 operator()(Env&, JTx& jt) const;
140};
141
142} // namespace batch
143
144} // namespace jtx
145
146} // namespace test
147} // namespace xrpl
148
149#endif
Lightweight wrapper to tag static string.
Definition json_value.h:45
Represents a JSON value.
Definition json_value.h:131
UInt asUInt() const
Value removeMember(char const *key)
Remove and return the named member.
Immutable cryptographic account descriptor.
Definition Account.h:20
A transaction testing environment.
Definition Env.h:102
Adds a new Batch Txn on a JTx and autofills.
Definition batch.h:42
void operator()(Env &, JTx &jtx) const
Definition batch.cpp:47
void removeMember(Json::StaticString const &key)
Definition batch.h:78
Json::Value const & getTxn() const
Definition batch.h:84
Json::Value & operator[](Json::StaticString const &key)
Definition batch.h:72
std::optional< std::uint32_t > ticket_
Definition batch.h:46
inner(Json::Value const &txn, std::uint32_t const &sequence, std::optional< std::uint32_t > const &ticket=std::nullopt)
Definition batch.h:49
Set a batch nested multi-signature on a JTx.
Definition batch.h:115
std::vector< Reg > signers
Definition batch.h:118
msig(Account const &masterAccount, AccountType &&a0, Accounts &&... aN)
Definition batch.h:128
void operator()(Env &, JTx &jt) const
Definition batch.cpp:92
msig(Account const &masterAccount, std::vector< Reg > signers_)
Definition batch.h:120
Set a batch signature on a JTx.
Definition batch.h:92
void operator()(Env &, JTx &jt) const
Definition batch.cpp:58
std::vector< Reg > signers
Definition batch.h:94
sig(std::vector< Reg > signers_)
Definition batch.h:96
sig(AccountType &&a0, Accounts &&... aN)
Definition batch.h:103
Set the fee on a JTx.
Definition fee.h:18
Match set account flags.
Definition flags.h:109
T is_same_v
STL namespace.
Json::Value outer(jtx::Account const &account, uint32_t seq, STAmount const &fee, std::uint32_t flags)
Batch.
Definition batch.cpp:30
XRPAmount calcBatchFee(jtx::Env const &env, uint32_t const &numSigners, uint32_t const &txns=0)
Calculate Batch Fee.
Definition batch.cpp:19
void sortSigners(std::vector< Reg > &signers)
Definition SignerUtils.h:44
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
constexpr std::uint32_t tfInnerBatchTxn
Definition TxFlags.h:42
T has_value(T... args)
Execution context for applying a JSON transaction.
Definition JTx.h:26
Set the sequence number on a JTx.
Definition seq.h:15