diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2021-06-15 23:02:28 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2021-06-21 14:28:05 +0200 |
commit | 2ce7b47958c4a10ba20dc86c011d71cda4b070a5 (patch) | |
tree | 9d3ad9433f7b5b054f5b072ebf33462399d9f502 /test/functional/test_framework/messages.py | |
parent | 965e93743454112c0c3c66bf24852f63ee07b862 (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/messages.py')
-rwxr-xr-x | test/functional/test_framework/messages.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 3d79174356..43c80fa7a8 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -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 |