|
|
@ -13,7 +13,7 @@ from lib.bitcoin import ( |
|
|
|
bip32_root, bip32_public_derivation, bip32_private_derivation, pw_encode, |
|
|
|
pw_decode, Hash, public_key_from_private_key, address_from_private_key, |
|
|
|
is_address, is_private_key, xpub_from_xprv, is_new_seed, is_old_seed, |
|
|
|
var_int, op_push) |
|
|
|
var_int, op_push, address_to_script) |
|
|
|
from lib.util import bfh |
|
|
|
|
|
|
|
try: |
|
|
@ -155,6 +155,23 @@ class Test_bitcoin(unittest.TestCase): |
|
|
|
self.assertEqual(op_push(0x10000), '4e00000100') |
|
|
|
self.assertEqual(op_push(0x12345678), '4e78563412') |
|
|
|
|
|
|
|
# TODO testnet addresses |
|
|
|
def test_address_to_script(self): |
|
|
|
# bech32 native segwit |
|
|
|
# test vectors from BIP-0173 |
|
|
|
self.assertEqual(address_to_script('BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4'), '0014751e76e8199196d454941c45d1b3a323f1433bd6') |
|
|
|
self.assertEqual(address_to_script('bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx'), '5128751e76e8199196d454941c45d1b3a323f1433bd6751e76e8199196d454941c45d1b3a323f1433bd6') |
|
|
|
self.assertEqual(address_to_script('BC1SW50QA3JX3S'), '6002751e') |
|
|
|
self.assertEqual(address_to_script('bc1zw508d6qejxtdg4y5r3zarvaryvg6kdaj'), '5210751e76e8199196d454941c45d1b3a323') |
|
|
|
|
|
|
|
# base58 P2PKH |
|
|
|
self.assertEqual(address_to_script('14gcRovpkCoGkCNBivQBvw7eso7eiNAbxG'), '76a91428662c67561b95c79d2257d2a93d9d151c977e9188ac') |
|
|
|
self.assertEqual(address_to_script('1BEqfzh4Y3zzLosfGhw1AsqbEKVW6e1qHv'), '76a914704f4b81cadb7bf7e68c08cd3657220f680f863c88ac') |
|
|
|
|
|
|
|
# base58 P2SH |
|
|
|
self.assertEqual(address_to_script('35ZqQJcBQMZ1rsv8aSuJ2wkC7ohUCQMJbT'), 'a9142a84cf00d47f699ee7bbc1dea5ec1bdecb4ac15487') |
|
|
|
self.assertEqual(address_to_script('3PyjzJ3im7f7bcV724GR57edKDqoZvH7Ji'), 'a914f47c8954e421031ad04ecd8e7752c9479206b9d387') |
|
|
|
|
|
|
|
|
|
|
|
class Test_keyImport(unittest.TestCase): |
|
|
|
""" The keys used in this class are TEST keys from |
|
|
|