rippled
Loading...
Searching...
No Matches
STTx.h
1#pragma once
2
3#include <xrpl/basics/Expected.h>
4#include <xrpl/protocol/Feature.h>
5#include <xrpl/protocol/PublicKey.h>
6#include <xrpl/protocol/Rules.h>
7#include <xrpl/protocol/STObject.h>
8#include <xrpl/protocol/SecretKey.h>
9#include <xrpl/protocol/SeqProxy.h>
10#include <xrpl/protocol/TxFormats.h>
11
12#include <boost/container/flat_set.hpp>
13
14#include <functional>
15
16namespace xrpl {
17
18enum class TxnSql : char {
19 txnSqlNew = 'N',
20 txnSqlConflict = 'C',
21 txnSqlHeld = 'H',
22 txnSqlValidated = 'V',
23 txnSqlIncluded = 'I',
24 txnSqlUnknown = 'U'
25};
26
27class STTx final : public STObject, public CountedObject<STTx>
28{
31
32public:
33 static constexpr std::size_t minMultiSigners = 1;
34 static constexpr std::size_t maxMultiSigners = 32;
35
36 STTx() = delete;
37 STTx(STTx const& other) = default;
38 STTx&
39 operator=(STTx const& other) = delete;
40
41 explicit STTx(SerialIter& sit);
42 explicit STTx(SerialIter&& sit);
43 explicit STTx(STObject&& object);
44
51 STTx(TxType type, std::function<void(STObject&)> assembler);
52
53 // STObject functions.
55 getSType() const override;
56
58 getFullText() const override;
59
60 // Outer transaction functions / signature functions.
61 static Blob
62 getSignature(STObject const& sigObject);
63
64 Blob
66 {
67 return getSignature(*this);
68 }
69
71 getSigningHash() const;
72
73 TxType
74 getTxnType() const;
75
76 Blob
77 getSigningPubKey() const;
78
80 getSeqProxy() const;
81
84 getSeqValue() const;
85
87 getFeePayer() const;
88
89 boost::container::flat_set<AccountID>
91
93 getTransactionID() const;
94
96 getJson(JsonOptions options) const override;
97
99 getJson(JsonOptions options, bool binary) const;
100
101 void
102 sign(
103 PublicKey const& publicKey,
104 SecretKey const& secretKey,
106
111 Expected<void, std::string>
112 checkSign(Rules const& rules) const;
113
114 Expected<void, std::string>
115 checkBatchSign(Rules const& rules) const;
116
117 // SQL Functions with metadata.
118 static std::string const&
120
122 getMetaSQL(std::uint32_t inLedger, std::string const& escapedMetaData) const;
123
126 Serializer rawTxn,
127 std::uint32_t inLedger,
128 TxnSql status,
129 std::string const& escapedMetaData) const;
130
133
134private:
141 Expected<void, std::string>
142 checkSign(Rules const& rules, STObject const& sigObject) const;
143
144 Expected<void, std::string>
145 checkSingleSign(STObject const& sigObject) const;
146
147 Expected<void, std::string>
148 checkMultiSign(Rules const& rules, STObject const& sigObject) const;
149
150 Expected<void, std::string>
151 checkBatchSingleSign(STObject const& batchSigner) const;
152
153 Expected<void, std::string>
154 checkBatchMultiSign(STObject const& batchSigner, Rules const& rules) const;
155
156 STBase*
157 copy(std::size_t n, void* buf) const override;
158 STBase*
159 move(std::size_t n, void* buf) override;
160
161 friend class detail::STVar;
163};
164
165bool
167
176sterilize(STTx const& stx);
177
179bool
180isPseudoTx(STObject const& tx);
181
182inline STTx::STTx(SerialIter&& sit) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
183 : STTx(sit)
184{
185}
186
187inline TxType
189{
190 return tx_type_;
191}
192
193inline Blob
195{
196 return getFieldVL(sfSigningPubKey);
197}
198
199inline uint256
201{
202 return tid_;
203}
204
205} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
Tracks the number of instances of an object.
A public key.
Definition PublicKey.h:42
Blob getFieldVL(SField const &field) const
Definition STObject.cpp:641
std::string getFullText() const override
Definition STTx.cpp:131
Expected< void, std::string > checkBatchSingleSign(STObject const &batchSigner) const
Definition STTx.cpp:431
STBase * move(std::size_t n, void *buf) override
Definition STTx.cpp:118
Blob getSignature() const
Definition STTx.h:65
std::string getMetaSQL(std::uint32_t inLedger, std::string const &escapedMetaData) const
Definition STTx.cpp:366
TxType tx_type_
Definition STTx.h:30
Expected< void, std::string > checkMultiSign(Rules const &rules, STObject const &sigObject) const
Definition STTx.cpp:535
uint256 tid_
Definition STTx.h:29
STTx & operator=(STTx const &other)=delete
Expected< void, std::string > checkBatchSign(Rules const &rules) const
Definition STTx.cpp:287
Json::Value getJson(JsonOptions options) const override
Definition STTx.cpp:317
static std::string const & getMetaSQLInsertReplaceHeader()
Definition STTx.cpp:354
STTx(STTx const &other)=default
std::vector< uint256 > const & getBatchTransactionIDs() const
Retrieves a batch of transaction IDs from the STTx.
Definition STTx.cpp:573
Expected< void, std::string > checkBatchMultiSign(STObject const &batchSigner, Rules const &rules) const
Definition STTx.cpp:516
SeqProxy getSeqProxy() const
Definition STTx.cpp:194
AccountID getFeePayer() const
Definition STTx.cpp:217
STBase * copy(std::size_t n, void *buf) const override
Definition STTx.cpp:112
STTx()=delete
static constexpr std::size_t minMultiSigners
Definition STTx.h:33
Expected< void, std::string > checkSign(Rules const &rules) const
Check the signature.
Definition STTx.cpp:272
std::uint32_t getSeqValue() const
Returns the first non-zero value of (Sequence, TicketSequence).
Definition STTx.cpp:211
TxType getTxnType() const
Definition STTx.h:188
std::vector< uint256 > batchTxnIds_
Definition STTx.h:162
Expected< void, std::string > checkSingleSign(STObject const &sigObject) const
Definition STTx.cpp:424
Blob getSigningPubKey() const
Definition STTx.h:194
uint256 getSigningHash() const
Definition STTx.cpp:175
static constexpr std::size_t maxMultiSigners
Definition STTx.h:34
uint256 getTransactionID() const
Definition STTx.h:200
SerializedTypeID getSType() const override
Definition STTx.cpp:125
boost::container::flat_set< AccountID > getMentionedAccounts() const
Definition STTx.cpp:142
void sign(PublicKey const &publicKey, SecretKey const &secretKey, std::optional< std::reference_wrapper< SField const > > signatureTarget={})
Definition STTx.cpp:231
A secret key.
Definition SecretKey.h:18
A type that represents either a sequence value or a ticket value.
Definition SeqProxy.h:36
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
TxType
Transaction type identifiers.
Definition TxFormats.h:39
TxnSql
Definition STTx.h:18
SerializedTypeID
Definition SField.h:90
bool passesLocalChecks(STObject const &st, std::string &)
Definition STTx.cpp:770
std::shared_ptr< STTx const > sterilize(STTx const &stx)
Sterilize a transaction.
Definition STTx.cpp:800
bool isPseudoTx(STObject const &tx)
Check whether a transaction is a pseudo-transaction.
Definition STTx.cpp:809
Note, should be treated as flags that can be | and &.
Definition STBase.h:17