Skip to content

Commit 0c41fc3

Browse files
committed
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
1 parent ff7d205 commit 0c41fc3

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

test/functional/test_framework/script_util.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""Useful Script constants and utils."""
66
from test_framework.script import (
77
CScript,
8-
CScriptOp,
98
OP_0,
109
OP_CHECKMULTISIG,
1110
OP_CHECKSIG,
@@ -49,10 +48,8 @@ def keys_to_multisig_script(keys, *, k=None):
4948
if k is None: # n-of-n multisig by default
5049
k = n
5150
assert k <= n
52-
op_k = CScriptOp.encode_op_n(k)
53-
op_n = CScriptOp.encode_op_n(n)
5451
checked_keys = [check_key(key) for key in keys]
55-
return CScript([op_k] + checked_keys + [op_n, OP_CHECKMULTISIG])
52+
return CScript([k] + checked_keys + [n, OP_CHECKMULTISIG])
5653

5754

5855
def keyhash_to_p2pkh_script(hash):

0 commit comments

Comments
 (0)