xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
libxrpl
tx
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
19
namespace
xrpl
{
20
21
std::expected<std::vector<SignerEntries::SignerEntry>,
NotTEC
>
22
SignerEntries::deserialize
(
STObject
const
& obj,
beast::Journal
journal,
std::string_view
annotation)
23
{
24
if
(!obj.
isFieldPresent
(sfSignerEntries))
25
{
26
JLOG(journal.
trace
()) <<
"Malformed "
<< annotation <<
": Need signer entry array."
;
27
return
std::unexpected
(
temMALFORMED
);
28
}
29
30
std::vector<SignerEntry>
accountVec;
31
accountVec.
reserve
(
STTx::kMaxMultiSigners
);
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."
;
40
return
std::unexpected
(
temMALFORMED
);
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
std::string_view
beast::Journal
A generic endpoint for log messages.
Definition
Journal.h:44
beast::Journal::trace
Stream trace() const
Severity stream access functions.
Definition
Journal.h:338
xrpl::STArray
Definition
STArray.h:20
xrpl::STObject
Definition
STObject.h:49
xrpl::STObject::getFieldArray
STArray const & getFieldArray(SField const &field) const
Definition
STObject.cpp:688
xrpl::STObject::isFieldPresent
bool isFieldPresent(SField const &field) const
Definition
STObject.cpp:464
xrpl::STTx::kMaxMultiSigners
static constexpr std::size_t kMaxMultiSigners
Definition
STTx.h:49
xrpl::SignerEntries::deserialize
static std::expected< std::vector< SignerEntry >, NotTEC > deserialize(STObject const &obj, beast::Journal journal, std::string_view annotation)
Definition
SignerEntries.cpp:22
cstdint
std::vector::emplace_back
T emplace_back(T... args)
std::uint16_t
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::NotTEC
TERSubset< CanCvtToNotTEC > NotTEC
Definition
TER.h:614
xrpl::AccountID
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition
AccountID.h:34
xrpl::temMALFORMED
@ temMALFORMED
Definition
TER.h:75
optional
std::vector::reserve
T reserve(T... args)
string_view
std::unexpected
T unexpected(T... args)
vector
Generated by
1.17.0