mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Merge #20168: contrib: Fix gen_key_io_test_vectors.py imports
fa68755364
contrib: Fix gen_key_io_test_vectors.py imports (MarcoFalke) Pull request description: The script currently fails with ``` Traceback (most recent call last): File "./gen_key_io_test_vectors.py", line 18, in <module> from segwit_addr import bech32_encode, decode, convertbits, CHARSET ImportError: cannot import name 'decode' from 'segwit_addr' ``` Fix that. Also, unrelated cleanup to use the `bytearray.hex()` method instead of importing a library. https://docs.python.org/3.5/library/stdtypes.html#bytes.hex ACKs for top commit: theStack: tested ACKfa68755364
Tree-SHA512: 45ff7d710de3d0ef5ac6d91543cff0edff6189d2cd00b0f8889f4361e66ef1825f12aea9e71d62038c14a7a531bfc95ffe9a1df83b85aa7f3dd666df07a6be81
This commit is contained in:
commit
b3527fd2e9
1 changed files with 3 additions and 6 deletions
|
@ -15,8 +15,7 @@ import os
|
|||
from itertools import islice
|
||||
from base58 import b58encode_chk, b58decode_chk, b58chars
|
||||
import random
|
||||
from binascii import b2a_hex
|
||||
from segwit_addr import bech32_encode, decode, convertbits, CHARSET
|
||||
from segwit_addr import bech32_encode, decode_segwit_address, convertbits, CHARSET
|
||||
|
||||
# key types
|
||||
PUBKEY_ADDRESS = 0
|
||||
|
@ -109,7 +108,7 @@ def is_valid(v):
|
|||
def is_valid_bech32(v):
|
||||
'''Check vector v for bech32 validity'''
|
||||
for hrp in ['bc', 'tb', 'bcrt']:
|
||||
if decode(hrp, v) != (None, None):
|
||||
if decode_segwit_address(hrp, v) != (None, None):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -141,9 +140,7 @@ def gen_valid_vectors():
|
|||
rv, payload = valid_vector_generator(template)
|
||||
assert is_valid(rv)
|
||||
metadata = {x: y for x, y in zip(metadata_keys,template[3]) if y is not None}
|
||||
hexrepr = b2a_hex(payload)
|
||||
if isinstance(hexrepr, bytes):
|
||||
hexrepr = hexrepr.decode('utf8')
|
||||
hexrepr = payload.hex()
|
||||
yield (rv, hexrepr, metadata)
|
||||
|
||||
def gen_invalid_base58_vector(template):
|
||||
|
|
Loading…
Add table
Reference in a new issue