rippled
Loading...
Searching...
No Matches
protocol_autogen/transactions/PaymentChannelCreate.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 PaymentChannelCreateBuilder;
17
30{
31public:
32 static constexpr xrpl::TxType txType = ttPAYCHAN_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 PaymentChannelCreate");
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
65 [[nodiscard]]
66 SF_AMOUNT::type::value_type
67 getAmount() const
68 {
69 return this->tx_->at(sfAmount);
70 }
71
76 [[nodiscard]]
77 SF_UINT32::type::value_type
79 {
80 return this->tx_->at(sfSettleDelay);
81 }
82
87 [[nodiscard]]
88 SF_VL::type::value_type
90 {
91 return this->tx_->at(sfPublicKey);
92 }
93
98 [[nodiscard]]
101 {
102 if (hasCancelAfter())
103 {
104 return this->tx_->at(sfCancelAfter);
105 }
106 return std::nullopt;
107 }
108
113 [[nodiscard]]
114 bool
116 {
117 return this->tx_->isFieldPresent(sfCancelAfter);
118 }
119
124 [[nodiscard]]
127 {
128 if (hasDestinationTag())
129 {
130 return this->tx_->at(sfDestinationTag);
131 }
132 return std::nullopt;
133 }
134
139 [[nodiscard]]
140 bool
142 {
143 return this->tx_->isFieldPresent(sfDestinationTag);
144 }
145};
146
154class PaymentChannelCreateBuilder : public TransactionBuilderBase<PaymentChannelCreateBuilder>
155{
156public:
178
185 {
186 if (tx->getTxnType() != ttPAYCHAN_CREATE)
187 {
188 throw std::runtime_error("Invalid transaction type for PaymentChannelCreateBuilder");
189 }
190 object_ = *tx;
191 }
192
201 {
202 object_[sfDestination] = value;
203 return *this;
204 }
205
212 {
213 object_[sfAmount] = value;
214 return *this;
215 }
216
223 {
224 object_[sfSettleDelay] = value;
225 return *this;
226 }
227
234 {
235 object_[sfPublicKey] = value;
236 return *this;
237 }
238
245 {
246 object_[sfCancelAfter] = value;
247 return *this;
248 }
249
256 {
257 object_[sfDestinationTag] = value;
258 return *this;
259 }
260
268 build(PublicKey const& publicKey, SecretKey const& secretKey)
269 {
270 sign(publicKey, secretKey);
272 }
273};
274
275} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:42
A secret key.
Definition SecretKey.h:18
PaymentChannelCreateBuilder & setPublicKey(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfPublicKey (soeREQUIRED)
PaymentChannelCreateBuilder & setAmount(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfAmount (soeREQUIRED)
PaymentChannelCreateBuilder & setDestination(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Transaction-specific field setters.
PaymentChannelCreate build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the PaymentChannelCreate wrapper.
PaymentChannelCreateBuilder & setDestinationTag(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfDestinationTag (soeOPTIONAL)
PaymentChannelCreateBuilder(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 &amount, std::decay_t< typename SF_UINT32::type::value_type > const &settleDelay, std::decay_t< typename SF_VL::type::value_type > const &publicKey, std::optional< SF_UINT32::type::value_type > sequence=std::nullopt, std::optional< SF_AMOUNT::type::value_type > fee=std::nullopt)
Construct a new PaymentChannelCreateBuilder with required fields.
PaymentChannelCreateBuilder(std::shared_ptr< STTx const > tx)
Construct a PaymentChannelCreateBuilder from an existing STTx object.
PaymentChannelCreateBuilder & setSettleDelay(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfSettleDelay (soeREQUIRED)
PaymentChannelCreateBuilder & setCancelAfter(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfCancelAfter (soeOPTIONAL)
SF_UINT32::type::value_type getSettleDelay() const
Get sfSettleDelay (soeREQUIRED)
protocol_autogen::Optional< SF_UINT32::type::value_type > getCancelAfter() const
Get sfCancelAfter (soeOPTIONAL)
SF_AMOUNT::type::value_type getAmount() const
Get sfAmount (soeREQUIRED)
protocol_autogen::Optional< SF_UINT32::type::value_type > getDestinationTag() const
Get sfDestinationTag (soeOPTIONAL)
SF_ACCOUNT::type::value_type getDestination() const
Get sfDestination (soeREQUIRED)
bool hasDestinationTag() const
Check if sfDestinationTag is present.
PaymentChannelCreate(std::shared_ptr< STTx const > tx)
Construct a PaymentChannelCreate transaction wrapper from an existing STTx object.
SF_VL::type::value_type getPublicKey() const
Get sfPublicKey (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.
PaymentChannelCreateBuilder & 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