11typedef std::vector<uint8_t> data;
16const char *
CHARSET =
"qpzry9x8gf2tvdw0s3jn54khce6mua7l";
22 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
23 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
24 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, 10, 17, 21, 20, 26, 30, 7,
25 5, -1, -1, -1, -1, -1, -1, -1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22,
26 31, 27, 19, -1, 1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1,
27 -1, -1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, -1, 1, 0,
28 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1};
98 c = ((
c & 0x07ffffffff) << 5) ^ d;
158 for (
size_t i = 0; i <
prefix.size(); ++i) {
179 enc.resize(enc.size() + 8);
183 for (
size_t i = 0; i < 8; ++i) {
185 ret[i] = (
mod >> (5 * (7 - i))) & 0x1f;
214std::pair<std::string, data>
Decode(
const std::string &str,
219 for (
size_t i = 0; i < str.size(); ++i) {
221 if (
c >=
'a' &&
c <=
'z') {
226 if (
c >=
'A' &&
c <=
'Z') {
231 if (
c >=
'0' &&
c <=
'9') {
289 return {std::move(
prefix), data(values.begin(), values.end() - 8)};
std::pair< std::string, data > Decode(const std::string &str, const std::string &default_prefix)
Decode a cashaddr string.
std::string Encode(const std::string &prefix, const data &payload)
Encode a cashaddr string.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.