20#include <xrpl/basics/Blob.h>
21#include <xrpl/basics/base_uint.h>
22#include <xrpl/basics/contract.h>
23#include <xrpl/beast/utility/instrumentation.h>
24#include <xrpl/protocol/AccountID.h>
25#include <xrpl/protocol/SField.h>
26#include <xrpl/protocol/STAccount.h>
27#include <xrpl/protocol/STAmount.h>
28#include <xrpl/protocol/STLedgerEntry.h>
29#include <xrpl/protocol/STObject.h>
30#include <xrpl/protocol/Serializer.h>
31#include <xrpl/protocol/TER.h>
32#include <xrpl/protocol/TxMeta.h>
34#include <boost/container/flat_set.hpp>
43 : transactionID_(txid)
45 , nodes_(obj.getFieldArray(sfAffectedNodes))
54 "ripple::TxMeta::TxMeta(STObject) : type cast succeeded");
62 : transactionID_(txid), ledgerSeq_(ledger), nodes_(sfAffectedNodes, 32)
77 , index_(
std::numeric_limits<
std::uint32_t>::max())
79 , nodes_(sfAffectedNodes)
93 if (n.getFieldH256(sfLedgerIndex) == node)
96 n.setFieldU16(sfLedgerEntryType, nodeType);
106 "ripple::TxMeta::setAffectedNode : field type match");
111boost::container::flat_set<AccountID>
114 boost::container::flat_set<AccountID> list;
119 for (
auto const& node :
nodes_)
121 int index = node.getFieldIndex(
122 (node.getFName() == sfCreatedNode) ? sfNewFields : sfFinalFields);
127 dynamic_cast<STObject const*
>(&node.peekAtIndex(index));
130 "ripple::getAffectedAccounts : STObject type cast succeeded");
133 for (
auto const& field : *inner)
135 if (
auto sa =
dynamic_cast<STAccount const*
>(&field))
139 "ripple::getAffectedAccounts : account is set");
140 if (!sa->isDefault())
141 list.insert(sa->value());
144 (field.getFName() == sfLowLimit) ||
145 (field.getFName() == sfHighLimit) ||
146 (field.getFName() == sfTakerPays) ||
147 (field.getFName() == sfTakerGets))
149 auto lim =
dynamic_cast<STAmount const*
>(&field);
152 "ripple::getAffectedAccounts : STAmount type cast "
157 auto issuer = lim->getIssuer();
159 if (issuer.isNonZero())
163 else if (field.getFName() == sfMPTokenIssuanceID)
167 if (mptID !=
nullptr)
171 if (issuer.isNonZero())
189 if (n.getFieldH256(sfLedgerIndex) == index)
197 "ripple::TxMeta::getAffectedNode(SLE::ref) : field type match");
199 obj.
setFieldU16(sfLedgerEntryType, node->getFieldU16(sfLedgerEntryType));
209 if (n.getFieldH256(sfLedgerIndex) == node)
213 UNREACHABLE(
"ripple::TxMeta::getAffectedNode(uint256) : node not found");
214 Throw<std::runtime_error>(
"Affected node not found");
222 STObject metaData(sfTransactionMetaData);
223 XRPL_ASSERT(
result_ != 255,
"ripple::TxMeta::getAsObject : result_ is set");
243 "ripple::TxMeta::addRaw : valid TER input");
AccountID const & getIssuer() const
void sort(bool(*compare)(STObject const &o1, STObject const &o2))
void reserve(std::size_t n)
void push_back(STObject const &object)
SField const & getFName() const
unsigned char getFieldU8(SField const &field) const
STArray const & getFieldArray(SField const &field) const
STBase const * peekAtPField(SField const &field) const
void setFieldH256(SField const &field, uint256 const &)
std::uint32_t getFieldU32(SField const &field) const
void setFieldU16(SField const &field, std::uint16_t)
void setFieldU8(SField const &field, unsigned char)
void add(Serializer &s) const override
void setFieldAmount(SField const &field, STAmount const &)
void setFieldU32(SField const &field, std::uint32_t)
std::size_t emplace_back(Args &&... args)
uint256 getFieldH256(SField const &field) const
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
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)
constexpr TERUnderlyingType TERtoInt(TELcodes v)
@ transactionID
transaction plus signature to give transaction ID