Changeset View
Changeset View
Standalone View
Standalone View
contrib/testgen/gen_base58_test_vectors.py
#!/usr/bin/env python | #!/usr/bin/env python | ||||
# Copyright (c) 2012-2016 The Bitcoin Core developers | # Copyright (c) 2012-2016 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
''' | ''' | ||||
Generate valid and invalid base58 address and private key test vectors. | Generate valid and invalid base58 address and private key test vectors. | ||||
Usage: | Usage: | ||||
gen_base58_test_vectors.py valid 50 > ../../src/test/data/base58_keys_valid.json | gen_base58_test_vectors.py valid 50 > ../../src/test/data/base58_keys_valid.json | ||||
gen_base58_test_vectors.py invalid 50 > ../../src/test/data/base58_keys_invalid.json | gen_base58_test_vectors.py invalid 50 > ../../src/test/data/base58_keys_invalid.json | ||||
''' | ''' | ||||
# 2012 Wladimir J. van der Laan | # 2012 Wladimir J. van der Laan | ||||
# Released under MIT License | # Released under MIT License | ||||
import os | import os | ||||
from itertools import islice | from itertools import islice | ||||
from base58 import b58encode, b58decode, b58encode_chk, b58decode_chk, b58chars | from base58 import b58encode_chk, b58decode_chk, b58chars | ||||
import random | import random | ||||
from binascii import b2a_hex | from binascii import b2a_hex | ||||
# key types | # key types | ||||
PUBKEY_ADDRESS = 0 | PUBKEY_ADDRESS = 0 | ||||
SCRIPT_ADDRESS = 5 | SCRIPT_ADDRESS = 5 | ||||
PUBKEY_ADDRESS_TEST = 111 | PUBKEY_ADDRESS_TEST = 111 | ||||
SCRIPT_ADDRESS_TEST = 196 | SCRIPT_ADDRESS_TEST = 196 | ||||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |