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>
48 : mTransactionID(txid), mLedger(ledger), mNodes(sfAffectedNodes, 32)
65 : mTransactionID(txid)
67 , mNodes(obj.getFieldArray(sfAffectedNodes))
76 "ripple::TxMeta::TxMeta(STObject) : type cast succeeded");
106 , mIndex(static_cast<
std::uint32_t>(-1))
108 , mParentBatchId(parentBatchId)
109 , mNodes(sfAffectedNodes)
123 if (n.getFieldH256(sfLedgerIndex) == node)
126 n.setFieldU16(sfLedgerEntryType, nodeType);
136 "ripple::TxMeta::setAffectedNode : field type match");
141boost::container::flat_set<AccountID>
144 boost::container::flat_set<AccountID> list;
149 for (
auto const& it :
mNodes)
151 int index = it.getFieldIndex(
152 (it.getFName() == sfCreatedNode) ? sfNewFields : sfFinalFields);
156 auto inner =
dynamic_cast<STObject const*
>(&it.peekAtIndex(index));
159 "ripple::getAffectedAccounts : STObject type cast succeeded");
162 for (
auto const& field : *inner)
164 if (
auto sa =
dynamic_cast<STAccount const*
>(&field))
168 "ripple::getAffectedAccounts : account is set");
169 if (!sa->isDefault())
170 list.insert(sa->value());
173 (field.getFName() == sfLowLimit) ||
174 (field.getFName() == sfHighLimit) ||
175 (field.getFName() == sfTakerPays) ||
176 (field.getFName() == sfTakerGets))
178 auto lim =
dynamic_cast<STAmount const*
>(&field);
181 "ripple::getAffectedAccounts : STAmount type cast "
186 auto issuer = lim->getIssuer();
188 if (issuer.isNonZero())
192 else if (field.getFName() == sfMPTokenIssuanceID)
196 if (mptID !=
nullptr)
200 if (issuer.isNonZero())
218 if (n.getFieldH256(sfLedgerIndex) == index)
226 "ripple::TxMeta::getAffectedNode(SLE::ref) : field type match");
228 obj.
setFieldU16(sfLedgerEntryType, node->getFieldU16(sfLedgerEntryType));
238 if (n.getFieldH256(sfLedgerIndex) == node)
241 UNREACHABLE(
"ripple::TxMeta::getAffectedNode(uint256) : node not found");
242 Throw<std::runtime_error>(
"Affected node not found");
249 STObject metaData(sfTransactionMetaData);
250 XRPL_ASSERT(
mResult != 255,
"ripple::TxMeta::getAsObject : result is set");
270 "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
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 &)
STBase & getField(SField const &field)
STAmount const & getFieldAmount(SField const &field) const
bool isFieldPresent(SField const &field) 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