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))
35 "ripple::TxMeta::TxMeta(STObject) : type cast succeeded");
43 : transactionID_(txid), ledgerSeq_(ledger), nodes_(sfAffectedNodes, 32)
58 , index_(
std::numeric_limits<
std::uint32_t>::max())
60 , nodes_(sfAffectedNodes)
74 if (n.getFieldH256(sfLedgerIndex) == node)
77 n.setFieldU16(sfLedgerEntryType, nodeType);
87 "ripple::TxMeta::setAffectedNode : field type match");
92boost::container::flat_set<AccountID>
95 boost::container::flat_set<AccountID> list;
100 for (
auto const& node :
nodes_)
102 int index = node.getFieldIndex(
103 (node.getFName() == sfCreatedNode) ? sfNewFields : sfFinalFields);
108 dynamic_cast<STObject const*
>(&node.peekAtIndex(index));
111 "ripple::getAffectedAccounts : STObject type cast succeeded");
114 for (
auto const& field : *inner)
116 if (
auto sa =
dynamic_cast<STAccount const*
>(&field))
120 "ripple::getAffectedAccounts : account is set");
121 if (!sa->isDefault())
122 list.insert(sa->value());
125 (field.getFName() == sfLowLimit) ||
126 (field.getFName() == sfHighLimit) ||
127 (field.getFName() == sfTakerPays) ||
128 (field.getFName() == sfTakerGets))
130 auto lim =
dynamic_cast<STAmount const*
>(&field);
133 "ripple::getAffectedAccounts : STAmount type cast "
138 auto issuer = lim->getIssuer();
140 if (issuer.isNonZero())
144 else if (field.getFName() == sfMPTokenIssuanceID)
148 if (mptID !=
nullptr)
152 if (issuer.isNonZero())
170 if (n.getFieldH256(sfLedgerIndex) == index)
178 "ripple::TxMeta::getAffectedNode(SLE::ref) : field type match");
180 obj.
setFieldU16(sfLedgerEntryType, node->getFieldU16(sfLedgerEntryType));
190 if (n.getFieldH256(sfLedgerIndex) == node)
194 UNREACHABLE(
"ripple::TxMeta::getAffectedNode(uint256) : node not found");
195 Throw<std::runtime_error>(
"Affected node not found");
203 STObject metaData(sfTransactionMetaData);
204 XRPL_ASSERT(
result_ != 255,
"ripple::TxMeta::getAsObject : result_ is set");
224 "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