rippled
Loading...
Searching...
No Matches
batch.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/owners.h>
7#include <test/jtx/tags.h>
8
9#include <xrpl/protocol/TxFlags.h>
10
11#include "test/jtx/SignerUtils.h"
12
13#include <concepts>
14#include <cstdint>
15#include <optional>
16
17namespace xrpl {
18namespace test {
19namespace jtx {
20
22namespace batch {
23
26calcBatchFee(jtx::Env const& env, uint32_t const& numSigners, uint32_t const& txns = 0);
27
30outer(jtx::Account const& account, uint32_t seq, STAmount const& fee, std::uint32_t flags);
31
33class inner
34{
35private:
39
40public:
42 Json::Value const& txn,
43 std::uint32_t const& sequence,
45 : txn_(txn), seq_(sequence), ticket_(ticket)
46 {
47 txn_[jss::SigningPubKey] = "";
48 txn_[jss::Sequence] = seq_;
49 txn_[jss::Fee] = "0";
50 txn_[jss::Flags] = txn_[jss::Flags].asUInt() | tfInnerBatchTxn;
51
52 // Optionally set ticket sequence
53 if (ticket_.has_value())
54 {
55 txn_[jss::Sequence] = 0;
56 txn_[sfTicketSequence.jsonName] = *ticket_;
57 }
58 }
59
60 void
61 operator()(Env&, JTx& jtx) const;
62
65 {
66 return txn_[key];
67 }
68
69 void
71 {
72 txn_.removeMember(key);
73 }
74
75 Json::Value const&
76 getTxn() const
77 {
78 return txn_;
79 }
80};
81
83class sig
84{
85public:
87
88 sig(std::vector<Reg> signers_) : signers(std::move(signers_))
89 {
91 }
92
93 template <class AccountType, class... Accounts>
95 explicit sig(AccountType&& a0, Accounts&&... aN)
96 : signers{std::forward<AccountType>(a0), std::forward<Accounts>(aN)...}
97 {
99 }
100
101 void
102 operator()(Env&, JTx& jt) const;
103};
104
106class msig
107{
108public:
111
112 msig(Account const& masterAccount, std::vector<Reg> signers_) : master(masterAccount), signers(std::move(signers_))
113 {
115 }
116
117 template <class AccountType, class... Accounts>
119 explicit msig(Account const& masterAccount, AccountType&& a0, Accounts&&... aN)
120 : master(masterAccount), signers{std::forward<AccountType>(a0), std::forward<Accounts>(aN)...}
121 {
123 }
124
125 void
126 operator()(Env&, JTx& jt) const;
127};
128
129} // namespace batch
130
131} // namespace jtx
132
133} // namespace test
134} // namespace xrpl
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:19
A transaction testing environment.
Definition Env.h:119
Adds a new Batch Txn on a JTx and autofills.
Definition batch.h:34
void operator()(Env &, JTx &jtx) const
Definition batch.cpp:40
void removeMember(Json::StaticString const &key)
Definition batch.h:70
Json::Value const & getTxn() const
Definition batch.h:76
Json::Value & operator[](Json::StaticString const &key)
Definition batch.h:64
std::optional< std::uint32_t > ticket_
Definition batch.h:38
inner(Json::Value const &txn, std::uint32_t const &sequence, std::optional< std::uint32_t > const &ticket=std::nullopt)
Definition batch.h:41
Set a batch nested multi-signature on a JTx.
Definition batch.h:107
std::vector< Reg > signers
Definition batch.h:110
msig(Account const &masterAccount, AccountType &&a0, Accounts &&... aN)
Definition batch.h:119
void operator()(Env &, JTx &jt) const
Definition batch.cpp:83
msig(Account const &masterAccount, std::vector< Reg > signers_)
Definition batch.h:112
Set a batch signature on a JTx.
Definition batch.h:84
void operator()(Env &, JTx &jt) const
Definition batch.cpp:51
std::vector< Reg > signers
Definition batch.h:86
sig(std::vector< Reg > signers_)
Definition batch.h:88
sig(AccountType &&a0, Accounts &&... aN)
Definition batch.h:95
Set the fee on a JTx.
Definition fee.h:17
Match set account flags.
Definition flags.h:108
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:27
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:41
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
constexpr std::uint32_t tfInnerBatchTxn
Definition TxFlags.h:41
T has_value(T... args)
Execution context for applying a JSON transaction.
Definition JTx.h:25
Set the sequence number on a JTx.
Definition seq.h:14