rippled
Loading...
Searching...
No Matches
AccountID.h
1#pragma once
2
3#include <xrpl/protocol/tokens.h>
4// VFALCO Uncomment when the header issues are resolved
5// #include <ripple/protocol/PublicKey.h>
6#include <xrpl/basics/UnorderedContainers.h>
7#include <xrpl/basics/base_uint.h>
8#include <xrpl/json/json_value.h>
9#include <xrpl/protocol/json_get_or_throw.h>
10
11#include <cstddef>
12#include <optional>
13#include <string>
14
15namespace xrpl {
16
17namespace detail {
18
20{
21public:
22 explicit AccountIDTag() = default;
23};
24
25} // namespace detail
26
29
32toBase58(AccountID const& v);
33
37template <>
39parseBase58(std::string const& s);
40
48// VFALCO In PublicKey.h for now
49// AccountID
50// calcAccountID (PublicKey const& pk);
51
53AccountID const&
55
57AccountID const&
58noAccount();
59
64// DEPRECATED
65bool
67
68// DEPRECATED Should be checking the currency or native flag
69inline bool
71{
72 return c == beast::zero;
73}
74
75// DEPRECATED
76inline std::string
77to_string(AccountID const& account)
78{
79 return toBase58(account);
80}
81
82// DEPRECATED
85{
86 os << to_string(x);
87 return os;
88}
89
102void
104
105} // namespace xrpl
106
107//------------------------------------------------------------------------------
108namespace Json {
109template <>
110inline xrpl::AccountID
111getOrThrow(Json::Value const& v, xrpl::SField const& field)
112{
113 using namespace xrpl;
114
115 std::string const b58 = getOrThrow<std::string>(v, field);
116 if (auto const r = parseBase58<AccountID>(b58))
117 return *r;
118 Throw<JsonTypeMismatchError>(field.getJsonName(), "AccountID");
119}
120} // namespace Json
121
122//------------------------------------------------------------------------------
123
124namespace std {
125
126// DEPRECATED
127// VFALCO Use beast::uhash or a hardened container
128template <>
130{
131 hash() = default;
132};
133
134} // namespace std
Represents a JSON value.
Definition json_value.h:130
Identifies fields.
Definition SField.h:126
Seed functor once per construction.
JSON (JavaScript Object Notation).
Definition json_errors.h:5
xrpl::AccountID getOrThrow(Json::Value const &v, xrpl::SField const &field)
Definition AccountID.h:111
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
bool isXRP(AccountID const &c)
Definition AccountID.h:70
std::optional< AccountID > parseBase58(std::string const &s)
Parse AccountID from checked, base58 string.
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:597
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition AccountID.cpp:92
std::ostream & operator<<(std::ostream &out, base_uint< Bits, Tag > const &u)
Definition base_uint.h:612
void initAccountIdCache(std::size_t count)
Initialize the global cache used to map AccountID to base58 conversions.
Definition AccountID.cpp:85
bool to_issuer(AccountID &, std::string const &)
Convert hex or base58 string to AccountID.
AccountID const & noAccount()
A placeholder for empty accounts.
AccountID const & xrpAccount()
Compute AccountID from public key.