|
15 | 15 | from itertools import islice
|
16 | 16 | from base58 import b58encode_chk, b58decode_chk, b58chars
|
17 | 17 | import random
|
18 |
| -from binascii import b2a_hex |
19 |
| -from segwit_addr import bech32_encode, decode, convertbits, CHARSET |
| 18 | +from segwit_addr import bech32_encode, decode_segwit_address, convertbits, CHARSET |
20 | 19 |
|
21 | 20 | # key types
|
22 | 21 | PUBKEY_ADDRESS = 0
|
@@ -109,7 +108,7 @@ def is_valid(v):
|
109 | 108 | def is_valid_bech32(v):
|
110 | 109 | '''Check vector v for bech32 validity'''
|
111 | 110 | for hrp in ['bc', 'tb', 'bcrt']:
|
112 |
| - if decode(hrp, v) != (None, None): |
| 111 | + if decode_segwit_address(hrp, v) != (None, None): |
113 | 112 | return True
|
114 | 113 | return False
|
115 | 114 |
|
@@ -141,9 +140,7 @@ def gen_valid_vectors():
|
141 | 140 | rv, payload = valid_vector_generator(template)
|
142 | 141 | assert is_valid(rv)
|
143 | 142 | metadata = {x: y for x, y in zip(metadata_keys,template[3]) if y is not None}
|
144 |
| - hexrepr = b2a_hex(payload) |
145 |
| - if isinstance(hexrepr, bytes): |
146 |
| - hexrepr = hexrepr.decode('utf8') |
| 143 | + hexrepr = payload.hex() |
147 | 144 | yield (rv, hexrepr, metadata)
|
148 | 145 |
|
149 | 146 | def gen_invalid_base58_vector(template):
|
|
0 commit comments