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 ripple {
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,
54 : txn_(txn), seq_(sequence), ticket_(ticket)
55 {
56 txn_[jss::SigningPubKey] = "";
57 txn_[jss::Sequence] = seq_;
58 txn_[jss::Fee] = "0";
59 txn_[jss::Flags] = txn_[jss::Flags].asUInt() | tfInnerBatchTxn;
60
61 // Optionally set ticket sequence
62 if (ticket_.has_value())
63 {
64 txn_[jss::Sequence] = 0;
65 txn_[sfTicketSequence.jsonName] = *ticket_;
66 }
67 }
68
69 void
70 operator()(Env&, JTx& jtx) const;
71
74 {
75 return txn_[key];
76 }
77
78 void
80 {
81 txn_.removeMember(key);
82 }
83
84 Json::Value const&
85 getTxn() const
86 {
87 return txn_;
88 }
89};
90
92class sig
93{
94public:
96
97 sig(std::vector<Reg> signers_) : signers(std::move(signers_))
98 {
100 }
101
102 template <class AccountType, class... Accounts>
104 explicit sig(AccountType&& a0, Accounts&&... aN)
105 : signers{std::forward<AccountType>(a0), std::forward<Accounts>(aN)...}
106 {
108 }
109
110 void
111 operator()(Env&, JTx& jt) const;
112};
113
115class msig
116{
117public:
120
121 msig(Account const& masterAccount, std::vector<Reg> signers_)
122 : master(masterAccount), signers(std::move(signers_))
123 {
125 }
126
127 template <class AccountType, class... Accounts>
129 explicit msig(
130 Account const& masterAccount,
131 AccountType&& a0,
132 Accounts&&... aN)
133 : master(masterAccount)
134 , signers{std::forward<AccountType>(a0), std::forward<Accounts>(aN)...}
135 {
137 }
138
139 void
140 operator()(Env&, JTx& jt) const;
141};
142
143} // namespace batch
144
145} // namespace jtx
146
147} // namespace test
148} // namespace ripple
149
150#endif
Lightweight wrapper to tag static string.
Definition json_value.h:44
Represents a JSON value.
Definition json_value.h:130
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
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, std::optional< std::uint32_t > const &fee=std::nullopt)
Definition batch.h:49
void removeMember(Json::StaticString const &key)
Definition batch.h:79
Json::Value const & getTxn() const
Definition batch.h:85
Json::Value & operator[](Json::StaticString const &key)
Definition batch.h:73
void operator()(Env &, JTx &jtx) const
Definition batch.cpp:47
Set a batch nested multi-signature on a JTx.
Definition batch.h:116
msig(Account const &masterAccount, AccountType &&a0, Accounts &&... aN)
Definition batch.h:129
void operator()(Env &, JTx &jt) const
Definition batch.cpp:92
msig(Account const &masterAccount, std::vector< Reg > signers_)
Definition batch.h:121
std::vector< Reg > signers
Definition batch.h:119
Set a batch signature on a JTx.
Definition batch.h:93
void operator()(Env &, JTx &jt) const
Definition batch.cpp:58
sig(AccountType &&a0, Accounts &&... aN)
Definition batch.h:104
sig(std::vector< Reg > signers_)
Definition batch.h:97
std::vector< Reg > signers
Definition batch.h:95
Set the fee on a JTx.
Definition fee.h:18
Match set account flags.
Definition flags.h:109
T is_same_v
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
STL namespace.
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