mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
naming nits
This commit is contained in:
parent
2e7c80fb5b
commit
03346022d6
2 changed files with 10 additions and 9 deletions
|
@ -15,10 +15,10 @@ namespace
|
||||||
|
|
||||||
typedef std::vector<uint8_t> data;
|
typedef std::vector<uint8_t> data;
|
||||||
|
|
||||||
/** The Bech32 character set for encoding. */
|
/** The Bech32 and Bech32m character set for encoding. */
|
||||||
const char* CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
const char* CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
||||||
|
|
||||||
/** The Bech32 character set for decoding. */
|
/** The Bech32 and Bech32m character set for decoding. */
|
||||||
const int8_t CHARSET_REV[128] = {
|
const int8_t CHARSET_REV[128] = {
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
@ -150,8 +150,8 @@ data CreateChecksum(Encoding encoding, const std::string& hrp, const data& value
|
||||||
|
|
||||||
/** Encode a Bech32 or Bech32m string. */
|
/** Encode a Bech32 or Bech32m string. */
|
||||||
std::string Encode(Encoding encoding, const std::string& hrp, const data& values) {
|
std::string Encode(Encoding encoding, const std::string& hrp, const data& values) {
|
||||||
// First ensure that the HRP is all lowercase. BIP-173 requires an encoder
|
// First ensure that the HRP is all lowercase. BIP-173 and BIP350 require an encoder
|
||||||
// to return a lowercase Bech32 string, but if given an uppercase HRP, the
|
// to return a lowercase Bech32/Bech32m string, but if given an uppercase HRP, the
|
||||||
// result will always be invalid.
|
// result will always be invalid.
|
||||||
for (const char& c : hrp) assert(c < 'A' || c > 'Z');
|
for (const char& c : hrp) assert(c < 'A' || c > 'Z');
|
||||||
data checksum = CreateChecksum(encoding, hrp, values);
|
data checksum = CreateChecksum(encoding, hrp, values);
|
||||||
|
|
11
src/bech32.h
11
src/bech32.h
|
@ -2,10 +2,11 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
// Bech32 is a string encoding format used in newer address types.
|
// Bech32 and Bech32m are string encoding formats used in newer
|
||||||
// The output consists of a human-readable part (alphanumeric), a
|
// address types. The outputs consist of a human-readable part
|
||||||
// separator character (1), and a base32 data section, the last
|
// (alphanumeric), a separator character (1), and a base32 data
|
||||||
// 6 characters of which are a checksum.
|
// section, the last 6 characters of which are a checksum. The
|
||||||
|
// module is namespaced under bech32 for historical reasons.
|
||||||
//
|
//
|
||||||
// For more information, see BIP 173 and BIP 350.
|
// For more information, see BIP 173 and BIP 350.
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ struct DecodeResult
|
||||||
DecodeResult(Encoding enc, std::string&& h, std::vector<uint8_t>&& d) : encoding(enc), hrp(std::move(h)), data(std::move(d)) {}
|
DecodeResult(Encoding enc, std::string&& h, std::vector<uint8_t>&& d) : encoding(enc), hrp(std::move(h)), data(std::move(d)) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Decode a Bech32 string. */
|
/** Decode a Bech32 or Bech32m string. */
|
||||||
DecodeResult Decode(const std::string& str);
|
DecodeResult Decode(const std::string& str);
|
||||||
|
|
||||||
} // namespace bech32
|
} // namespace bech32
|
||||||
|
|
Loading…
Add table
Reference in a new issue