rippled
Loading...
Searching...
No Matches
SignerEntries.cpp
1#include <xrpld/app/tx/detail/SignerEntries.h>
2
3#include <xrpl/basics/Log.h>
4#include <xrpl/protocol/STArray.h>
5#include <xrpl/protocol/STObject.h>
6
7#include <cstdint>
8#include <optional>
9
10namespace ripple {
11
12Expected<std::vector<SignerEntries::SignerEntry>, NotTEC>
14 STObject const& obj,
15 beast::Journal journal,
16 std::string_view annotation)
17{
19
20 if (!obj.isFieldPresent(sfSignerEntries))
21 {
22 JLOG(journal.trace())
23 << "Malformed " << annotation << ": Need signer entry array.";
25 }
26
27 std::vector<SignerEntry> accountVec;
28 accountVec.reserve(STTx::maxMultiSigners());
29
30 STArray const& sEntries(obj.getFieldArray(sfSignerEntries));
31 for (STObject const& sEntry : sEntries)
32 {
33 // Validate the SignerEntry.
34 if (sEntry.getFName() != sfSignerEntry)
35 {
36 JLOG(journal.trace())
37 << "Malformed " << annotation << ": Expected SignerEntry.";
39 }
40
41 // Extract SignerEntry fields.
42 AccountID const account = sEntry.getAccountID(sfAccount);
43 std::uint16_t const weight = sEntry.getFieldU16(sfSignerWeight);
44 std::optional<uint256> const tag = sEntry.at(~sfWalletLocator);
45
46 accountVec.emplace_back(account, weight, tag);
47 }
48 return accountVec;
49}
50
51} // namespace ripple
A generic endpoint for log messages.
Definition Journal.h:41
Stream trace() const
Severity stream access functions.
Definition Journal.h:303
STArray const & getFieldArray(SField const &field) const
Definition STObject.cpp:683
bool isFieldPresent(SField const &field) const
Definition STObject.cpp:465
static std::size_t maxMultiSigners(Rules const *rules=0)
Definition STTx.h:38
static 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:6
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:590
@ temMALFORMED
Definition TER.h:68
T reserve(T... args)