xrpld
Loading...
Searching...
No Matches
TxMeta.h
1#pragma once
2
3#include <xrpl/basics/Blob.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/json/json_value.h>
6#include <xrpl/protocol/AccountID.h>
7#include <xrpl/protocol/SField.h>
8#include <xrpl/protocol/STAmount.h>
9#include <xrpl/protocol/STArray.h>
10#include <xrpl/protocol/STBase.h>
11#include <xrpl/protocol/STLedgerEntry.h>
12#include <xrpl/protocol/STObject.h>
13#include <xrpl/protocol/Serializer.h>
14#include <xrpl/protocol/TER.h>
15#include <xrpl/protocol/UintTypes.h>
16
17#include <boost/container/flat_set.hpp>
18
19#include <cstdint>
20#include <flat_set>
21#include <optional>
22
23namespace xrpl {
24
25class TxMeta
26{
27public:
28 TxMeta(UInt256 const& transactionID, std::uint32_t ledger);
29 TxMeta(UInt256 const& txID, std::uint32_t ledger, Blob const&);
30 TxMeta(UInt256 const& txID, std::uint32_t ledger, STObject const&);
31
32 [[nodiscard]] UInt256 const&
33 getTxID() const
34 {
35 return transactionID_;
36 }
37 [[nodiscard]] std::uint32_t
38 getLgrSeq() const
39 {
40 return ledgerSeq_;
41 }
42 [[nodiscard]] int
43 getResult() const
44 {
45 return result_;
46 }
47 [[nodiscard]] TER
49 {
50 return TER::fromInt(result_);
51 }
52 [[nodiscard]] std::uint32_t
53 getIndex() const
54 {
55 return index_;
56 }
57
58 void
59 setAffectedNode(UInt256 const&, SField const& type, std::uint16_t nodeType);
61 getAffectedNode(SLE::Ref node, SField const& type); // create if needed
64
68 [[nodiscard]] boost::container::flat_set<AccountID>
69 getAffectedAccounts() const;
70
71 [[nodiscard]] json::Value
73 {
74 return getAsObject().getJson(p);
75 }
76 void
78
79 [[nodiscard]] STObject
80 getAsObject() const;
81 STArray&
83 {
84 return nodes_;
85 }
86 [[nodiscard]] STArray const&
87 getNodes() const
88 {
89 return nodes_;
90 }
91
92 void
94 {
95 if (obj.isFieldPresent(sfDeliveredAmount))
96 deliveredAmount_ = obj.getFieldAmount(sfDeliveredAmount);
97
98 if (obj.isFieldPresent(sfParentBatchID))
99 parentBatchID_ = obj.getFieldH256(sfParentBatchID);
100 }
101
102 [[nodiscard]] std::optional<STAmount> const&
104 {
105 return deliveredAmount_;
106 }
107
108 void
110 {
111 deliveredAmount_ = amount;
112 }
113
114 void
119
120 [[nodiscard]] std::flat_set<MPTID>
121 getAffectedMPTs() const;
122
123private:
128
131
133};
134
135} // namespace xrpl
Represents a JSON value.
Definition json_value.h:117
Identifies fields.
Definition SField.h:132
std::shared_ptr< STLedgerEntry > const & Ref
UInt256 getFieldH256(SField const &field) const
Definition STObject.cpp:631
json::Value getJson(JsonOptions=JsonOptions::Values::None) const override
Definition STObject.cpp:845
bool isFieldPresent(SField const &field) const
Definition STObject.cpp:464
STAmount const & getFieldAmount(SField const &field) const
Definition STObject.cpp:657
static constexpr TERSubset fromInt(int from)
Definition TER.h:444
boost::container::flat_set< AccountID > getAffectedAccounts() const
Return a list of accounts affected by this transaction.
Definition TxMeta.cpp:89
UInt256 const & getTxID() const
Definition TxMeta.h:33
void setDeliveredAmount(std::optional< STAmount > const &amount)
Definition TxMeta.h:109
TER getResultTER() const
Definition TxMeta.h:48
STArray const & getNodes() const
Definition TxMeta.h:87
TxMeta(UInt256 const &transactionID, std::uint32_t ledger)
Definition TxMeta.cpp:56
json::Value getJson(JsonOptions p) const
Definition TxMeta.h:72
UInt256 transactionID_
Definition TxMeta.h:124
std::uint32_t getIndex() const
Definition TxMeta.h:53
void setAdditionalFields(STObject const &obj)
Definition TxMeta.h:93
STObject & getAffectedNode(SLE::Ref node, SField const &type)
Definition TxMeta.cpp:199
std::optional< STAmount > deliveredAmount_
Definition TxMeta.h:129
std::optional< STAmount > const & getDeliveredAmount() const
Definition TxMeta.h:103
STArray nodes_
Definition TxMeta.h:132
int result_
Definition TxMeta.h:127
std::uint32_t getLgrSeq() const
Definition TxMeta.h:38
std::flat_set< MPTID > getAffectedMPTs() const
Definition TxMeta.cpp:153
void addRaw(Serializer &, TER, std::uint32_t index)
Definition TxMeta.cpp:251
std::optional< UInt256 > parentBatchID_
Definition TxMeta.h:130
STObject getAsObject() const
Definition TxMeta.cpp:234
STArray & getNodes()
Definition TxMeta.h:82
void setAffectedNode(UInt256 const &, SField const &type, std::uint16_t nodeType)
Definition TxMeta.cpp:67
std::uint32_t index_
Definition TxMeta.h:126
std::uint32_t ledgerSeq_
Definition TxMeta.h:125
void setParentBatchID(std::optional< UInt256 > const &id)
Definition TxMeta.h:115
int getResult() const
Definition TxMeta.h:43
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
BaseUInt< 256 > UInt256
Definition base_uint.h:580
TERSubset< CanCvtToTER > TER
Definition TER.h:654
std::vector< unsigned char > Blob
Storage for linear binary data.
Definition Blob.h:11
Note, should be treated as flags that can be | and &.
Definition STBase.h:22