rippled
Loading...
Searching...
No Matches
protocol_autogen/transactions/PaymentChannelClaim.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 PaymentChannelClaimBuilder;
17
30{
31public:
32 static constexpr xrpl::TxType txType = ttPAYCHAN_CLAIM;
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 PaymentChannelClaim");
45 }
46 }
47
48 // Transaction-specific field getters
49
54 [[nodiscard]]
55 SF_UINT256::type::value_type
56 getChannel() const
57 {
58 return this->tx_->at(sfChannel);
59 }
60
65 [[nodiscard]]
67 getAmount() const
68 {
69 if (hasAmount())
70 {
71 return this->tx_->at(sfAmount);
72 }
73 return std::nullopt;
74 }
75
80 [[nodiscard]]
81 bool
82 hasAmount() const
83 {
84 return this->tx_->isFieldPresent(sfAmount);
85 }
86
91 [[nodiscard]]
93 getBalance() const
94 {
95 if (hasBalance())
96 {
97 return this->tx_->at(sfBalance);
98 }
99 return std::nullopt;
100 }
101
106 [[nodiscard]]
107 bool
109 {
110 return this->tx_->isFieldPresent(sfBalance);
111 }
112
117 [[nodiscard]]
120 {
121 if (hasSignature())
122 {
123 return this->tx_->at(sfSignature);
124 }
125 return std::nullopt;
126 }
127
132 [[nodiscard]]
133 bool
135 {
136 return this->tx_->isFieldPresent(sfSignature);
137 }
138
143 [[nodiscard]]
146 {
147 if (hasPublicKey())
148 {
149 return this->tx_->at(sfPublicKey);
150 }
151 return std::nullopt;
152 }
153
158 [[nodiscard]]
159 bool
161 {
162 return this->tx_->isFieldPresent(sfPublicKey);
163 }
164
169 [[nodiscard]]
172 {
173 if (hasCredentialIDs())
174 {
175 return this->tx_->at(sfCredentialIDs);
176 }
177 return std::nullopt;
178 }
179
184 [[nodiscard]]
185 bool
187 {
188 return this->tx_->isFieldPresent(sfCredentialIDs);
189 }
190};
191
199class PaymentChannelClaimBuilder : public TransactionBuilderBase<PaymentChannelClaimBuilder>
200{
201public:
209 PaymentChannelClaimBuilder(SF_ACCOUNT::type::value_type account,
212)
213 : TransactionBuilderBase<PaymentChannelClaimBuilder>(ttPAYCHAN_CLAIM, account, sequence, fee)
214 {
215 setChannel(channel);
216 }
217
224 {
225 if (tx->getTxnType() != ttPAYCHAN_CLAIM)
226 {
227 throw std::runtime_error("Invalid transaction type for PaymentChannelClaimBuilder");
228 }
229 object_ = *tx;
230 }
231
240 {
241 object_[sfChannel] = value;
242 return *this;
243 }
244
251 {
252 object_[sfAmount] = value;
253 return *this;
254 }
255
262 {
263 object_[sfBalance] = value;
264 return *this;
265 }
266
273 {
274 object_[sfSignature] = value;
275 return *this;
276 }
277
284 {
285 object_[sfPublicKey] = value;
286 return *this;
287 }
288
295 {
296 object_[sfCredentialIDs] = value;
297 return *this;
298 }
299
307 build(PublicKey const& publicKey, SecretKey const& secretKey)
308 {
309 sign(publicKey, secretKey);
311 }
312};
313
314} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:42
A secret key.
Definition SecretKey.h:18
PaymentChannelClaimBuilder(SF_ACCOUNT::type::value_type account, std::decay_t< typename SF_UINT256::type::value_type > const &channel, std::optional< SF_UINT32::type::value_type > sequence=std::nullopt, std::optional< SF_AMOUNT::type::value_type > fee=std::nullopt)
Construct a new PaymentChannelClaimBuilder with required fields.
PaymentChannelClaim build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the PaymentChannelClaim wrapper.
PaymentChannelClaimBuilder & setBalance(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfBalance (soeOPTIONAL)
PaymentChannelClaimBuilder & setChannel(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Transaction-specific field setters.
PaymentChannelClaimBuilder & setPublicKey(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfPublicKey (soeOPTIONAL)
PaymentChannelClaimBuilder(std::shared_ptr< STTx const > tx)
Construct a PaymentChannelClaimBuilder from an existing STTx object.
PaymentChannelClaimBuilder & setSignature(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfSignature (soeOPTIONAL)
PaymentChannelClaimBuilder & setCredentialIDs(std::decay_t< typename SF_VECTOR256::type::value_type > const &value)
Set sfCredentialIDs (soeOPTIONAL)
PaymentChannelClaimBuilder & setAmount(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfAmount (soeOPTIONAL)
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getAmount() const
Get sfAmount (soeOPTIONAL)
bool hasCredentialIDs() const
Check if sfCredentialIDs is present.
protocol_autogen::Optional< SF_VL::type::value_type > getPublicKey() const
Get sfPublicKey (soeOPTIONAL)
protocol_autogen::Optional< SF_VL::type::value_type > getSignature() const
Get sfSignature (soeOPTIONAL)
PaymentChannelClaim(std::shared_ptr< STTx const > tx)
Construct a PaymentChannelClaim transaction wrapper from an existing STTx object.
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getBalance() const
Get sfBalance (soeOPTIONAL)
protocol_autogen::Optional< SF_VECTOR256::type::value_type > getCredentialIDs() const
Get sfCredentialIDs (soeOPTIONAL)
SF_UINT256::type::value_type getChannel() const
Get sfChannel (soeREQUIRED)
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.
PaymentChannelClaimBuilder & sign(PublicKey const &publicKey, SecretKey const &secretKey)
Sign the transaction with the given keys.
T is_same_v
STL namespace.
TxType
Transaction type identifiers.
Definition TxFormats.h:39