aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/blocktools.py
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-06-15 23:02:28 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2021-06-21 14:28:05 +0200
commit2ce7b47958c4a10ba20dc86c011d71cda4b070a5 (patch)
tree9d3ad9433f7b5b054f5b072ebf33462399d9f502 /test/functional/test_framework/blocktools.py
parent965e93743454112c0c3c66bf24852f63ee07b862 (diff)
test: introduce `tx_from_hex` helper for tx deserialization
`FromHex` is mostly used for transactions, so we introduce a shortcut `tx_from_hex` for `FromHex(CTransaction, hex_str)`.
Diffstat (limited to 'test/functional/test_framework/blocktools.py')
-rw-r--r--test/functional/test_framework/blocktools.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py
index f35ea6c122..0019b7a426 100644
--- a/test/functional/test_framework/blocktools.py
+++ b/test/functional/test_framework/blocktools.py
@@ -23,12 +23,12 @@ 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 (
@@ -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):
@@ -248,7 +248,7 @@ 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)