mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
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
This commit is contained in:
parent
ff7d2054c4
commit
0c41fc3fa5
1 changed files with 1 additions and 4 deletions
|
@ -5,7 +5,6 @@
|
||||||
"""Useful Script constants and utils."""
|
"""Useful Script constants and utils."""
|
||||||
from test_framework.script import (
|
from test_framework.script import (
|
||||||
CScript,
|
CScript,
|
||||||
CScriptOp,
|
|
||||||
OP_0,
|
OP_0,
|
||||||
OP_CHECKMULTISIG,
|
OP_CHECKMULTISIG,
|
||||||
OP_CHECKSIG,
|
OP_CHECKSIG,
|
||||||
|
@ -49,10 +48,8 @@ def keys_to_multisig_script(keys, *, k=None):
|
||||||
if k is None: # n-of-n multisig by default
|
if k is None: # n-of-n multisig by default
|
||||||
k = n
|
k = n
|
||||||
assert 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]
|
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):
|
def keyhash_to_p2pkh_script(hash):
|
||||||
|
|
Loading…
Add table
Reference in a new issue