rippled
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
16class VaultWithdrawBuilder;
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};
125
133class VaultWithdrawBuilder : public TransactionBuilderBase<VaultWithdrawBuilder>
134{
135public:
144 VaultWithdrawBuilder(SF_ACCOUNT::type::value_type account,
147)
148 : TransactionBuilderBase<VaultWithdrawBuilder>(ttVAULT_WITHDRAW, account, sequence, fee)
149 {
150 setVaultID(vaultID);
151 setAmount(amount);
152 }
153
160 {
161 if (tx->getTxnType() != ttVAULT_WITHDRAW)
162 {
163 throw std::runtime_error("Invalid transaction type for VaultWithdrawBuilder");
164 }
165 object_ = *tx;
166 }
167
176 {
177 object_[sfVaultID] = value;
178 return *this;
179 }
180
188 {
189 object_[sfAmount] = value;
190 return *this;
191 }
192
199 {
200 object_[sfDestination] = value;
201 return *this;
202 }
203
210 {
211 object_[sfDestinationTag] = value;
212 return *this;
213 }
214
222 build(PublicKey const& publicKey, SecretKey const& secretKey)
223 {
224 sign(publicKey, secretKey);
225 return VaultWithdraw{std::make_shared<STTx>(std::move(object_))};
226 }
227};
228
229} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:42
A secret key.
Definition SecretKey.h:18
Base class for all transaction wrapper types.
std::shared_ptr< STTx const > tx_
The underlying transaction object being wrapped.
Base class for all transaction builders.
VaultWithdrawBuilder & sign(PublicKey const &publicKey, SecretKey const &secretKey)
Sign the transaction with the given keys.
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(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)
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 is_same_v
STL namespace.
TxType
Transaction type identifiers.
Definition TxFormats.h:39