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