refactor: use address_to_scriptpubkey to retrieve addresses scriptpubkey

This commit updates the code by replacing the RPC call used to
decode an address and retrieve its corresponding scriptpubkey
with the address_to_scriptpubkey function. address_to_scriptpubkey
function can now decode all addresses formats, which makes
it more efficient to use.
This commit is contained in:
ismaelsadeeq
2023-03-28 16:58:16 +01:00
parent 4142d19d74
commit e47ce42f67
8 changed files with 16 additions and 8 deletions

View File

@ -7,6 +7,7 @@
import os
from typing import List
from test_framework.address import address_to_scriptpubkey
from test_framework.descriptors import descsum_create
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_node import TestNode
@ -58,7 +59,7 @@ class WalletFastRescanTest(BitcoinTestFramework):
if 'range' in desc_info:
start_range, end_range = desc_info['range']
addr = w.deriveaddresses(desc_info['desc'], [end_range, end_range])[0]
spk = bytes.fromhex(w.getaddressinfo(addr)['scriptPubKey'])
spk = address_to_scriptpubkey(addr)
self.log.info(f"-> range [{start_range},{end_range}], last address {addr}")
else:
spk = bytes.fromhex(fixed_key.p2wpkh_script)