xrpld
Loading...
Searching...
No Matches
protocol_autogen/transactions/VaultWithdraw.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 = ttVAULT_WITHDRAW;
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 VaultWithdraw");
45 }
46 }
47
48 // Transaction-specific field getters
49
54 [[nodiscard]]
55 SF_UINT256::type::value_type
56 getVaultID() const
57 {
58 return this->tx_->at(sfVaultID);
59 }
60
66 [[nodiscard]]
67 SF_AMOUNT::type::value_type
68 getAmount() const
69 {
70 return this->tx_->at(sfAmount);
71 }
72
77 [[nodiscard]]
80 {
81 if (hasDestination())
82 {
83 return this->tx_->at(sfDestination);
84 }
85 return std::nullopt;
86 }
87
92 [[nodiscard]]
93 bool
95 {
96 return this->tx_->isFieldPresent(sfDestination);
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 (hasCredentialIDs())
134 {
135 return this->tx_->at(sfCredentialIDs);
136 }
137 return std::nullopt;
138 }
139
144 [[nodiscard]]
145 bool
147 {
148 return this->tx_->isFieldPresent(sfCredentialIDs);
149 }
150};
151
159class VaultWithdrawBuilder : public TransactionBuilderBase<VaultWithdrawBuilder>
160{
161public:
170 VaultWithdrawBuilder(SF_ACCOUNT::type::value_type account,
173)
174 : TransactionBuilderBase<VaultWithdrawBuilder>(ttVAULT_WITHDRAW, account, sequence, fee)
175 {
176 setVaultID(vaultID);
177 setAmount(amount);
178 }
179
186 {
187 if (tx->getTxnType() != ttVAULT_WITHDRAW)
188 {
189 throw std::runtime_error("Invalid transaction type for VaultWithdrawBuilder");
190 }
191 object_ = *tx;
192 }
193
197
204 {
205 object_[sfVaultID] = value;
206 return *this;
207 }
208
216 {
217 object_[sfAmount] = value;
218 return *this;
219 }
220
227 {
228 object_[sfDestination] = value;
229 return *this;
230 }
231
238 {
239 object_[sfDestinationTag] = value;
240 return *this;
241 }
242
249 {
250 object_[sfCredentialIDs] = value;
251 return *this;
252 }
253
261 build(PublicKey const& publicKey, SecretKey const& secretKey)
262 {
263 sign(publicKey, secretKey);
264 return VaultWithdraw{std::make_shared<STTx>(std::move(object_))};
265 }
266};
267
268} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:53
A secret key.
Definition SecretKey.h:24
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.
VaultWithdrawBuilder & sign(PublicKey const &publicKey, SecretKey const &secretKey)
VaultWithdraw build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the VaultWithdraw wrapper.
VaultWithdrawBuilder & setDestination(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfDestination (SoeOptional).
VaultWithdrawBuilder(std::shared_ptr< STTx const > tx)
Construct a VaultWithdrawBuilder from an existing STTx object.
VaultWithdrawBuilder & setVaultID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Transaction-specific field setters.
VaultWithdrawBuilder & setAmount(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfAmount (SoeRequired).
VaultWithdrawBuilder & setCredentialIDs(std::decay_t< typename SF_VECTOR256::type::value_type > const &value)
Set sfCredentialIDs (SoeOptional).
VaultWithdrawBuilder(SF_ACCOUNT::type::value_type account, std::decay_t< typename SF_UINT256::type::value_type > const &vaultID, std::decay_t< typename SF_AMOUNT::type::value_type > const &amount, std::optional< SF_UINT32::type::value_type > sequence=std::nullopt, std::optional< SF_AMOUNT::type::value_type > fee=std::nullopt)
Construct a new VaultWithdrawBuilder with required fields.
VaultWithdrawBuilder & setDestinationTag(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfDestinationTag (SoeOptional).
protocol_autogen::Optional< SF_UINT32::type::value_type > getDestinationTag() const
Get sfDestinationTag (SoeOptional).
SF_UINT256::type::value_type getVaultID() const
Get sfVaultID (SoeRequired).
VaultWithdraw(std::shared_ptr< STTx const > tx)
Construct a VaultWithdraw transaction wrapper from an existing STTx object.
protocol_autogen::Optional< SF_ACCOUNT::type::value_type > getDestination() const
Get sfDestination (SoeOptional).
protocol_autogen::Optional< SF_VECTOR256::type::value_type > getCredentialIDs() const
Get sfCredentialIDs (SoeOptional).
bool hasCredentialIDs() const
Check if sfCredentialIDs is present.
bool hasDestination() const
Check if sfDestination is present.
bool hasDestinationTag() const
Check if sfDestinationTag is present.
SF_AMOUNT::type::value_type getAmount() const
Get sfAmount (SoeRequired).
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:45