1#include <xrpl/basics/Blob.h>
2#include <xrpl/basics/base_uint.h>
3#include <xrpl/basics/contract.h>
4#include <xrpl/beast/utility/instrumentation.h>
5#include <xrpl/protocol/AccountID.h>
6#include <xrpl/protocol/SField.h>
7#include <xrpl/protocol/STAccount.h>
8#include <xrpl/protocol/STAmount.h>
9#include <xrpl/protocol/STLedgerEntry.h>
10#include <xrpl/protocol/STObject.h>
11#include <xrpl/protocol/Serializer.h>
12#include <xrpl/protocol/TER.h>
13#include <xrpl/protocol/TxMeta.h>
15#include <boost/container/flat_set.hpp>
24 : transactionID_(txid)
26 , nodes_(obj.getFieldArray(sfAffectedNodes))
34 affectedNodes,
"xrpl::TxMeta::TxMeta(STObject) : type cast succeeded");
42 : transactionID_(txid), ledgerSeq_(ledger), nodes_(sfAffectedNodes, 32)
57 , index_(
std::numeric_limits<
std::uint32_t>::max())
59 , nodes_(sfAffectedNodes)
73 if (n.getFieldH256(sfLedgerIndex) == node)
76 n.setFieldU16(sfLedgerEntryType, nodeType);
86 "xrpl::TxMeta::setAffectedNode : field type match");
91boost::container::flat_set<AccountID>
94 boost::container::flat_set<AccountID> list;
99 for (
auto const& node :
nodes_)
101 int index = node.getFieldIndex(
102 (node.getFName() == sfCreatedNode) ? sfNewFields : sfFinalFields);
107 dynamic_cast<STObject const*
>(&node.peekAtIndex(index));
110 "xrpl::getAffectedAccounts : STObject type cast succeeded");
113 for (
auto const& field : *inner)
115 if (
auto sa =
dynamic_cast<STAccount const*
>(&field))
119 "xrpl::getAffectedAccounts : account is set");
120 if (!sa->isDefault())
121 list.insert(sa->value());
124 (field.getFName() == sfLowLimit) ||
125 (field.getFName() == sfHighLimit) ||
126 (field.getFName() == sfTakerPays) ||
127 (field.getFName() == sfTakerGets))
129 auto lim =
dynamic_cast<STAmount const*
>(&field);
132 "xrpl::getAffectedAccounts : STAmount type cast "
137 auto issuer = lim->getIssuer();
139 if (issuer.isNonZero())
143 else if (field.getFName() == sfMPTokenIssuanceID)
147 if (mptID !=
nullptr)
151 if (issuer.isNonZero())
169 if (n.getFieldH256(sfLedgerIndex) == index)
177 "xrpl::TxMeta::getAffectedNode(SLE::ref) : field type match");
179 obj.
setFieldU16(sfLedgerEntryType, node->getFieldU16(sfLedgerEntryType));
189 if (n.getFieldH256(sfLedgerIndex) == node)
193 UNREACHABLE(
"xrpl::TxMeta::getAffectedNode(uint256) : node not found");
194 Throw<std::runtime_error>(
"Affected node not found");
202 STObject metaData(sfTransactionMetaData);
203 XRPL_ASSERT(
result_ != 255,
"xrpl::TxMeta::getAsObject : result_ is set");
223 "xrpl::TxMeta::addRaw : valid TER input");
AccountID const & getIssuer() const
void push_back(STObject const &object)
void reserve(std::size_t n)
void sort(bool(*compare)(STObject const &o1, STObject const &o2))
SField const & getFName() const
void setFieldU8(SField const &field, unsigned char)
unsigned char getFieldU8(SField const &field) const
std::uint32_t getFieldU32(SField const &field) const
std::size_t emplace_back(Args &&... args)
void setFieldU32(SField const &field, std::uint32_t)
STArray const & getFieldArray(SField const &field) const
void setFieldAmount(SField const &field, STAmount const &)
void add(Serializer &s) const override
void setFieldU16(SField const &field, std::uint16_t)
uint256 getFieldH256(SField const &field) const
STBase const * peekAtPField(SField const &field) const
void setFieldH256(SField const &field, uint256 const &)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
@ transactionID
transaction plus signature to give transaction ID
constexpr TERUnderlyingType TERtoInt(TELcodes v)
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)