xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
protocol_autogen
transactions
protocol_autogen/transactions/Batch.h
1
// This file is auto-generated. Do not edit.
2
#pragma once
3
4
#include <xrpl/protocol/STTx.h>
5
#include <xrpl/protocol/STParsedJSON.h>
6
#include <xrpl/protocol/jss.h>
7
#include <xrpl/protocol_autogen/TransactionBase.h>
8
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
9
#include <xrpl/json/json_value.h>
10
11
#include <
stdexcept
>
12
#include <
optional
>
13
14
namespace
xrpl::transactions
{
15
16
class
BatchBuilder
;
17
29
class
Batch
:
public
TransactionBase
30
{
31
public
:
32
static
constexpr
xrpl::TxType
txType
= ttBATCH;
33
38
explicit
Batch
(
std::shared_ptr<STTx const>
tx)
39
:
TransactionBase
(
std
::move(tx))
40
{
41
// Verify transaction type
42
if
(
tx_
->getTxnType() !=
txType
)
43
{
44
throw std::runtime_error(
"Invalid transaction type for Batch"
);
45
}
46
}
47
48
// Transaction-specific field getters
54
[[nodiscard]]
55
STArray
const
&
56
getRawTransactions
()
const
57
{
58
return
this->
tx_
->getFieldArray(sfRawTransactions);
59
}
60
65
[[nodiscard]]
66
std::optional<std::reference_wrapper<STArray const>
>
67
getBatchSigners
()
const
68
{
69
if
(this->
tx_
->isFieldPresent(sfBatchSigners))
70
return
this->
tx_
->getFieldArray(sfBatchSigners);
71
return
std::nullopt;
72
}
73
78
[[nodiscard]]
79
bool
80
hasBatchSigners
()
const
81
{
82
return
this->
tx_
->isFieldPresent(sfBatchSigners);
83
}
84
};
85
93
class
BatchBuilder
:
public
TransactionBuilderBase
<BatchBuilder>
94
{
95
public
:
103
BatchBuilder
(SF_ACCOUNT::type::value_type account,
104
STArray
const
& rawTransactions,
std::optional<SF_UINT32::type::value_type>
sequence = std::nullopt,
105
std::optional<SF_AMOUNT::type::value_type>
fee = std::nullopt
106
)
107
:
TransactionBuilderBase
<
BatchBuilder
>(ttBATCH, account, sequence, fee)
108
{
109
setRawTransactions
(rawTransactions);
110
}
111
117
BatchBuilder
(
std::shared_ptr<STTx const>
tx)
118
{
119
if
(tx->getTxnType() != ttBATCH)
120
{
121
throw
std::runtime_error
(
"Invalid transaction type for BatchBuilder"
);
122
}
123
object_
= *tx;
124
}
125
129
134
BatchBuilder
&
135
setRawTransactions
(
STArray
const
& value)
136
{
137
object_
.setFieldArray(sfRawTransactions, value);
138
return
*
this
;
139
}
140
145
BatchBuilder
&
146
setBatchSigners
(
STArray
const
& value)
147
{
148
object_
.setFieldArray(sfBatchSigners, value);
149
return
*
this
;
150
}
151
158
Batch
159
build
(
PublicKey
const
& publicKey,
SecretKey
const
& secretKey)
160
{
161
sign
(publicKey, secretKey);
162
return
Batch
{
std::make_shared<STTx>
(std::move(
object_
))};
163
}
164
};
165
166
}
// namespace xrpl::transactions
xrpl::PublicKey
A public key.
Definition
PublicKey.h:53
xrpl::STArray
Definition
STArray.h:20
xrpl::SecretKey
A secret key.
Definition
SecretKey.h:24
xrpl::transactions::BatchBuilder
Builder for Batch transactions.
Definition
protocol_autogen/transactions/Batch.h:94
xrpl::transactions::BatchBuilder::BatchBuilder
BatchBuilder(SF_ACCOUNT::type::value_type account, STArray const &rawTransactions, std::optional< SF_UINT32::type::value_type > sequence=std::nullopt, std::optional< SF_AMOUNT::type::value_type > fee=std::nullopt)
Construct a new BatchBuilder with required fields.
Definition
protocol_autogen/transactions/Batch.h:103
xrpl::transactions::BatchBuilder::BatchBuilder
BatchBuilder(std::shared_ptr< STTx const > tx)
Construct a BatchBuilder from an existing STTx object.
Definition
protocol_autogen/transactions/Batch.h:117
xrpl::transactions::BatchBuilder::setBatchSigners
BatchBuilder & setBatchSigners(STArray const &value)
Set sfBatchSigners (SoeOptional).
Definition
protocol_autogen/transactions/Batch.h:146
xrpl::transactions::BatchBuilder::build
Batch build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the Batch wrapper.
Definition
protocol_autogen/transactions/Batch.h:159
xrpl::transactions::BatchBuilder::setRawTransactions
BatchBuilder & setRawTransactions(STArray const &value)
Transaction-specific field setters.
Definition
protocol_autogen/transactions/Batch.h:135
xrpl::transactions::Batch
Transaction: Batch.
Definition
protocol_autogen/transactions/Batch.h:30
xrpl::transactions::Batch::txType
static constexpr xrpl::TxType txType
Definition
protocol_autogen/transactions/Batch.h:32
xrpl::transactions::Batch::hasBatchSigners
bool hasBatchSigners() const
Check if sfBatchSigners is present.
Definition
protocol_autogen/transactions/Batch.h:80
xrpl::transactions::Batch::Batch
Batch(std::shared_ptr< STTx const > tx)
Construct a Batch transaction wrapper from an existing STTx object.
Definition
protocol_autogen/transactions/Batch.h:38
xrpl::transactions::Batch::getRawTransactions
STArray const & getRawTransactions() const
Get sfRawTransactions (SoeRequired).
Definition
protocol_autogen/transactions/Batch.h:56
xrpl::transactions::Batch::getBatchSigners
std::optional< std::reference_wrapper< STArray const > > getBatchSigners() const
Get sfBatchSigners (SoeOptional).
Definition
protocol_autogen/transactions/Batch.h:67
xrpl::transactions::TransactionBase::tx_
std::shared_ptr< STTx const > tx_
The underlying transaction object being wrapped.
Definition
TransactionBase.h:456
xrpl::transactions::TransactionBase::TransactionBase
TransactionBase(std::shared_ptr< STTx const > tx)
Construct a transaction wrapper from an existing STTx object.
Definition
TransactionBase.h:31
xrpl::transactions::TransactionBuilderBase< BatchBuilder >::object_
STObject object_
Definition
TransactionBuilderBase.h:266
xrpl::transactions::TransactionBuilderBase< BatchBuilder >::TransactionBuilderBase
TransactionBuilderBase()=default
xrpl::transactions::TransactionBuilderBase< BatchBuilder >::sign
BatchBuilder & sign(PublicKey const &publicKey, SecretKey const &secretKey)
Definition
TransactionBuilderBase.h:248
std::make_shared
T make_shared(T... args)
std
STL namespace.
xrpl::transactions
Definition
TransactionBase.h:15
xrpl::TxType
TxType
Transaction type identifiers.
Definition
TxFormats.h:45
optional
std::runtime_error
std::shared_ptr
stdexcept
Generated by
1.17.0