|
13 | 13 | Optional, |
14 | 14 | ) |
15 | 15 | from test_framework.address import ( |
16 | | - base58_to_byte, |
17 | | - bech32_to_bytes, |
| 16 | + address_to_scriptpubkey, |
18 | 17 | create_deterministic_address_bcrt1_p2tr_op_true, |
19 | 18 | key_to_p2pkh, |
20 | 19 | key_to_p2sh_p2wpkh, |
|
49 | 48 | key_to_p2pkh_script, |
50 | 49 | key_to_p2sh_p2wpkh_script, |
51 | 50 | key_to_p2wpkh_script, |
52 | | - keyhash_to_p2pkh_script, |
53 | | - program_to_witness_script, |
54 | | - scripthash_to_p2sh_script, |
55 | 51 | ) |
56 | 52 | from test_framework.util import ( |
57 | 53 | assert_equal, |
@@ -101,7 +97,7 @@ def __init__(self, test_node, *, mode=MiniWalletMode.ADDRESS_OP_TRUE): |
101 | 97 | self._scriptPubKey = key_to_p2pk_script(pub_key.get_bytes()) |
102 | 98 | elif mode == MiniWalletMode.ADDRESS_OP_TRUE: |
103 | 99 | self._address, self._internal_key = create_deterministic_address_bcrt1_p2tr_op_true() |
104 | | - self._scriptPubKey = bytes.fromhex(self._test_node.validateaddress(self._address)['scriptPubKey']) |
| 100 | + self._scriptPubKey = address_to_scriptpubkey(self._address) |
105 | 101 |
|
106 | 102 | # When the pre-mined test framework chain is used, it contains coinbase |
107 | 103 | # outputs to the MiniWallet's default address in blocks 76-100 |
@@ -412,18 +408,3 @@ def getnewdestination(address_type='bech32m'): |
412 | 408 | else: |
413 | 409 | assert False |
414 | 410 | return pubkey, scriptpubkey, address |
415 | | - |
416 | | - |
417 | | -def address_to_scriptpubkey(address): |
418 | | - """Converts a given address to the corresponding output script (scriptPubKey).""" |
419 | | - version, payload = bech32_to_bytes(address) |
420 | | - if version is not None: |
421 | | - return program_to_witness_script(version, payload) # testnet segwit scriptpubkey |
422 | | - payload, version = base58_to_byte(address) |
423 | | - if version == 111: # testnet pubkey hash |
424 | | - return keyhash_to_p2pkh_script(payload) |
425 | | - elif version == 196: # testnet script hash |
426 | | - return scripthash_to_p2sh_script(payload) |
427 | | - # TODO: also support other address formats |
428 | | - else: |
429 | | - assert False |
0 commit comments