xrpld
Loading...
Searching...
No Matches
SignerEntries.cpp
1#include <xrpl/tx/SignerEntries.h>
2
3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/protocol/AccountID.h>
7#include <xrpl/protocol/SField.h>
8#include <xrpl/protocol/STArray.h>
9#include <xrpl/protocol/STObject.h>
10#include <xrpl/protocol/STTx.h>
11#include <xrpl/protocol/TER.h>
12
13#include <cstdint>
14#include <expected>
15#include <optional>
16#include <string_view>
17#include <vector>
18
19namespace xrpl {
20
21std::expected<std::vector<SignerEntries::SignerEntry>, NotTEC>
23{
24 if (!obj.isFieldPresent(sfSignerEntries))
25 {
26 JLOG(journal.trace()) << "Malformed " << annotation << ": Need signer entry array.";
28 }
29
30 std::vector<SignerEntry> accountVec;
32
33 STArray const& sEntries(obj.getFieldArray(sfSignerEntries));
34 for (STObject const& sEntry : sEntries)
35 {
36 // Validate the SignerEntry.
37 if (sEntry.getFName() != sfSignerEntry)
38 {
39 JLOG(journal.trace()) << "Malformed " << annotation << ": Expected SignerEntry.";
41 }
42
43 // Extract SignerEntry fields.
44 AccountID const account = sEntry.getAccountID(sfAccount);
45 std::uint16_t const weight = sEntry.getFieldU16(sfSignerWeight);
46 std::optional<uint256> const tag = sEntry.at(~sfWalletLocator);
47
48 accountVec.emplace_back(account, weight, tag);
49 }
50 return accountVec;
51}
52
53} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:38
Stream trace() const
Severity stream access functions.
Definition Journal.h:291
STArray const & getFieldArray(SField const &field) const
Definition STObject.cpp:678
bool isFieldPresent(SField const &field) const
Definition STObject.cpp:454
static constexpr std::size_t kMaxMultiSigners
Definition STTx.h:34
static std::expected< std::vector< SignerEntry >, NotTEC > deserialize(STObject const &obj, beast::Journal journal, std::string_view annotation)
T emplace_back(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:594
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
@ temMALFORMED
Definition TER.h:73
T reserve(T... args)
T unexpected(T... args)