Merge #21471: bugfix: fix bech32_encode calls in gen_key_io_test_vectors.py

5c0210e3e6 bugfix: fix bech32_encode calls in gen_key_io_test_vectors.py (Pieter Wuille)

Pull request description:

  This fixes the the calls to bech32_encode in the gen_key_io_test_vectors.py script.

  Bug introduced in #20861.

ACKs for top commit:
  fanquake:
    ACK 5c0210e3e6

Tree-SHA512: 8e8aee08741619c1700371ca1a8ca05ffdb2f48544d9fd3982f2665f6afb926b126478cf644f15a699f8c7e7da53c2777a56ce7989f05e4a3ef9fbe085f74d5a
This commit is contained in:
fanquake 2021-03-19 11:31:51 +08:00
commit 47d79c941a
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -149,7 +149,7 @@ def gen_valid_bech32_vector(template):
witprog = bytearray(os.urandom(template[2]))
encoding = template[4]
dst_prefix = bytearray(template[5])
rv = bech32_encode(hrp, [witver] + convertbits(witprog, 8, 5), encoding)
rv = bech32_encode(encoding, hrp, [witver] + convertbits(witprog, 8, 5))
return rv, dst_prefix + witprog
def gen_valid_vectors():
@ -210,7 +210,7 @@ def gen_invalid_bech32_vector(template):
encoding = template[3]
if no_data:
rv = bech32_encode(hrp, [], encoding)
rv = bech32_encode(encoding, hrp, [])
else:
data = [witver] + convertbits(witprog, 8, 5)
if template[4] and not no_data:
@ -218,7 +218,7 @@ def gen_invalid_bech32_vector(template):
data[-1] |= 1
else:
data.append(0)
rv = bech32_encode(hrp, data, encoding)
rv = bech32_encode(encoding, hrp, data)
if template[5]:
i = len(rv) - random.randrange(1, 7)