Skip to content

Commit 8ec881d

Browse files
committed
Merge #20861: BIP 350: Implement Bech32m and use it for v1+ segwit addresses
0334602 naming nits (Fabian Jahr) 2e7c80f Add signet support to gen_key_io_test_vectors.py (Pieter Wuille) fe5e495 Use Bech32m encoding for v1+ segwit addresses (Pieter Wuille) 25b1c6e Add Bech32m test vectors (Pieter Wuille) da2bb69 Implement Bech32m encoding/decoding (Pieter Wuille) Pull request description: This implements [BIP 350](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki): * For segwit v1+ addresses, a new checksum algorithm called Bech32m is used. * Segwit v0 address keep using Bech32 as specified in [BIP 173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki). ACKs for top commit: Sjors: utACK 0334602 jnewbery: utACK 0334602 achow101: ACK 0334602 fjahr: re-ACK 0334602 benthecarman: ACK 0334602 Tree-SHA512: 4424cfd44869d813d6152fb3ed867b204036736bc2344a039b93700b6f36a43e9110478f138eb81c97c77ab27ecb776dada5ba632cb5a3a9d244924d2540a557
2 parents a65e772 + 0334602 commit 8ec881d

File tree

15 files changed

+687
-431
lines changed

15 files changed

+687
-431
lines changed

contrib/testgen/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ Utilities to generate test vectors for the data-driven Bitcoin tests.
44

55
Usage:
66

7-
PYTHONPATH=../../test/functional/test_framework ./gen_key_io_test_vectors.py valid 50 > ../../src/test/data/key_io_valid.json
8-
PYTHONPATH=../../test/functional/test_framework ./gen_key_io_test_vectors.py invalid 50 > ../../src/test/data/key_io_invalid.json
7+
PYTHONPATH=../../test/functional/test_framework ./gen_key_io_test_vectors.py valid 70 > ../../src/test/data/key_io_valid.json
8+
PYTHONPATH=../../test/functional/test_framework ./gen_key_io_test_vectors.py invalid 70 > ../../src/test/data/key_io_invalid.json

contrib/testgen/gen_key_io_test_vectors.py

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
'''
6-
Generate valid and invalid base58 address and private key test vectors.
6+
Generate valid and invalid base58/bech32(m) address and private key test vectors.
77
88
Usage:
9-
PYTHONPATH=../../test/functional/test_framework ./gen_key_io_test_vectors.py valid 50 > ../../src/test/data/key_io_valid.json
10-
PYTHONPATH=../../test/functional/test_framework ./gen_key_io_test_vectors.py invalid 50 > ../../src/test/data/key_io_invalid.json
9+
PYTHONPATH=../../test/functional/test_framework ./gen_key_io_test_vectors.py valid 70 > ../../src/test/data/key_io_valid.json
10+
PYTHONPATH=../../test/functional/test_framework ./gen_key_io_test_vectors.py invalid 70 > ../../src/test/data/key_io_invalid.json
1111
'''
1212
# 2012 Wladimir J. van der Laan
1313
# Released under MIT License
1414
import os
1515
from itertools import islice
1616
from base58 import b58encode_chk, b58decode_chk, b58chars
1717
import random
18-
from segwit_addr import bech32_encode, decode_segwit_address, convertbits, CHARSET
18+
from segwit_addr import bech32_encode, decode_segwit_address, convertbits, CHARSET, Encoding
1919

2020
# key types
2121
PUBKEY_ADDRESS = 0
@@ -32,6 +32,7 @@
3232
OP_0 = 0x00
3333
OP_1 = 0x51
3434
OP_2 = 0x52
35+
OP_3 = 0x53
3536
OP_16 = 0x60
3637
OP_DUP = 0x76
3738
OP_EQUAL = 0x87
@@ -44,6 +45,7 @@
4445
script_suffix = (OP_EQUAL,)
4546
p2wpkh_prefix = (OP_0, 20)
4647
p2wsh_prefix = (OP_0, 32)
48+
p2tr_prefix = (OP_1, 32)
4749

4850
metadata_keys = ['isPrivkey', 'chain', 'isCompressed', 'tryCaseFlip']
4951
# templates for valid sequences
@@ -54,40 +56,58 @@
5456
((SCRIPT_ADDRESS,), 20, (), (False, 'main', None, None), script_prefix, script_suffix),
5557
((PUBKEY_ADDRESS_TEST,), 20, (), (False, 'test', None, None), pubkey_prefix, pubkey_suffix),
5658
((SCRIPT_ADDRESS_TEST,), 20, (), (False, 'test', None, None), script_prefix, script_suffix),
59+
((PUBKEY_ADDRESS_TEST,), 20, (), (False, 'signet', None, None), pubkey_prefix, pubkey_suffix),
60+
((SCRIPT_ADDRESS_TEST,), 20, (), (False, 'signet', None, None), script_prefix, script_suffix),
5761
((PUBKEY_ADDRESS_REGTEST,), 20, (), (False, 'regtest', None, None), pubkey_prefix, pubkey_suffix),
5862
((SCRIPT_ADDRESS_REGTEST,), 20, (), (False, 'regtest', None, None), script_prefix, script_suffix),
5963
((PRIVKEY,), 32, (), (True, 'main', False, None), (), ()),
6064
((PRIVKEY,), 32, (1,), (True, 'main', True, None), (), ()),
6165
((PRIVKEY_TEST,), 32, (), (True, 'test', False, None), (), ()),
6266
((PRIVKEY_TEST,), 32, (1,), (True, 'test', True, None), (), ()),
67+
((PRIVKEY_TEST,), 32, (), (True, 'signet', False, None), (), ()),
68+
((PRIVKEY_TEST,), 32, (1,), (True, 'signet', True, None), (), ()),
6369
((PRIVKEY_REGTEST,), 32, (), (True, 'regtest', False, None), (), ()),
6470
((PRIVKEY_REGTEST,), 32, (1,), (True, 'regtest', True, None), (), ())
6571
]
6672
# templates for valid bech32 sequences
6773
bech32_templates = [
68-
# hrp, version, witprog_size, metadata, output_prefix
69-
('bc', 0, 20, (False, 'main', None, True), p2wpkh_prefix),
70-
('bc', 0, 32, (False, 'main', None, True), p2wsh_prefix),
71-
('bc', 1, 2, (False, 'main', None, True), (OP_1, 2)),
72-
('tb', 0, 20, (False, 'test', None, True), p2wpkh_prefix),
73-
('tb', 0, 32, (False, 'test', None, True), p2wsh_prefix),
74-
('tb', 2, 16, (False, 'test', None, True), (OP_2, 16)),
75-
('bcrt', 0, 20, (False, 'regtest', None, True), p2wpkh_prefix),
76-
('bcrt', 0, 32, (False, 'regtest', None, True), p2wsh_prefix),
77-
('bcrt', 16, 40, (False, 'regtest', None, True), (OP_16, 40))
74+
# hrp, version, witprog_size, metadata, encoding, output_prefix
75+
('bc', 0, 20, (False, 'main', None, True), Encoding.BECH32, p2wpkh_prefix),
76+
('bc', 0, 32, (False, 'main', None, True), Encoding.BECH32, p2wsh_prefix),
77+
('bc', 1, 32, (False, 'main', None, True), Encoding.BECH32M, p2tr_prefix),
78+
('bc', 2, 2, (False, 'main', None, True), Encoding.BECH32M, (OP_2, 2)),
79+
('tb', 0, 20, (False, 'test', None, True), Encoding.BECH32, p2wpkh_prefix),
80+
('tb', 0, 32, (False, 'test', None, True), Encoding.BECH32, p2wsh_prefix),
81+
('tb', 1, 32, (False, 'test', None, True), Encoding.BECH32M, p2tr_prefix),
82+
('tb', 3, 16, (False, 'test', None, True), Encoding.BECH32M, (OP_3, 16)),
83+
('tb', 0, 20, (False, 'signet', None, True), Encoding.BECH32, p2wpkh_prefix),
84+
('tb', 0, 32, (False, 'signet', None, True), Encoding.BECH32, p2wsh_prefix),
85+
('tb', 1, 32, (False, 'signet', None, True), Encoding.BECH32M, p2tr_prefix),
86+
('tb', 3, 32, (False, 'signet', None, True), Encoding.BECH32M, (OP_3, 32)),
87+
('bcrt', 0, 20, (False, 'regtest', None, True), Encoding.BECH32, p2wpkh_prefix),
88+
('bcrt', 0, 32, (False, 'regtest', None, True), Encoding.BECH32, p2wsh_prefix),
89+
('bcrt', 1, 32, (False, 'regtest', None, True), Encoding.BECH32M, p2tr_prefix),
90+
('bcrt', 16, 40, (False, 'regtest', None, True), Encoding.BECH32M, (OP_16, 40))
7891
]
7992
# templates for invalid bech32 sequences
8093
bech32_ng_templates = [
81-
# hrp, version, witprog_size, invalid_bech32, invalid_checksum, invalid_char
82-
('tc', 0, 20, False, False, False),
83-
('tb', 17, 32, False, False, False),
84-
('bcrt', 3, 1, False, False, False),
85-
('bc', 15, 41, False, False, False),
86-
('tb', 0, 16, False, False, False),
87-
('bcrt', 0, 32, True, False, False),
88-
('bc', 0, 16, True, False, False),
89-
('tb', 0, 32, False, True, False),
90-
('bcrt', 0, 20, False, False, True)
94+
# hrp, version, witprog_size, encoding, invalid_bech32, invalid_checksum, invalid_char
95+
('tc', 0, 20, Encoding.BECH32, False, False, False),
96+
('bt', 1, 32, Encoding.BECH32M, False, False, False),
97+
('tb', 17, 32, Encoding.BECH32M, False, False, False),
98+
('bcrt', 3, 1, Encoding.BECH32M, False, False, False),
99+
('bc', 15, 41, Encoding.BECH32M, False, False, False),
100+
('tb', 0, 16, Encoding.BECH32, False, False, False),
101+
('bcrt', 0, 32, Encoding.BECH32, True, False, False),
102+
('bc', 0, 16, Encoding.BECH32, True, False, False),
103+
('tb', 0, 32, Encoding.BECH32, False, True, False),
104+
('bcrt', 0, 20, Encoding.BECH32, False, False, True),
105+
('bc', 0, 20, Encoding.BECH32M, False, False, False),
106+
('tb', 0, 32, Encoding.BECH32M, False, False, False),
107+
('bcrt', 0, 20, Encoding.BECH32M, False, False, False),
108+
('bc', 1, 32, Encoding.BECH32, False, False, False),
109+
('tb', 2, 16, Encoding.BECH32, False, False, False),
110+
('bcrt', 16, 20, Encoding.BECH32, False, False, False),
91111
]
92112

93113
def is_valid(v):
@@ -127,8 +147,9 @@ def gen_valid_bech32_vector(template):
127147
hrp = template[0]
128148
witver = template[1]
129149
witprog = bytearray(os.urandom(template[2]))
130-
dst_prefix = bytearray(template[4])
131-
rv = bech32_encode(hrp, [witver] + convertbits(witprog, 8, 5))
150+
encoding = template[4]
151+
dst_prefix = bytearray(template[5])
152+
rv = bech32_encode(hrp, [witver] + convertbits(witprog, 8, 5), encoding)
132153
return rv, dst_prefix + witprog
133154

134155
def gen_valid_vectors():
@@ -186,22 +207,23 @@ def gen_invalid_bech32_vector(template):
186207
hrp = template[0]
187208
witver = template[1]
188209
witprog = bytearray(os.urandom(template[2]))
210+
encoding = template[3]
189211

190212
if no_data:
191-
rv = bech32_encode(hrp, [])
213+
rv = bech32_encode(hrp, [], encoding)
192214
else:
193215
data = [witver] + convertbits(witprog, 8, 5)
194-
if template[3] and not no_data:
216+
if template[4] and not no_data:
195217
if template[2] % 5 in {2, 4}:
196218
data[-1] |= 1
197219
else:
198220
data.append(0)
199-
rv = bech32_encode(hrp, data)
221+
rv = bech32_encode(hrp, data, encoding)
200222

201-
if template[4]:
223+
if template[5]:
202224
i = len(rv) - random.randrange(1, 7)
203225
rv = rv[:i] + random.choice(CHARSET.replace(rv[i], '')) + rv[i + 1:]
204-
if template[5]:
226+
if template[6]:
205227
i = len(hrp) + 1 + random.randrange(0, len(rv) - len(hrp) - 4)
206228
rv = rv[:i] + rv[i:i + 4].upper() + rv[i + 4:]
207229

doc/bips.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
BIPs that are implemented by Bitcoin Core (up-to-date up to **v0.21.0**):
1+
BIPs that are implemented by Bitcoin Core (up-to-date up to **v22.0**):
22

33
* [`BIP 9`](https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki): The changes allowing multiple soft-forks to be deployed in parallel have been implemented since **v0.12.1** ([PR #7575](https://github.com/bitcoin/bitcoin/pull/7575))
44
* [`BIP 11`](https://github.com/bitcoin/bips/blob/master/bip-0011.mediawiki): Multisig outputs are standard since **v0.6.0** ([PR #669](https://github.com/bitcoin/bitcoin/pull/669)).
@@ -50,3 +50,4 @@ BIPs that are implemented by Bitcoin Core (up-to-date up to **v0.21.0**):
5050
* [`BIP 325`](https://github.com/bitcoin/bips/blob/master/bip-0325.mediawiki): Signet test network is supported as of **v0.21.0** ([PR 18267](https://github.com/bitcoin/bitcoin/pull/18267)).
5151
* [`BIP 339`](https://github.com/bitcoin/bips/blob/master/bip-0339.mediawiki): Relay of transactions by wtxid is supported as of **v0.21.0** ([PR 18044](https://github.com/bitcoin/bitcoin/pull/18044)).
5252
* [`BIP 340`](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki) [`341`](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki) [`342`](https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki): Validation rules for Taproot (including Schnorr signatures and Tapscript leaves) are implemented as of **v0.21.0** ([PR 19953](https://github.com/bitcoin/bitcoin/pull/19953)), without mainnet activation.
53+
* [`BIP 350`](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki): Addresses for native v1+ segregated Witness outputs use Bech32m instead of Bech32 as of **v22.0** ([PR 20861](https://github.com/bitcoin/bitcoin/pull/20861)).

doc/release-notes-20861.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Updated RPCs
2+
------------
3+
4+
- Due to [BIP 350](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki)
5+
being implemented, behavior for all RPCs that accept addresses is changed when
6+
a native witness version 1 (or higher) is passed. These now require a Bech32m
7+
encoding instead of a Bech32 one, and Bech32m encoding will be used for such
8+
addresses in RPC output as well. No version 1 addresses should be created
9+
for mainnet until consensus rules are adopted that give them meaning
10+
(e.g. through [BIP 341](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki)).
11+
Once that happens, Bech32m is expected to be used for them, so this shouldn't
12+
affect any production systems, but may be observed on other networks where such
13+
addresses already have meaning (like signet).

src/bech32.cpp

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017 Pieter Wuille
1+
// Copyright (c) 2017, 2021 Pieter Wuille
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -7,15 +7,18 @@
77

88
#include <assert.h>
99

10+
namespace bech32
11+
{
12+
1013
namespace
1114
{
1215

1316
typedef std::vector<uint8_t> data;
1417

15-
/** The Bech32 character set for encoding. */
18+
/** The Bech32 and Bech32m character set for encoding. */
1619
const char* CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
1720

18-
/** The Bech32 character set for decoding. */
21+
/** The Bech32 and Bech32m character set for decoding. */
1922
const int8_t CHARSET_REV[128] = {
2023
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2124
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
@@ -27,6 +30,12 @@ const int8_t CHARSET_REV[128] = {
2730
1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1
2831
};
2932

33+
/* Determine the final constant to use for the specified encoding. */
34+
uint32_t EncodingConstant(Encoding encoding) {
35+
assert(encoding == Encoding::BECH32 || encoding == Encoding::BECH32M);
36+
return encoding == Encoding::BECH32 ? 1 : 0x2bc830a3;
37+
}
38+
3039
/** This function will compute what 6 5-bit values to XOR into the last 6 input values, in order to
3140
* make the checksum 0. These 6 values are packed together in a single 30-bit integer. The higher
3241
* bits correspond to earlier values. */
@@ -111,21 +120,24 @@ data ExpandHRP(const std::string& hrp)
111120
}
112121

113122
/** Verify a checksum. */
114-
bool VerifyChecksum(const std::string& hrp, const data& values)
123+
Encoding VerifyChecksum(const std::string& hrp, const data& values)
115124
{
116125
// PolyMod computes what value to xor into the final values to make the checksum 0. However,
117126
// if we required that the checksum was 0, it would be the case that appending a 0 to a valid
118127
// list of values would result in a new valid list. For that reason, Bech32 requires the
119-
// resulting checksum to be 1 instead.
120-
return PolyMod(Cat(ExpandHRP(hrp), values)) == 1;
128+
// resulting checksum to be 1 instead. In Bech32m, this constant was amended.
129+
const uint32_t check = PolyMod(Cat(ExpandHRP(hrp), values));
130+
if (check == EncodingConstant(Encoding::BECH32)) return Encoding::BECH32;
131+
if (check == EncodingConstant(Encoding::BECH32M)) return Encoding::BECH32M;
132+
return Encoding::INVALID;
121133
}
122134

123135
/** Create a checksum. */
124-
data CreateChecksum(const std::string& hrp, const data& values)
136+
data CreateChecksum(Encoding encoding, const std::string& hrp, const data& values)
125137
{
126138
data enc = Cat(ExpandHRP(hrp), values);
127139
enc.resize(enc.size() + 6); // Append 6 zeroes
128-
uint32_t mod = PolyMod(enc) ^ 1; // Determine what to XOR into those 6 zeroes.
140+
uint32_t mod = PolyMod(enc) ^ EncodingConstant(encoding); // Determine what to XOR into those 6 zeroes.
129141
data ret(6);
130142
for (size_t i = 0; i < 6; ++i) {
131143
// Convert the 5-bit groups in mod to checksum values.
@@ -136,16 +148,13 @@ data CreateChecksum(const std::string& hrp, const data& values)
136148

137149
} // namespace
138150

139-
namespace bech32
140-
{
141-
142-
/** Encode a Bech32 string. */
143-
std::string Encode(const std::string& hrp, const data& values) {
144-
// First ensure that the HRP is all lowercase. BIP-173 requires an encoder
145-
// to return a lowercase Bech32 string, but if given an uppercase HRP, the
151+
/** Encode a Bech32 or Bech32m string. */
152+
std::string Encode(Encoding encoding, const std::string& hrp, const data& values) {
153+
// First ensure that the HRP is all lowercase. BIP-173 and BIP350 require an encoder
154+
// to return a lowercase Bech32/Bech32m string, but if given an uppercase HRP, the
146155
// result will always be invalid.
147156
for (const char& c : hrp) assert(c < 'A' || c > 'Z');
148-
data checksum = CreateChecksum(hrp, values);
157+
data checksum = CreateChecksum(encoding, hrp, values);
149158
data combined = Cat(values, checksum);
150159
std::string ret = hrp + '1';
151160
ret.reserve(ret.size() + combined.size());
@@ -155,8 +164,8 @@ std::string Encode(const std::string& hrp, const data& values) {
155164
return ret;
156165
}
157166

158-
/** Decode a Bech32 string. */
159-
std::pair<std::string, data> Decode(const std::string& str) {
167+
/** Decode a Bech32 or Bech32m string. */
168+
DecodeResult Decode(const std::string& str) {
160169
bool lower = false, upper = false;
161170
for (size_t i = 0; i < str.size(); ++i) {
162171
unsigned char c = str[i];
@@ -183,10 +192,9 @@ std::pair<std::string, data> Decode(const std::string& str) {
183192
for (size_t i = 0; i < pos; ++i) {
184193
hrp += LowerCase(str[i]);
185194
}
186-
if (!VerifyChecksum(hrp, values)) {
187-
return {};
188-
}
189-
return {hrp, data(values.begin(), values.end() - 6)};
195+
Encoding result = VerifyChecksum(hrp, values);
196+
if (result == Encoding::INVALID) return {};
197+
return {result, std::move(hrp), data(values.begin(), values.end() - 6)};
190198
}
191199

192200
} // namespace bech32

src/bech32.h

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
// Copyright (c) 2017 Pieter Wuille
1+
// Copyright (c) 2017, 2021 Pieter Wuille
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
// Bech32 is a string encoding format used in newer address types.
6-
// The output consists of a human-readable part (alphanumeric), a
7-
// separator character (1), and a base32 data section, the last
8-
// 6 characters of which are a checksum.
5+
// Bech32 and Bech32m are string encoding formats used in newer
6+
// address types. The outputs consist of a human-readable part
7+
// (alphanumeric), a separator character (1), and a base32 data
8+
// section, the last 6 characters of which are a checksum. The
9+
// module is namespaced under bech32 for historical reasons.
910
//
10-
// For more information, see BIP 173.
11+
// For more information, see BIP 173 and BIP 350.
1112

1213
#ifndef BITCOIN_BECH32_H
1314
#define BITCOIN_BECH32_H
@@ -19,11 +20,29 @@
1920
namespace bech32
2021
{
2122

22-
/** Encode a Bech32 string. If hrp contains uppercase characters, this will cause an assertion error. */
23-
std::string Encode(const std::string& hrp, const std::vector<uint8_t>& values);
23+
enum class Encoding {
24+
INVALID, //!< Failed decoding
2425

25-
/** Decode a Bech32 string. Returns (hrp, data). Empty hrp means failure. */
26-
std::pair<std::string, std::vector<uint8_t>> Decode(const std::string& str);
26+
BECH32, //!< Bech32 encoding as defined in BIP173
27+
BECH32M, //!< Bech32m encoding as defined in BIP350
28+
};
29+
30+
/** Encode a Bech32 or Bech32m string. If hrp contains uppercase characters, this will cause an
31+
* assertion error. Encoding must be one of BECH32 or BECH32M. */
32+
std::string Encode(Encoding encoding, const std::string& hrp, const std::vector<uint8_t>& values);
33+
34+
struct DecodeResult
35+
{
36+
Encoding encoding; //!< What encoding was detected in the result; Encoding::INVALID if failed.
37+
std::string hrp; //!< The human readable part
38+
std::vector<uint8_t> data; //!< The payload (excluding checksum)
39+
40+
DecodeResult() : encoding(Encoding::INVALID) {}
41+
DecodeResult(Encoding enc, std::string&& h, std::vector<uint8_t>&& d) : encoding(enc), hrp(std::move(h)), data(std::move(d)) {}
42+
};
43+
44+
/** Decode a Bech32 or Bech32m string. */
45+
DecodeResult Decode(const std::string& str);
2746

2847
} // namespace bech32
2948

src/bench/bech32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static void Bech32Encode(benchmark::Bench& bench)
1919
tmp.reserve(1 + 32 * 8 / 5);
2020
ConvertBits<8, 5, true>([&](unsigned char c) { tmp.push_back(c); }, v.begin(), v.end());
2121
bench.batch(v.size()).unit("byte").run([&] {
22-
bech32::Encode("bc", tmp);
22+
bech32::Encode(bech32::Encoding::BECH32, "bc", tmp);
2323
});
2424
}
2525

0 commit comments

Comments
 (0)