xrpld
Loading...
Searching...
No Matches
SignerEntries.h
1#pragma once
2
3#include <xrpl/basics/base_uint.h>
4#include <xrpl/beast/utility/Journal.h> // beast::Journal
5#include <xrpl/protocol/AccountID.h>
6#include <xrpl/protocol/TER.h> // temMALFORMED
7
8#include <cstdint>
9#include <expected>
10#include <optional>
11#include <string_view>
12#include <vector>
13
14namespace xrpl {
15
16// Forward declarations
17class STObject;
18
19// Support for SignerEntries that is needed by a few Transactors.
20//
21// SignerEntries is represented as a std::vector<SignerEntries::SignerEntry>.
22// There is no direct constructor for SignerEntries.
23//
24// o A std::vector<SignerEntries::SignerEntry> is a SignerEntries.
25// o More commonly, SignerEntries are extracted from an STObject by
26// calling SignerEntries::deserialize().
28{
29public:
30 explicit SignerEntries() = delete;
31
33 {
37
39 AccountID const& inAccount,
40 std::uint16_t inWeight,
42 : account(inAccount), weight(inWeight), tag(inTag)
43 {
44 }
45
46 // For sorting to look for duplicate accounts
47 friend auto
48 operator<=>(SignerEntry const& lhs, SignerEntry const& rhs)
49 {
50 return lhs.account <=> rhs.account;
51 }
52
53 friend bool
54 operator==(SignerEntry const& lhs, SignerEntry const& rhs)
55 {
56 return lhs.account == rhs.account;
57 }
58 };
59
60 // Deserialize a SignerEntries array from the network or from the ledger.
61 //
62 // obj Contains a SignerEntries field that is an STArray.
63 // journal For reporting error conditions.
64 // annotation Source of SignerEntries, like "ledger" or "transaction".
65 static std::expected<std::vector<SignerEntry>, NotTEC>
66 deserialize(STObject const& obj, beast::Journal journal, std::string_view annotation);
67};
68
69} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:44
static std::expected< std::vector< SignerEntry >, NotTEC > deserialize(STObject const &obj, beast::Journal journal, std::string_view annotation)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:607
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:34
SignerEntry(AccountID const &inAccount, std::uint16_t inWeight, std::optional< uint256 > inTag)
friend bool operator==(SignerEntry const &lhs, SignerEntry const &rhs)
std::optional< uint256 > tag
friend auto operator<=>(SignerEntry const &lhs, SignerEntry const &rhs)