xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
protocol
AccountID.h
1
#pragma once
2
3
#include <xrpl/protocol/tokens.h>
4
// VFALCO Uncomment when the header issues are resolved
5
// #include <xrpl/protocol/PublicKey.h>
6
#include <xrpl/basics/base_uint.h>
7
#include <xrpl/basics/contract.h>
8
#include <xrpl/beast/utility/Zero.h>
9
#include <xrpl/json/json_value.h>
10
#include <xrpl/protocol/SField.h>
11
#include <xrpl/protocol/json_get_or_throw.h>
12
13
#include <
cstddef
>
14
#include <
functional
>
15
#include <
optional
>
16
#include <
ostream
>
17
#include <
string
>
18
19
namespace
xrpl
{
20
21
namespace
detail
{
22
23
class
AccountIDTag
24
{
25
public
:
26
explicit
AccountIDTag
() =
default
;
27
};
28
29
}
// namespace detail
30
34
using
AccountID
=
BaseUInt<160, detail::AccountIDTag>
;
35
39
std::string
40
toBase58
(
AccountID
const
& v);
41
46
template
<>
47
std::optional<AccountID>
48
parseBase58
(
std::string
const
& s);
49
57
// VFALCO In PublicKey.h for now
58
// AccountID
59
// calcAccountID (PublicKey const& pk);
60
64
AccountID
const
&
65
xrpAccount
();
66
70
AccountID
const
&
71
noAccount
();
72
78
// DEPRECATED
79
bool
80
toIssuer
(
AccountID
&,
std::string
const
&);
81
82
// DEPRECATED Should be checking the currency or native flag
83
inline
bool
84
isXRP
(
AccountID
const
& c)
85
{
86
return
c ==
beast::kZero
;
87
}
88
89
// DEPRECATED
90
inline
std::string
91
to_string
(
AccountID
const
& account)
92
{
93
return
toBase58
(account);
94
}
95
96
// DEPRECATED
97
inline
std::ostream
&
98
operator<<
(
std::ostream
& os,
AccountID
const
& x)
99
{
100
os <<
to_string
(x);
101
return
os;
102
}
103
117
void
118
initAccountIdCache
(
std::size_t
count);
119
120
}
// namespace xrpl
121
122
//------------------------------------------------------------------------------
123
namespace
json
{
124
template
<>
125
inline
xrpl::AccountID
126
getOrThrow
(
json::Value
const
& v,
xrpl::SField
const
& field)
127
{
128
using namespace
xrpl
;
129
130
std::string
const
b58 =
getOrThrow<std::string>
(v, field);
131
if
(
auto
const
r =
parseBase58<AccountID>
(b58))
132
return
*r;
133
Throw<JsonTypeMismatchError>
(field.
getJsonName
(),
"AccountID"
);
134
}
135
}
// namespace json
136
137
//------------------------------------------------------------------------------
138
139
namespace
std
{
140
141
// DEPRECATED
142
// VFALCO Use beast::uhash or a hardened container
143
template
<>
144
struct
hash
<
xrpl
::
AccountID
> :
xrpl::AccountID::hasher
145
{
146
hash
() =
default
;
147
};
148
149
}
// namespace std
std::ostream
std::string
json::Value
Represents a JSON value.
Definition
json_value.h:117
xrpl::BaseUInt
Integers of any length that is a multiple of 32-bits.
Definition
base_uint.h:82
xrpl::BaseUInt< 160, detail::AccountIDTag >::hasher
HardenedHash<> hasher
Definition
base_uint.h:163
xrpl::SField
Identifies fields.
Definition
SField.h:132
xrpl::SField::getJsonName
json::StaticString const & getJsonName() const
Definition
SField.h:210
xrpl::detail::AccountIDTag::AccountIDTag
AccountIDTag()=default
cstddef
functional
beast::kZero
constexpr Zero kZero
Definition
Zero.h:30
json
JSON (JavaScript Object Notation).
Definition
json_errors.h:5
json::getOrThrow
xrpl::AccountID getOrThrow(json::Value const &v, xrpl::SField const &field)
Definition
AccountID.h:126
std
STL namespace.
xrpl::detail
Definition
base_uint.h:37
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::isXRP
bool isXRP(AccountID const &c)
Definition
AccountID.h:84
xrpl::parseBase58
std::optional< AccountID > parseBase58(std::string const &s)
Parse AccountID from checked, base58 string.
Definition
AccountID.cpp:105
xrpl::toBase58
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition
AccountID.cpp:95
xrpl::operator<<
std::ostream & operator<<(std::ostream &out, BaseUInt< Bits, Tag > const &u)
Definition
base_uint.h:672
xrpl::to_string
std::string to_string(BaseUInt< Bits, Tag > const &a)
Definition
base_uint.h:657
xrpl::initAccountIdCache
void initAccountIdCache(std::size_t count)
Initialize the global cache used to map AccountID to base58 conversions.
Definition
AccountID.cpp:88
xrpl::AccountID
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition
AccountID.h:34
xrpl::noAccount
AccountID const & noAccount()
A placeholder for empty accounts.
Definition
AccountID.cpp:166
xrpl::xrpAccount
AccountID const & xrpAccount()
Compute AccountID from public key.
Definition
AccountID.cpp:159
xrpl::toIssuer
bool toIssuer(AccountID &, std::string const &)
Convert hex or base58 string to AccountID.
Definition
AccountID.cpp:173
xrpl::Throw
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
Definition
contract.h:52
optional
ostream
std::size_t
string
std::hash< xrpl::AccountID >::hash
hash()=default
Generated by
1.17.0