diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2021-07-31 21:23:16 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2021-08-01 19:26:51 +0200 |
commit | ca6c154ef116e8d2e0484cdb1af13b34a0c86c17 (patch) | |
tree | 4b38a878a5b2fd0f49a2cc0b0e1948b8119b40e9 /test/functional/test_framework/script_util.py | |
parent | f2e41d11097dde1c841bcaa8615886c984f71632 (diff) |
test: refactor: remove `hex_str_to_bytes` helper
Use the built-in class method bytes.fromhex() instead,
which is available since Python 3.0.
Diffstat (limited to 'test/functional/test_framework/script_util.py')
-rwxr-xr-x | test/functional/test_framework/script_util.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/test/functional/test_framework/script_util.py b/test/functional/test_framework/script_util.py index 457be6b0e6..5d1d7ea45c 100755 --- a/test/functional/test_framework/script_util.py +++ b/test/functional/test_framework/script_util.py @@ -4,7 +4,6 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Useful Script constants and utils.""" from test_framework.script import CScript, hash160, sha256, OP_0, OP_DUP, OP_HASH160, OP_CHECKSIG, OP_EQUAL, OP_EQUALVERIFY -from test_framework.util import hex_str_to_bytes # To prevent a "tx-size-small" policy rule error, a transaction has to have a # non-witness size of at least 82 bytes (MIN_STANDARD_TX_NONWITNESS_SIZE in @@ -49,7 +48,7 @@ def key_to_p2sh_p2wpkh_script(key, main = False): def program_to_witness_script(version, program, main = False): if isinstance(program, str): - program = hex_str_to_bytes(program) + program = bytes.fromhex(program) assert 0 <= version <= 16 assert 2 <= len(program) <= 40 assert version > 0 or len(program) in [20, 32] @@ -70,14 +69,14 @@ def script_to_p2sh_p2wsh_script(script, main = False): def check_key(key): if isinstance(key, str): - key = hex_str_to_bytes(key) # Assuming this is hex string + key = bytes.fromhex(key) # Assuming this is hex string if isinstance(key, bytes) and (len(key) == 33 or len(key) == 65): return key assert False def check_script(script): if isinstance(script, str): - script = hex_str_to_bytes(script) # Assuming this is hex string + script = bytes.fromhex(script) # Assuming this is hex string if isinstance(script, bytes) or isinstance(script, CScript): return script assert False |