diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2023-08-22 03:06:15 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2024-06-05 16:15:17 +0200 |
commit | 0c41fc3fa52ad16923afbd0ec18b9c1b3ded8036 (patch) | |
tree | 58ea8871ab1ca28baa9e0c8cd03fb768416d213a /test/functional/test_framework | |
parent | ff7d2054c4f1d7ff98078b9695e7c36e79a476c6 (diff) |
test: fix `keys_to_multisig_script` (P2MS) helper for n/k > 16
The helper assumes that the n and k values have to be provided as a
single byte push operation, which is only possible for values up to 16.
Fix that by passing the numbers directly to the CScript list, where it's
automatically converted to minimally-encoded pushes (see class
method `CScript.__coerce_instance`, branch `isinstance(other, int)`).
In case of 17..20, this means that the data-pushes are done with two
bytes using OP_PUSH1 (0x01), e.g. for n=20: 0x01,0x14
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-x | test/functional/test_framework/script_util.py | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/test/functional/test_framework/script_util.py b/test/functional/test_framework/script_util.py index 62894cc0f4..ee8199c2da 100755 --- a/test/functional/test_framework/script_util.py +++ b/test/functional/test_framework/script_util.py @@ -5,7 +5,6 @@ """Useful Script constants and utils.""" from test_framework.script import ( CScript, - CScriptOp, OP_0, OP_CHECKMULTISIG, OP_CHECKSIG, @@ -49,10 +48,8 @@ def keys_to_multisig_script(keys, *, k=None): if k is None: # n-of-n multisig by default k = n assert k <= n - op_k = CScriptOp.encode_op_n(k) - op_n = CScriptOp.encode_op_n(n) checked_keys = [check_key(key) for key in keys] - return CScript([op_k] + checked_keys + [op_n, OP_CHECKMULTISIG]) + return CScript([k] + checked_keys + [n, OP_CHECKMULTISIG]) def keyhash_to_p2pkh_script(hash): |