xrpld
Loading...
Searching...
No Matches
PayChannel.h
1// This file is auto-generated. Do not edit.
2#pragma once
3
4#include <xrpl/protocol/STLedgerEntry.h>
5#include <xrpl/protocol/STParsedJSON.h>
6#include <xrpl/protocol/jss.h>
7#include <xrpl/protocol_autogen/LedgerEntryBase.h>
8#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
9#include <xrpl/json/json_value.h>
10
11#include <stdexcept>
12#include <optional>
13
14namespace xrpl::ledger_entries {
15
17
28{
29public:
30 static constexpr LedgerEntryType entryType = ltPAYCHAN;
31
37 : LedgerEntryBase(std::move(sle))
38 {
39 // Verify ledger entry type
40 if (sle_->getType() != entryType)
41 {
42 throw std::runtime_error("Invalid ledger entry type for PayChannel");
43 }
44 }
45
46 // Ledger entry-specific field getters
47
52 [[nodiscard]]
53 SF_ACCOUNT::type::value_type
54 getAccount() const
55 {
56 return this->sle_->at(sfAccount);
57 }
58
63 [[nodiscard]]
64 SF_ACCOUNT::type::value_type
66 {
67 return this->sle_->at(sfDestination);
68 }
69
74 [[nodiscard]]
77 {
78 if (hasSequence())
79 return this->sle_->at(sfSequence);
80 return std::nullopt;
81 }
82
87 [[nodiscard]]
88 bool
90 {
91 return this->sle_->isFieldPresent(sfSequence);
92 }
93
98 [[nodiscard]]
99 SF_AMOUNT::type::value_type
100 getAmount() const
101 {
102 return this->sle_->at(sfAmount);
103 }
104
109 [[nodiscard]]
110 SF_AMOUNT::type::value_type
112 {
113 return this->sle_->at(sfBalance);
114 }
115
120 [[nodiscard]]
121 SF_VL::type::value_type
123 {
124 return this->sle_->at(sfPublicKey);
125 }
126
131 [[nodiscard]]
132 SF_UINT32::type::value_type
134 {
135 return this->sle_->at(sfSettleDelay);
136 }
137
142 [[nodiscard]]
145 {
146 if (hasExpiration())
147 return this->sle_->at(sfExpiration);
148 return std::nullopt;
149 }
150
155 [[nodiscard]]
156 bool
158 {
159 return this->sle_->isFieldPresent(sfExpiration);
160 }
161
166 [[nodiscard]]
169 {
170 if (hasCancelAfter())
171 return this->sle_->at(sfCancelAfter);
172 return std::nullopt;
173 }
174
179 [[nodiscard]]
180 bool
182 {
183 return this->sle_->isFieldPresent(sfCancelAfter);
184 }
185
190 [[nodiscard]]
193 {
194 if (hasSourceTag())
195 return this->sle_->at(sfSourceTag);
196 return std::nullopt;
197 }
198
203 [[nodiscard]]
204 bool
206 {
207 return this->sle_->isFieldPresent(sfSourceTag);
208 }
209
214 [[nodiscard]]
217 {
218 if (hasDestinationTag())
219 return this->sle_->at(sfDestinationTag);
220 return std::nullopt;
221 }
222
227 [[nodiscard]]
228 bool
230 {
231 return this->sle_->isFieldPresent(sfDestinationTag);
232 }
233
238 [[nodiscard]]
239 SF_UINT64::type::value_type
241 {
242 return this->sle_->at(sfOwnerNode);
243 }
244
249 [[nodiscard]]
250 SF_UINT256::type::value_type
252 {
253 return this->sle_->at(sfPreviousTxnID);
254 }
255
260 [[nodiscard]]
261 SF_UINT32::type::value_type
263 {
264 return this->sle_->at(sfPreviousTxnLgrSeq);
265 }
266
271 [[nodiscard]]
274 {
275 if (hasDestinationNode())
276 return this->sle_->at(sfDestinationNode);
277 return std::nullopt;
278 }
279
284 [[nodiscard]]
285 bool
287 {
288 return this->sle_->isFieldPresent(sfDestinationNode);
289 }
290};
291
299class PayChannelBuilder : public LedgerEntryBuilderBase<PayChannelBuilder>
300{
301public:
327
334 {
335 if (sle->at(sfLedgerEntryType) != ltPAYCHAN)
336 {
337 throw std::runtime_error("Invalid ledger entry type for PayChannel");
338 }
339 object_ = *sle;
340 }
341
345
352 {
353 object_[sfAccount] = value;
354 return *this;
355 }
356
363 {
364 object_[sfDestination] = value;
365 return *this;
366 }
367
374 {
375 object_[sfSequence] = value;
376 return *this;
377 }
378
385 {
386 object_[sfAmount] = value;
387 return *this;
388 }
389
396 {
397 object_[sfBalance] = value;
398 return *this;
399 }
400
407 {
408 object_[sfPublicKey] = value;
409 return *this;
410 }
411
418 {
419 object_[sfSettleDelay] = value;
420 return *this;
421 }
422
429 {
430 object_[sfExpiration] = value;
431 return *this;
432 }
433
440 {
441 object_[sfCancelAfter] = value;
442 return *this;
443 }
444
451 {
452 object_[sfSourceTag] = value;
453 return *this;
454 }
455
462 {
463 object_[sfDestinationTag] = value;
464 return *this;
465 }
466
473 {
474 object_[sfOwnerNode] = value;
475 return *this;
476 }
477
484 {
485 object_[sfPreviousTxnID] = value;
486 return *this;
487 }
488
495 {
496 object_[sfPreviousTxnLgrSeq] = value;
497 return *this;
498 }
499
506 {
507 object_[sfDestinationNode] = value;
508 return *this;
509 }
510
517 build(uint256 const& index)
518 {
519 return PayChannel{std::make_shared<SLE>(std::move(object_), index)};
520 }
521};
522
523} // namespace xrpl::ledger_entries
std::shared_ptr< STLedgerEntry const > const_pointer
LedgerEntryBase(SLE::const_pointer sle)
Construct a ledger entry wrapper from an existing SLE object.
SLE::const_pointer sle_
The underlying serialized ledger entry being wrapped.
Builder for PayChannel ledger entries.
Definition PayChannel.h:300
PayChannelBuilder & setBalance(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfBalance (SoeRequired).
Definition PayChannel.h:395
PayChannel build(uint256 const &index)
Build and return the completed PayChannel wrapper.
Definition PayChannel.h:517
PayChannelBuilder & setDestinationTag(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfDestinationTag (SoeOptional).
Definition PayChannel.h:461
PayChannelBuilder & setSourceTag(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfSourceTag (SoeOptional).
Definition PayChannel.h:450
PayChannelBuilder & setSequence(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfSequence (SoeOptional).
Definition PayChannel.h:373
PayChannelBuilder & setCancelAfter(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfCancelAfter (SoeOptional).
Definition PayChannel.h:439
PayChannelBuilder & setExpiration(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfExpiration (SoeOptional).
Definition PayChannel.h:428
PayChannelBuilder & setDestinationNode(std::decay_t< typename SF_UINT64::type::value_type > const &value)
Set sfDestinationNode (SoeOptional).
Definition PayChannel.h:505
PayChannelBuilder & setAccount(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Ledger entry-specific field setters.
Definition PayChannel.h:351
PayChannelBuilder & setPreviousTxnID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Set sfPreviousTxnID (SoeRequired).
Definition PayChannel.h:483
PayChannelBuilder & setDestination(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfDestination (SoeRequired).
Definition PayChannel.h:362
PayChannelBuilder & setPreviousTxnLgrSeq(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfPreviousTxnLgrSeq (SoeRequired).
Definition PayChannel.h:494
PayChannelBuilder & setOwnerNode(std::decay_t< typename SF_UINT64::type::value_type > const &value)
Set sfOwnerNode (SoeRequired).
Definition PayChannel.h:472
PayChannelBuilder(SLE::const_pointer sle)
Construct a PayChannelBuilder from an existing SLE object.
Definition PayChannel.h:333
PayChannelBuilder & setPublicKey(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfPublicKey (SoeRequired).
Definition PayChannel.h:406
PayChannelBuilder & setSettleDelay(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfSettleDelay (SoeRequired).
Definition PayChannel.h:417
PayChannelBuilder & setAmount(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfAmount (SoeRequired).
Definition PayChannel.h:384
PayChannelBuilder(std::decay_t< typename SF_ACCOUNT::type::value_type > const &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_AMOUNT::type::value_type > const &balance, std::decay_t< typename SF_VL::type::value_type > const &publicKey, std::decay_t< typename SF_UINT32::type::value_type > const &settleDelay, std::decay_t< typename SF_UINT64::type::value_type > const &ownerNode, std::decay_t< typename SF_UINT256::type::value_type > const &previousTxnID, std::decay_t< typename SF_UINT32::type::value_type > const &previousTxnLgrSeq)
Construct a new PayChannelBuilder with required fields.
Definition PayChannel.h:314
Ledger Entry: PayChannel.
Definition PayChannel.h:28
SF_VL::type::value_type getPublicKey() const
Get sfPublicKey (SoeRequired).
Definition PayChannel.h:122
SF_UINT32::type::value_type getSettleDelay() const
Get sfSettleDelay (SoeRequired).
Definition PayChannel.h:133
PayChannel(SLE::const_pointer sle)
Construct a PayChannel ledger entry wrapper from an existing SLE object.
Definition PayChannel.h:36
bool hasExpiration() const
Check if sfExpiration is present.
Definition PayChannel.h:157
bool hasDestinationNode() const
Check if sfDestinationNode is present.
Definition PayChannel.h:286
bool hasSequence() const
Check if sfSequence is present.
Definition PayChannel.h:89
SF_ACCOUNT::type::value_type getDestination() const
Get sfDestination (SoeRequired).
Definition PayChannel.h:65
protocol_autogen::Optional< SF_UINT32::type::value_type > getDestinationTag() const
Get sfDestinationTag (SoeOptional).
Definition PayChannel.h:216
protocol_autogen::Optional< SF_UINT64::type::value_type > getDestinationNode() const
Get sfDestinationNode (SoeOptional).
Definition PayChannel.h:273
bool hasSourceTag() const
Check if sfSourceTag is present.
Definition PayChannel.h:205
protocol_autogen::Optional< SF_UINT32::type::value_type > getSequence() const
Get sfSequence (SoeOptional).
Definition PayChannel.h:76
SF_AMOUNT::type::value_type getBalance() const
Get sfBalance (SoeRequired).
Definition PayChannel.h:111
SF_AMOUNT::type::value_type getAmount() const
Get sfAmount (SoeRequired).
Definition PayChannel.h:100
SF_UINT32::type::value_type getPreviousTxnLgrSeq() const
Get sfPreviousTxnLgrSeq (SoeRequired).
Definition PayChannel.h:262
static constexpr LedgerEntryType entryType
Definition PayChannel.h:30
protocol_autogen::Optional< SF_UINT32::type::value_type > getSourceTag() const
Get sfSourceTag (SoeOptional).
Definition PayChannel.h:192
SF_UINT64::type::value_type getOwnerNode() const
Get sfOwnerNode (SoeRequired).
Definition PayChannel.h:240
protocol_autogen::Optional< SF_UINT32::type::value_type > getCancelAfter() const
Get sfCancelAfter (SoeOptional).
Definition PayChannel.h:168
protocol_autogen::Optional< SF_UINT32::type::value_type > getExpiration() const
Get sfExpiration (SoeOptional).
Definition PayChannel.h:144
bool hasCancelAfter() const
Check if sfCancelAfter is present.
Definition PayChannel.h:181
SF_ACCOUNT::type::value_type getAccount() const
Get sfAccount (SoeRequired).
Definition PayChannel.h:54
bool hasDestinationTag() const
Check if sfDestinationTag is present.
Definition PayChannel.h:229
SF_UINT256::type::value_type getPreviousTxnID() const
Get sfPreviousTxnID (SoeRequired).
Definition PayChannel.h:251
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
LedgerEntryType
Identifiers for on-ledger objects.
BaseUInt< 256 > uint256
Definition base_uint.h:580