diff options
author | Fabian Jahr <fjahr@protonmail.com> | 2021-03-18 00:43:35 +0100 |
---|---|---|
committer | Pieter Wuille <pieter@wuille.net> | 2021-03-27 12:08:33 -0700 |
commit | c6709867d3614809c17d38bab5ac6772460c0599 (patch) | |
tree | 93fe58939088d02cfe6182a57da4a49e7bec6bc0 | |
parent | 1a4e88e0e885cfcb91196840a958e7c9fa09c3b5 (diff) |
naming nits
Github-Pull: #20861
Rebased-From: 03346022d611871f2cc185440b19d928b9264d9d
-rw-r--r-- | src/bech32.cpp | 8 | ||||
-rw-r--r-- | src/bech32.h | 11 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/bech32.cpp b/src/bech32.cpp index 289e0213e8..288b14e023 100644 --- a/src/bech32.cpp +++ b/src/bech32.cpp @@ -15,10 +15,10 @@ namespace typedef std::vector<uint8_t> data; -/** The Bech32 character set for encoding. */ +/** The Bech32 and Bech32m character set for encoding. */ const char* CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"; -/** The Bech32 character set for decoding. */ +/** The Bech32 and Bech32m character set for decoding. */ 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, @@ -150,8 +150,8 @@ data CreateChecksum(Encoding encoding, const std::string& hrp, const data& value /** Encode a Bech32 or Bech32m string. */ 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 - // to return a lowercase Bech32 string, but if given an uppercase HRP, the + // First ensure that the HRP is all lowercase. BIP-173 and BIP350 require an encoder + // to return a lowercase Bech32/Bech32m string, but if given an uppercase HRP, the // result will always be invalid. for (const char& c : hrp) assert(c < 'A' || c > 'Z'); data checksum = CreateChecksum(encoding, hrp, values); diff --git a/src/bech32.h b/src/bech32.h index 3679ea8ccb..e9450ccc2b 100644 --- a/src/bech32.h +++ b/src/bech32.h @@ -2,10 +2,11 @@ // 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. +// Bech32 and Bech32m are string encoding formats used in newer +// address types. The outputs consist of a human-readable part +// (alphanumeric), a separator character (1), and a base32 data +// 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. @@ -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)) {} }; -/** Decode a Bech32 string. */ +/** Decode a Bech32 or Bech32m string. */ DecodeResult Decode(const std::string& str); } // namespace bech32 |