dash/src/bech32.h
Pieter Wuille c9936a5115
Partial merge bitcoin#11167: Full BIP173 (Bech32) support
Implement {Encode,Decode}Destination without CBitcoinAddress

Import Bech32 C++ reference code & tests

This includes a reformatted version of the Bech32 reference code
(see https://github.com/sipa/bech32/tree/master/ref/c%2B%2B), with
extra documentation.

Convert base58_tests from type/payload to scriptPubKey comparison

Add regtest testing to base58_tests

Implement ConvertBits

A part of "Implement BIP173 addresses and tests"

Make linter happy
2021-01-08 22:35:13 +03:00

31 lines
946 B
C++

// Copyright (c) 2017 Pieter Wuille
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
// Bech32 is a string encoding format used in newer address types.
// The output consists of a human-readable part (alphanumeric), a
// separator character (1), and a base32 data section, the last
// 6 characters of which are a checksum.
//
// For more information, see BIP 173.
#ifndef BITCOIN_BECH32_H
#define BITCOIN_BECH32_H
#include <stdint.h>
#include <string>
#include <vector>
namespace bech32
{
/** Encode a Bech32 string. Returns the empty string in case of failure. */
std::string Encode(const std::string& hrp, const std::vector<uint8_t>& values);
/** Decode a Bech32 string. Returns (hrp, data). Empty hrp means failure. */
std::pair<std::string, std::vector<uint8_t>> Decode(const std::string& str);
} // namespace bech32
#endif // BITCOIN_BECH32_H