rippled
Loading...
Searching...
No Matches
tokens.h
1#ifndef XRPL_PROTOCOL_TOKENS_H_INCLUDED
2#define XRPL_PROTOCOL_TOKENS_H_INCLUDED
3
4#include <xrpl/basics/Expected.h>
5#include <xrpl/basics/contract.h>
6#include <xrpl/protocol/detail/token_errors.h>
7
8#include <cstdint>
9#include <optional>
10#include <span>
11#include <string>
12#include <string_view>
13
14namespace ripple {
15
16template <class T>
18
19enum class TokenType : std::uint8_t {
20 None = 1, // unused
21 NodePublic = 28,
22 NodePrivate = 32,
23 AccountID = 0,
24 AccountPublic = 35,
25 AccountSecret = 34,
26 FamilyGenerator = 41, // unused
27 FamilySeed = 33
28};
29
30template <class T>
31[[nodiscard]] std::optional<T>
33
34template <class T>
35[[nodiscard]] std::optional<T>
37
49[[nodiscard]] std::string
50encodeBase58Token(TokenType type, void const* token, std::size_t size);
51
52[[nodiscard]] std::string
54
55namespace b58_ref {
56// The reference version does not use gcc extensions (int128 in particular)
57[[nodiscard]] std::string
58encodeBase58Token(TokenType type, void const* token, std::size_t size);
59
60[[nodiscard]] std::string
62
63namespace detail {
64// Expose detail functions for unit tests only
67 void const* message,
68 std::size_t size,
69 void* temp,
70 std::size_t temp_size);
71
74} // namespace detail
75} // namespace b58_ref
76
77#ifndef _MSC_VER
78namespace b58_fast {
79// Use the fast version (10-15x faster) is using gcc extensions (int128 in
80// particular)
83 TokenType token_type,
86
89 TokenType type,
92
93// This interface matches the old interface, but requires additional allocation
94[[nodiscard]] std::string
95encodeBase58Token(TokenType type, void const* token, std::size_t size);
96
97// This interface matches the old interface, but requires additional allocation
98[[nodiscard]] std::string
100
101namespace detail {
102// Expose detail functions for unit tests only
104b256_to_b58_be(
107
109b58_to_b256_be(std::string_view input, std::span<std::uint8_t> out);
110} // namespace detail
111
112} // namespace b58_fast
113#endif // _MSC_VER
114} // namespace ripple
115
116#endif
std::string decodeBase58(std::string const &s)
Definition tokens.cpp:257
std::string encodeBase58(void const *message, std::size_t size, void *temp, std::size_t temp_size)
Definition tokens.cpp:205
std::string encodeBase58Token(TokenType type, void const *token, std::size_t size)
Definition tokens.cpp:307
std::string decodeBase58Token(std::string const &s, TokenType type)
Definition tokens.cpp:331
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
TokenType
Definition tokens.h:19
std::optional< AccountID > parseBase58(std::string const &s)
Parse AccountID from checked, base58 string.
std::string encodeBase58Token(TokenType type, void const *token, std::size_t size)
Encode data in Base58Check format using XRPL alphabet.
Definition tokens.cpp:181
std::string decodeBase58Token(std::string const &s, TokenType type)
Definition tokens.cpp:191