|
12 | 12 | from test_framework.descriptors import descsum_create, drop_origins
|
13 | 13 | from test_framework.key import ECPubKey
|
14 | 14 | from test_framework.messages import COIN
|
| 15 | +from test_framework.script_util import keys_to_multisig_script |
15 | 16 | from test_framework.test_framework import BitcoinTestFramework
|
16 | 17 | from test_framework.util import (
|
17 | 18 | assert_raises_rpc_error,
|
@@ -69,6 +70,16 @@ def run_test(self):
|
69 | 70 | # Check that bech32m is currently not allowed
|
70 | 71 | assert_raises_rpc_error(-5, "createmultisig cannot create bech32m multisig addresses", self.nodes[0].createmultisig, 2, self.pub, "bech32m")
|
71 | 72 |
|
| 73 | + self.log.info('Check correct encoding of multisig script for all n (1..20)') |
| 74 | + for nkeys in range(1, 20+1): |
| 75 | + keys = [self.pub[0]]*nkeys |
| 76 | + expected_ms_script = keys_to_multisig_script(keys, k=nkeys) # simply use n-of-n |
| 77 | + # note that the 'legacy' address type fails for n values larger than 15 |
| 78 | + # due to exceeding the P2SH size limit (520 bytes), so we use 'bech32' instead |
| 79 | + # (for the purpose of this encoding test, we don't care about the resulting address) |
| 80 | + res = self.nodes[0].createmultisig(nrequired=nkeys, keys=keys, address_type='bech32') |
| 81 | + assert_equal(res['redeemScript'], expected_ms_script.hex()) |
| 82 | + |
72 | 83 | def check_addmultisigaddress_errors(self):
|
73 | 84 | if self.options.descriptors:
|
74 | 85 | return
|
|
0 commit comments