rippled
Loading...
Searching...
No Matches
protocol_autogen/transactions/Clawback.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 ClawbackBuilder;
17
30{
31public:
32 static constexpr xrpl::TxType txType = ttCLAWBACK;
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 Clawback");
45 }
46 }
47
48 // Transaction-specific field getters
49
55 [[nodiscard]]
56 SF_AMOUNT::type::value_type
57 getAmount() const
58 {
59 return this->tx_->at(sfAmount);
60 }
61
66 [[nodiscard]]
68 getHolder() const
69 {
70 if (hasHolder())
71 {
72 return this->tx_->at(sfHolder);
73 }
74 return std::nullopt;
75 }
76
81 [[nodiscard]]
82 bool
83 hasHolder() const
84 {
85 return this->tx_->isFieldPresent(sfHolder);
86 }
87};
88
96class ClawbackBuilder : public TransactionBuilderBase<ClawbackBuilder>
97{
98public:
106 ClawbackBuilder(SF_ACCOUNT::type::value_type account,
109)
110 : TransactionBuilderBase<ClawbackBuilder>(ttCLAWBACK, account, sequence, fee)
111 {
112 setAmount(amount);
113 }
114
121 {
122 if (tx->getTxnType() != ttCLAWBACK)
123 {
124 throw std::runtime_error("Invalid transaction type for ClawbackBuilder");
125 }
126 object_ = *tx;
127 }
128
138 {
139 object_[sfAmount] = value;
140 return *this;
141 }
142
149 {
150 object_[sfHolder] = value;
151 return *this;
152 }
153
161 build(PublicKey const& publicKey, SecretKey const& secretKey)
162 {
163 sign(publicKey, secretKey);
164 return Clawback{std::make_shared<STTx>(std::move(object_))};
165 }
166};
167
168} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:42
A secret key.
Definition SecretKey.h:18
ClawbackBuilder & setHolder(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfHolder (soeOPTIONAL)
ClawbackBuilder & setAmount(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Transaction-specific field setters.
ClawbackBuilder(SF_ACCOUNT::type::value_type account, 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 ClawbackBuilder with required fields.
ClawbackBuilder(std::shared_ptr< STTx const > tx)
Construct a ClawbackBuilder from an existing STTx object.
Clawback build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the Clawback wrapper.
bool hasHolder() const
Check if sfHolder is present.
SF_AMOUNT::type::value_type getAmount() const
Get sfAmount (soeREQUIRED)
protocol_autogen::Optional< SF_ACCOUNT::type::value_type > getHolder() const
Get sfHolder (soeOPTIONAL)
Clawback(std::shared_ptr< STTx const > tx)
Construct a Clawback transaction wrapper from an existing STTx object.
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.
ClawbackBuilder & 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