xrpld
Loading...
Searching...
No Matches
protocol_autogen/transactions/CheckCreate.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
14namespace xrpl::transactions {
15
17
30{
31public:
32 static constexpr xrpl::TxType txType = ttCHECK_CREATE;
33
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 CheckCreate");
45 }
46 }
47
48 // Transaction-specific field getters
49
54 [[nodiscard]]
55 SF_ACCOUNT::type::value_type
57 {
58 return this->tx_->at(sfDestination);
59 }
60
66 [[nodiscard]]
67 SF_AMOUNT::type::value_type
68 getSendMax() const
69 {
70 return this->tx_->at(sfSendMax);
71 }
72
77 [[nodiscard]]
80 {
81 if (hasExpiration())
82 {
83 return this->tx_->at(sfExpiration);
84 }
85 return std::nullopt;
86 }
87
92 [[nodiscard]]
93 bool
95 {
96 return this->tx_->isFieldPresent(sfExpiration);
97 }
98
103 [[nodiscard]]
106 {
107 if (hasDestinationTag())
108 {
109 return this->tx_->at(sfDestinationTag);
110 }
111 return std::nullopt;
112 }
113
118 [[nodiscard]]
119 bool
121 {
122 return this->tx_->isFieldPresent(sfDestinationTag);
123 }
124
129 [[nodiscard]]
132 {
133 if (hasInvoiceID())
134 {
135 return this->tx_->at(sfInvoiceID);
136 }
137 return std::nullopt;
138 }
139
144 [[nodiscard]]
145 bool
147 {
148 return this->tx_->isFieldPresent(sfInvoiceID);
149 }
150};
151
159class CheckCreateBuilder : public TransactionBuilderBase<CheckCreateBuilder>
160{
161public:
170 CheckCreateBuilder(SF_ACCOUNT::type::value_type account,
173)
174 : TransactionBuilderBase<CheckCreateBuilder>(ttCHECK_CREATE, account, sequence, fee)
175 {
176 setDestination(destination);
177 setSendMax(sendMax);
178 }
179
186 {
187 if (tx->getTxnType() != ttCHECK_CREATE)
188 {
189 throw std::runtime_error("Invalid transaction type for CheckCreateBuilder");
190 }
191 object_ = *tx;
192 }
193
195
202 {
203 object_[sfDestination] = value;
204 return *this;
205 }
206
214 {
215 object_[sfSendMax] = value;
216 return *this;
217 }
218
225 {
226 object_[sfExpiration] = value;
227 return *this;
228 }
229
236 {
237 object_[sfDestinationTag] = value;
238 return *this;
239 }
240
247 {
248 object_[sfInvoiceID] = value;
249 return *this;
250 }
251
259 build(PublicKey const& publicKey, SecretKey const& secretKey)
260 {
261 sign(publicKey, secretKey);
262 return CheckCreate{std::make_shared<STTx>(std::move(object_))};
263 }
264};
265
266} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:42
A secret key.
Definition SecretKey.h:18
CheckCreateBuilder(SF_ACCOUNT::type::value_type account, std::decay_t< typename SF_ACCOUNT::type::value_type > const &destination, std::decay_t< typename SF_AMOUNT::type::value_type > const &sendMax, std::optional< SF_UINT32::type::value_type > sequence=std::nullopt, std::optional< SF_AMOUNT::type::value_type > fee=std::nullopt)
Construct a new CheckCreateBuilder with required fields.
CheckCreateBuilder & setInvoiceID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Set sfInvoiceID (SoeOptional).
CheckCreateBuilder & setSendMax(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfSendMax (SoeRequired).
CheckCreate build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the CheckCreate wrapper.
CheckCreateBuilder & setDestination(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Transaction-specific field setters.
CheckCreateBuilder(std::shared_ptr< STTx const > tx)
Construct a CheckCreateBuilder from an existing STTx object.
CheckCreateBuilder & setExpiration(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfExpiration (SoeOptional).
CheckCreateBuilder & setDestinationTag(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfDestinationTag (SoeOptional).
bool hasInvoiceID() const
Check if sfInvoiceID is present.
protocol_autogen::Optional< SF_UINT256::type::value_type > getInvoiceID() const
Get sfInvoiceID (SoeOptional).
SF_ACCOUNT::type::value_type getDestination() const
Get sfDestination (SoeRequired).
bool hasExpiration() const
Check if sfExpiration is present.
CheckCreate(std::shared_ptr< STTx const > tx)
Construct a CheckCreate transaction wrapper from an existing STTx object.
protocol_autogen::Optional< SF_UINT32::type::value_type > getDestinationTag() const
Get sfDestinationTag (SoeOptional).
protocol_autogen::Optional< SF_UINT32::type::value_type > getExpiration() const
Get sfExpiration (SoeOptional).
SF_AMOUNT::type::value_type getSendMax() const
Get sfSendMax (SoeRequired).
bool hasDestinationTag() const
Check if sfDestinationTag is present.
std::shared_ptr< STTx const > tx_
The underlying transaction object being wrapped.
TransactionBase(std::shared_ptr< STTx const > tx)
Construct a transaction wrapper from an existing STTx object.
CheckCreateBuilder & sign(PublicKey const &publicKey, SecretKey const &secretKey)
T make_shared(T... args)
STL namespace.
std::conditional_t< std::is_reference_v< ValueType >, std::optional< std::reference_wrapper< std::remove_reference_t< ValueType > > >, std::optional< ValueType > > Optional
Definition Utils.h:9
TxType
Transaction type identifiers.
Definition TxFormats.h:41