Skip to content

Commit d178082

Browse files
committed
test: add bech32 decoding support to address_to_scriptpubkey()
This permits functional tests to decode bech32 addresses to scriptpubkeys.
1 parent aac8793 commit d178082

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

test/functional/test_framework/wallet.py

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
)
1515
from test_framework.address import (
1616
base58_to_byte,
17+
bech32_to_bytes,
1718
create_deterministic_address_bcrt1_p2tr_op_true,
1819
key_to_p2pkh,
1920
key_to_p2sh_p2wpkh,
@@ -49,6 +50,7 @@
4950
key_to_p2sh_p2wpkh_script,
5051
key_to_p2wpkh_script,
5152
keyhash_to_p2pkh_script,
53+
program_to_witness_script,
5254
scripthash_to_p2sh_script,
5355
)
5456
from test_framework.util import (
@@ -414,6 +416,9 @@ def getnewdestination(address_type='bech32m'):
414416

415417
def address_to_scriptpubkey(address):
416418
"""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
417422
payload, version = base58_to_byte(address)
418423
if version == 111: # testnet pubkey hash
419424
return keyhash_to_p2pkh_script(payload)

0 commit comments

Comments
 (0)