1#include <xrpl/protocol/TxMeta.h>
3#include <xrpl/basics/Blob.h>
4#include <xrpl/basics/Slice.h>
5#include <xrpl/basics/base_uint.h>
6#include <xrpl/basics/contract.h>
7#include <xrpl/beast/utility/instrumentation.h>
8#include <xrpl/protocol/AccountID.h>
9#include <xrpl/protocol/SField.h>
10#include <xrpl/protocol/STAccount.h>
11#include <xrpl/protocol/STAmount.h>
12#include <xrpl/protocol/STLedgerEntry.h>
13#include <xrpl/protocol/STObject.h>
14#include <xrpl/protocol/Serializer.h>
15#include <xrpl/protocol/TER.h>
17#include <boost/container/flat_set.hpp>
32 XRPL_ASSERT(affectedNodes,
"xrpl::TxMeta::TxMeta(STObject) : type cast succeeded");
33 if (affectedNodes !=
nullptr)
68 if (n.getFieldH256(sfLedgerIndex) == node)
71 n.setFieldU16(sfLedgerEntryType, nodeType);
79 XRPL_ASSERT(obj.
getFName() == type,
"xrpl::TxMeta::setAffectedNode : field type match");
84boost::container::flat_set<AccountID>
87 boost::container::flat_set<AccountID> list;
92 for (
auto const& node :
nodes_)
95 node.getFieldIndex((node.getFName() == sfCreatedNode) ? sfNewFields : sfFinalFields);
99 auto const* inner =
dynamic_cast<STObject const*
>(&node.peekAtIndex(index));
100 XRPL_ASSERT(inner,
"xrpl::getAffectedAccounts : STObject type cast succeeded");
101 if (inner !=
nullptr)
103 for (
auto const& field : *inner)
105 if (
auto sa =
dynamic_cast<STAccount const*
>(&field))
107 XRPL_ASSERT(!sa->isDefault(),
"xrpl::getAffectedAccounts : account is set");
108 if (!sa->isDefault())
109 list.insert(sa->value());
112 (field.getFName() == sfLowLimit) || (field.getFName() == sfHighLimit) ||
113 (field.getFName() == sfTakerPays) || (field.getFName() == sfTakerGets))
115 auto lim =
dynamic_cast<STAmount const*
>(&field);
118 "xrpl::getAffectedAccounts : STAmount type cast "
123 auto issuer = lim->getIssuer();
125 if (issuer.isNonZero())
129 else if (field.getFName() == sfMPTokenIssuanceID)
132 if (mptID !=
nullptr)
136 if (issuer.isNonZero())
151 uint256 const index = node->key();
154 if (n.getFieldH256(sfLedgerIndex) == index)
161 obj.
getFName() == type,
"xrpl::TxMeta::getAffectedNode(SLE::ref) : field type match");
163 obj.
setFieldU16(sfLedgerEntryType, node->getFieldU16(sfLedgerEntryType));
173 if (n.getFieldH256(sfLedgerIndex) == node)
177 UNREACHABLE(
"xrpl::TxMeta::getAffectedNode(uint256) : node not found");
186 STObject metaData(sfTransactionMetaData);
187 XRPL_ASSERT(
result_ != 255,
"xrpl::TxMeta::getAsObject : result_ is set");
207 "xrpl::TxMeta::addRaw : valid TER input");
AccountID const & getIssuer() const
SField const & getFName() const
std::shared_ptr< STLedgerEntry > const & ref
void setFieldU8(SField const &field, unsigned char)
unsigned char getFieldU8(SField const &field) const
std::uint32_t getFieldU32(SField const &field) const
void setFieldU32(SField const &field, std::uint32_t)
std::size_t emplaceBack(Args &&... args)
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.
constexpr TERUnderlyingType TERtoInt(TELcodes v)
TERSubset< CanCvtToTER > TER
std::vector< unsigned char > Blob
Storage for linear binary data.
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
std::enable_if_t< std::is_same_v< T, char >||std::is_same_v< T, unsigned char >, Slice > makeSlice(std::array< T, N > const &a)