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
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
86 boost::container::flat_set<AccountID>
88
90 getTransactionID() const;
91
93 getJson(JsonOptions options) const override;
94
96 getJson(JsonOptions options, bool binary) const;
97
98 void
99 sign(
100 PublicKey const& publicKey,
101 SecretKey const& secretKey,
103
108 Expected<void, std::string>
109 checkSign(Rules const& rules) const;
110
111 Expected<void, std::string>
112 checkBatchSign(Rules const& rules) const;
113
114 // SQL Functions with metadata.
115 static std::string const&
117
119 getMetaSQL(std::uint32_t inLedger, std::string const& escapedMetaData) const;
120
122 getMetaSQL(Serializer rawTxn, std::uint32_t inLedger, char status, std::string const& escapedMetaData) const;
123
126
127private:
134 Expected<void, std::string>
135 checkSign(Rules const& rules, STObject const& sigObject) const;
136
137 Expected<void, std::string>
138 checkSingleSign(STObject const& sigObject) const;
139
140 Expected<void, std::string>
141 checkMultiSign(Rules const& rules, STObject const& sigObject) const;
142
143 Expected<void, std::string>
144 checkBatchSingleSign(STObject const& batchSigner) const;
145
146 Expected<void, std::string>
147 checkBatchMultiSign(STObject const& batchSigner, Rules const& rules) const;
148
149 STBase*
150 copy(std::size_t n, void* buf) const override;
151 STBase*
152 move(std::size_t n, void* buf) override;
153
154 friend class detail::STVar;
156};
157
158bool
160
169sterilize(STTx const& stx);
170
172bool
173isPseudoTx(STObject const& tx);
174
175inline STTx::STTx(SerialIter&& sit) : STTx(sit)
176{
177}
178
179inline TxType
181{
182 return tx_type_;
183}
184
185inline Blob
187{
188 return getFieldVL(sfSigningPubKey);
189}
190
191inline uint256
193{
194 return tid_;
195}
196
197} // 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:624
std::string getFullText() const override
Definition STTx.cpp:130
Expected< void, std::string > checkBatchSingleSign(STObject const &batchSigner) const
Definition STTx.cpp:408
STBase * move(std::size_t n, void *buf) override
Definition STTx.cpp:117
Blob getSignature() const
Definition STTx.h:65
std::string getMetaSQL(std::uint32_t inLedger, std::string const &escapedMetaData) const
Definition STTx.cpp:348
TxType tx_type_
Definition STTx.h:30
Expected< void, std::string > checkMultiSign(Rules const &rules, STObject const &sigObject) const
Definition STTx.cpp:508
uint256 tid_
Definition STTx.h:29
STTx & operator=(STTx const &other)=delete
Expected< void, std::string > checkBatchSign(Rules const &rules) const
Definition STTx.cpp:269
Json::Value getJson(JsonOptions options) const override
Definition STTx.cpp:299
static std::string const & getMetaSQLInsertReplaceHeader()
Definition STTx.cpp:336
STTx(STTx const &other)=default
std::vector< uint256 > const & getBatchTransactionIDs() const
Retrieves a batch of transaction IDs from the STTx.
Definition STTx.cpp:545
Expected< void, std::string > checkBatchMultiSign(STObject const &batchSigner, Rules const &rules) const
Definition STTx.cpp:489
SeqProxy getSeqProxy() const
Definition STTx.cpp:193
STBase * copy(std::size_t n, void *buf) const override
Definition STTx.cpp:111
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:254
std::uint32_t getSeqValue() const
Returns the first non-zero value of (Sequence, TicketSequence).
Definition STTx.cpp:208
TxType getTxnType() const
Definition STTx.h:180
std::vector< uint256 > batchTxnIds_
Definition STTx.h:155
Expected< void, std::string > checkSingleSign(STObject const &sigObject) const
Definition STTx.cpp:401
Blob getSigningPubKey() const
Definition STTx.h:186
uint256 getSigningHash() const
Definition STTx.cpp:174
static constexpr std::size_t maxMultiSigners
Definition STTx.h:34
uint256 getTransactionID() const
Definition STTx.h:192
SerializedTypeID getSType() const override
Definition STTx.cpp:124
boost::container::flat_set< AccountID > getMentionedAccounts() const
Definition STTx.cpp:141
void sign(PublicKey const &publicKey, SecretKey const &secretKey, std::optional< std::reference_wrapper< SField const > > signatureTarget={})
Definition STTx.cpp:214
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:37
TxnSql
Definition STTx.h:18
@ txnSqlNew
Definition STTx.h:19
@ txnSqlValidated
Definition STTx.h:22
@ txnSqlUnknown
Definition STTx.h:24
@ txnSqlConflict
Definition STTx.h:20
@ txnSqlHeld
Definition STTx.h:21
@ txnSqlIncluded
Definition STTx.h:23
SerializedTypeID
Definition SField.h:90
bool passesLocalChecks(STObject const &st, std::string &)
Definition STTx.cpp:737
std::shared_ptr< STTx const > sterilize(STTx const &stx)
Sterilize a transaction.
Definition STTx.cpp:767
bool isPseudoTx(STObject const &tx)
Check whether a transaction is a pseudo-transaction.
Definition STTx.cpp:776
Note, should be treated as flags that can be | and &.
Definition STBase.h:17