mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
contrib: Fix gen_key_io_test_vectors.py imports
This commit is contained in:
parent
cb21d864c5
commit
fa68755364
1 changed files with 3 additions and 6 deletions
|
@ -15,8 +15,7 @@ import os
|
||||||
from itertools import islice
|
from itertools import islice
|
||||||
from base58 import b58encode_chk, b58decode_chk, b58chars
|
from base58 import b58encode_chk, b58decode_chk, b58chars
|
||||||
import random
|
import random
|
||||||
from binascii import b2a_hex
|
from segwit_addr import bech32_encode, decode_segwit_address, convertbits, CHARSET
|
||||||
from segwit_addr import bech32_encode, decode, convertbits, CHARSET
|
|
||||||
|
|
||||||
# key types
|
# key types
|
||||||
PUBKEY_ADDRESS = 0
|
PUBKEY_ADDRESS = 0
|
||||||
|
@ -109,7 +108,7 @@ def is_valid(v):
|
||||||
def is_valid_bech32(v):
|
def is_valid_bech32(v):
|
||||||
'''Check vector v for bech32 validity'''
|
'''Check vector v for bech32 validity'''
|
||||||
for hrp in ['bc', 'tb', 'bcrt']:
|
for hrp in ['bc', 'tb', 'bcrt']:
|
||||||
if decode(hrp, v) != (None, None):
|
if decode_segwit_address(hrp, v) != (None, None):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -141,9 +140,7 @@ def gen_valid_vectors():
|
||||||
rv, payload = valid_vector_generator(template)
|
rv, payload = valid_vector_generator(template)
|
||||||
assert is_valid(rv)
|
assert is_valid(rv)
|
||||||
metadata = {x: y for x, y in zip(metadata_keys,template[3]) if y is not None}
|
metadata = {x: y for x, y in zip(metadata_keys,template[3]) if y is not None}
|
||||||
hexrepr = b2a_hex(payload)
|
hexrepr = payload.hex()
|
||||||
if isinstance(hexrepr, bytes):
|
|
||||||
hexrepr = hexrepr.decode('utf8')
|
|
||||||
yield (rv, hexrepr, metadata)
|
yield (rv, hexrepr, metadata)
|
||||||
|
|
||||||
def gen_invalid_base58_vector(template):
|
def gen_invalid_base58_vector(template):
|
||||||
|
|
Loading…
Add table
Reference in a new issue