mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-02 00:38:15 +01:00
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)`.
This commit is contained in:
@@ -195,10 +195,17 @@ def FromHex(obj, hex_string):
|
||||
obj.deserialize(BytesIO(hex_str_to_bytes(hex_string)))
|
||||
return obj
|
||||
|
||||
|
||||
# Convert a binary-serializable object to hex (eg for submission via RPC)
|
||||
def ToHex(obj):
|
||||
return obj.serialize().hex()
|
||||
|
||||
|
||||
def tx_from_hex(hex_string):
|
||||
"""Deserialize from hex string to a transaction object"""
|
||||
return FromHex(CTransaction(), hex_string)
|
||||
|
||||
|
||||
# Objects that map to bitcoind objects, which can be serialized/deserialized
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user