rippled
Loading...
Searching...
No Matches
STTx.h
1#ifndef XRPL_PROTOCOL_STTX_H_INCLUDED
2#define XRPL_PROTOCOL_STTX_H_INCLUDED
3
4#include <xrpl/basics/Expected.h>
5#include <xrpl/protocol/Feature.h>
6#include <xrpl/protocol/PublicKey.h>
7#include <xrpl/protocol/Rules.h>
8#include <xrpl/protocol/STObject.h>
9#include <xrpl/protocol/SecretKey.h>
10#include <xrpl/protocol/SeqProxy.h>
11#include <xrpl/protocol/TxFormats.h>
12
13#include <boost/container/flat_set.hpp>
14
15#include <functional>
16
17namespace ripple {
18
27
28class STTx final : public STObject, public CountedObject<STTx>
29{
32
33public:
34 static constexpr std::size_t minMultiSigners = 1;
35 static constexpr std::size_t maxMultiSigners = 32;
36
37 STTx() = delete;
38 STTx(STTx const& other) = default;
39 STTx&
40 operator=(STTx const& other) = delete;
41
42 explicit STTx(SerialIter& sit);
43 explicit STTx(SerialIter&& sit);
44 explicit STTx(STObject&& object);
45
52 STTx(TxType type, std::function<void(STObject&)> assembler);
53
54 // STObject functions.
56 getSType() const override;
57
59 getFullText() const override;
60
61 // Outer transaction functions / signature functions.
62 static Blob
63 getSignature(STObject const& sigObject);
64
65 Blob
67 {
68 return getSignature(*this);
69 }
70
72 getSigningHash() const;
73
74 TxType
75 getTxnType() const;
76
77 Blob
78 getSigningPubKey() const;
79
81 getSeqProxy() const;
82
85 getSeqValue() const;
86
87 boost::container::flat_set<AccountID>
89
91 getTransactionID() const;
92
94 getJson(JsonOptions options) const override;
95
97 getJson(JsonOptions options, bool binary) const;
98
99 void
100 sign(
101 PublicKey const& publicKey,
102 SecretKey const& secretKey,
104 {});
105
110 Expected<void, std::string>
111 checkSign(Rules const& rules) const;
112
113 Expected<void, std::string>
114 checkBatchSign(Rules const& rules) const;
115
116 // SQL Functions with metadata.
117 static std::string const&
119
121 getMetaSQL(std::uint32_t inLedger, std::string const& escapedMetaData)
122 const;
123
126 Serializer rawTxn,
127 std::uint32_t inLedger,
128 char 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) : STTx(sit)
183{
184}
185
186inline TxType
188{
189 return tx_type_;
190}
191
192inline Blob
194{
195 return getFieldVL(sfSigningPubKey);
196}
197
198inline uint256
200{
201 return tid_;
202}
203
204} // namespace ripple
205
206#endif
Represents a JSON value.
Definition json_value.h:131
Tracks the number of instances of an object.
A public key.
Definition PublicKey.h:43
Blob getFieldVL(SField const &field) const
Definition STObject.cpp:644
boost::container::flat_set< AccountID > getMentionedAccounts() const
Definition STTx.cpp:143
uint256 getSigningHash() const
Definition STTx.cpp:178
static std::string const & getMetaSQLInsertReplaceHeader()
Definition STTx.cpp:348
std::vector< uint256 > batchTxnIds_
Definition STTx.h:162
SeqProxy getSeqProxy() const
Definition STTx.cpp:197
static constexpr std::size_t minMultiSigners
Definition STTx.h:34
Json::Value getJson(JsonOptions options) const override
Definition STTx.cpp:311
std::vector< uint256 > const & getBatchTransactionIDs() const
Retrieves a batch of transaction IDs from the STTx.
Definition STTx.cpp:572
STBase * move(std::size_t n, void *buf) override
Definition STTx.cpp:119
Expected< void, std::string > checkBatchMultiSign(STObject const &batchSigner, Rules const &rules) const
Definition STTx.cpp:514
Expected< void, std::string > checkBatchSingleSign(STObject const &batchSigner) const
Definition STTx.cpp:428
static constexpr std::size_t maxMultiSigners
Definition STTx.h:35
Expected< void, std::string > checkBatchSign(Rules const &rules) const
Definition STTx.cpp:277
Blob getSigningPubKey() const
Definition STTx.h:193
TxType tx_type_
Definition STTx.h:31
uint256 tid_
Definition STTx.h:30
STTx & operator=(STTx const &other)=delete
Blob getSignature() const
Definition STTx.h:66
Expected< void, std::string > checkSingleSign(STObject const &sigObject) const
Definition STTx.cpp:421
Expected< void, std::string > checkMultiSign(Rules const &rules, STObject const &sigObject) const
Definition STTx.cpp:533
STTx()=delete
std::uint32_t getSeqValue() const
Returns the first non-zero value of (Sequence, TicketSequence).
Definition STTx.cpp:212
STTx(STTx const &other)=default
void sign(PublicKey const &publicKey, SecretKey const &secretKey, std::optional< std::reference_wrapper< SField const > > signatureTarget={})
Definition STTx.cpp:218
TxType getTxnType() const
Definition STTx.h:187
std::string getMetaSQL(std::uint32_t inLedger, std::string const &escapedMetaData) const
Definition STTx.cpp:360
Expected< void, std::string > checkSign(Rules const &rules) const
Check the signature.
Definition STTx.cpp:259
uint256 getTransactionID() const
Definition STTx.h:199
SerializedTypeID getSType() const override
Definition STTx.cpp:126
std::string getFullText() const override
Definition STTx.cpp:132
STBase * copy(std::size_t n, void *buf) const override
Definition STTx.cpp:113
A secret key.
Definition SecretKey.h:19
A type that represents either a sequence value or a ticket value.
Definition SeqProxy.h:37
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
std::shared_ptr< STTx const > sterilize(STTx const &stx)
Sterilize a transaction.
Definition STTx.cpp:804
TxType
Transaction type identifiers.
Definition TxFormats.h:38
bool isPseudoTx(STObject const &tx)
Check whether a transaction is a pseudo-transaction.
Definition STTx.cpp:813
SerializedTypeID
Definition SField.h:91
TxnSql
Definition STTx.h:19
@ txnSqlIncluded
Definition STTx.h:24
@ txnSqlUnknown
Definition STTx.h:25
@ txnSqlConflict
Definition STTx.h:21
@ txnSqlHeld
Definition STTx.h:22
@ txnSqlNew
Definition STTx.h:20
@ txnSqlValidated
Definition STTx.h:23
bool passesLocalChecks(STObject const &st, std::string &)
Definition STTx.cpp:774
Note, should be treated as flags that can be | and &.
Definition STBase.h:18