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

@ -8,6 +8,7 @@ from test_framework.blocktools import (
COINBASE_MATURITY,
)
from test_framework.address import (
address_to_scriptpubkey,
script_to_p2sh,
)
from test_framework.key import ECKey
@ -118,7 +119,7 @@ class SignRawTransactionWithKeyTest(BitcoinTestFramework):
}.get(tx_type, "Invalid tx_type")
redeem_script = script_to_p2wsh_script(witness_script).hex()
addr = script_to_p2sh(redeem_script)
script_pub_key = self.nodes[1].validateaddress(addr)['scriptPubKey']
script_pub_key = address_to_scriptpubkey(addr).hex()
# Fund that address
txid = self.send_to_address(addr, 10)
vout = find_vout_for_address(self.nodes[0], txid, addr)