aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorismaelsadeeq <ask4ismailsadiq@gmail.com>2023-03-23 12:00:54 +0100
committerismaelsadeeq <ask4ismailsadiq@gmail.com>2023-03-23 12:00:54 +0100
commitd178082996dc3000f42816f89afcf3fa4d31e159 (patch)
treea0e5c232bb29a0dafb43519cf487295bd294515a /test
parentaac8793c7a2ee7630641dd74be6ba2ead50c2aee (diff)
downloadbitcoin-d178082996dc3000f42816f89afcf3fa4d31e159.tar.xz
test: add bech32 decoding support to address_to_scriptpubkey()
This permits functional tests to decode bech32 addresses to scriptpubkeys.
Diffstat (limited to 'test')
-rw-r--r--test/functional/test_framework/wallet.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py
index f3253630c4..eab8fbda47 100644
--- a/test/functional/test_framework/wallet.py
+++ b/test/functional/test_framework/wallet.py
@@ -14,6 +14,7 @@ from typing import (
)
from test_framework.address import (
base58_to_byte,
+ bech32_to_bytes,
create_deterministic_address_bcrt1_p2tr_op_true,
key_to_p2pkh,
key_to_p2sh_p2wpkh,
@@ -49,6 +50,7 @@ from test_framework.script_util import (
key_to_p2sh_p2wpkh_script,
key_to_p2wpkh_script,
keyhash_to_p2pkh_script,
+ program_to_witness_script,
scripthash_to_p2sh_script,
)
from test_framework.util import (
@@ -414,6 +416,9 @@ def getnewdestination(address_type='bech32m'):
def address_to_scriptpubkey(address):
"""Converts a given address to the corresponding output script (scriptPubKey)."""
+ version, payload = bech32_to_bytes(address)
+ if version is not None:
+ return program_to_witness_script(version, payload) # testnet segwit scriptpubkey
payload, version = base58_to_byte(address)
if version == 111: # testnet pubkey hash
return keyhash_to_p2pkh_script(payload)