aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/blocktools.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/test_framework/blocktools.py')
-rw-r--r--test/functional/test_framework/blocktools.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py
index e91b44e776..833a215993 100644
--- a/test/functional/test_framework/blocktools.py
+++ b/test/functional/test_framework/blocktools.py
@@ -23,25 +23,25 @@ from .messages import (
CTxIn,
CTxInWitness,
CTxOut,
- FromHex,
- ToHex,
hash256,
hex_str_to_bytes,
ser_uint256,
- sha256,
+ tx_from_hex,
uint256_from_str,
)
from .script import (
CScript,
CScriptNum,
CScriptOp,
- OP_0,
OP_1,
OP_CHECKMULTISIG,
OP_CHECKSIG,
OP_RETURN,
OP_TRUE,
- hash160,
+)
+from .script_util import (
+ key_to_p2wpkh_script,
+ script_to_p2wsh_script,
)
from .util import assert_equal
@@ -79,7 +79,7 @@ def create_block(hashprev=None, coinbase=None, ntime=None, *, version=None, tmpl
if txlist:
for tx in txlist:
if not hasattr(tx, 'calc_sha256'):
- tx = FromHex(CTransaction(), tx)
+ tx = tx_from_hex(tx)
block.vtx.append(tx)
block.hashMerkleRoot = block.calc_merkle_root()
block.calc_sha256()
@@ -166,7 +166,7 @@ def create_transaction(node, txid, to_address, *, amount):
sign for the output that is being spent.
"""
raw_tx = create_raw_transaction(node, txid, to_address, amount=amount)
- tx = FromHex(CTransaction(), raw_tx)
+ tx = tx_from_hex(raw_tx)
return tx
def create_raw_transaction(node, txid, to_address, *, amount):
@@ -207,13 +207,11 @@ def witness_script(use_p2wsh, pubkey):
scriptPubKey."""
if not use_p2wsh:
# P2WPKH instead
- pubkeyhash = hash160(hex_str_to_bytes(pubkey))
- pkscript = CScript([OP_0, pubkeyhash])
+ pkscript = key_to_p2wpkh_script(pubkey)
else:
# 1-of-1 multisig
witness_program = CScript([OP_1, hex_str_to_bytes(pubkey), OP_1, OP_CHECKMULTISIG])
- scripthash = sha256(witness_program)
- pkscript = CScript([OP_0, scripthash])
+ pkscript = script_to_p2wsh_script(witness_program)
return pkscript.hex()
def create_witness_tx(node, use_p2wsh, utxo, pubkey, encode_p2sh, amount):
@@ -243,9 +241,9 @@ def send_to_witness(use_p2wsh, node, utxo, pubkey, encode_p2sh, amount, sign=Tru
return node.sendrawtransaction(signed["hex"])
else:
if (insert_redeem_script):
- tx = FromHex(CTransaction(), tx_to_witness)
+ tx = tx_from_hex(tx_to_witness)
tx.vin[0].scriptSig += CScript([hex_str_to_bytes(insert_redeem_script)])
- tx_to_witness = ToHex(tx)
+ tx_to_witness = tx.serialize().hex()
return node.sendrawtransaction(tx_to_witness)