Skip to content

Commit 2451a21

Browse files
committed
test: addmultisigaddress, coverage for script size limits
1 parent 53302a0 commit 2451a21

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/functional/rpc_createmultisig.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def run_test(self):
6262
for output_type in ["bech32", "p2sh-segwit", "legacy"]:
6363
self.do_multisig(keys, sigs, output_type, wallet_multi)
6464

65-
self.test_multisig_script_limit()
65+
self.test_multisig_script_limit(wallet_multi)
6666
self.test_mixing_uncompressed_and_compressed_keys(node0, wallet_multi)
6767
self.test_sortedmulti_descriptors_bip67()
6868

@@ -84,7 +84,7 @@ def check_addmultisigaddress_errors(self):
8484
pubs = [self.nodes[1].getaddressinfo(addr)["pubkey"] for addr in addresses]
8585
assert_raises_rpc_error(-5, "Bech32m multisig addresses cannot be created with legacy wallets", self.nodes[0].addmultisigaddress, 2, pubs, "", "bech32m")
8686

87-
def test_multisig_script_limit(self):
87+
def test_multisig_script_limit(self, wallet_multi):
8888
node1 = self.nodes[1]
8989
pubkeys = self.pub[0:20]
9090

@@ -99,6 +99,17 @@ def test_multisig_script_limit(self):
9999
assert_raises_rpc_error(-8, "Number of keys involved in the multisignature address creation > 20", node1.createmultisig, 16, self.pub, 'p2sh-segwit')
100100
assert_raises_rpc_error(-8, "Number of keys involved in the multisignature address creation > 20", node1.createmultisig, 16, self.pub, 'bech32')
101101

102+
# Check legacy wallet related command
103+
self.log.info('Test legacy redeem script max size limit (with wallet)')
104+
if wallet_multi is not None and not self.options.descriptors:
105+
assert_raises_rpc_error(-8, "redeemScript exceeds size limit: 684 > 520", wallet_multi.addmultisigaddress, 16, pubkeys, '', 'legacy')
106+
107+
self.log.info('Test legacy wallet unsupported operation. 16-20 multisig p2sh-legacy and bech32 generation')
108+
# Due an internal limitation on legacy wallets, the redeem script limit also applies to p2sh-segwit and bech32 (even when the scripts are valid)
109+
# We take this as a "good thing" to tell users to upgrade to descriptors.
110+
assert_raises_rpc_error(-4, "Unsupported multisig script size for legacy wallet. Upgrade to descriptors to overcome this limitation for p2sh-segwit or bech32 scripts", wallet_multi.addmultisigaddress, 16, pubkeys, '', 'p2sh-segwit')
111+
assert_raises_rpc_error(-4, "Unsupported multisig script size for legacy wallet. Upgrade to descriptors to overcome this limitation for p2sh-segwit or bech32 scripts", wallet_multi.addmultisigaddress, 16, pubkeys, '', 'bech32')
112+
102113
def do_multisig(self, nkeys, nsigs, output_type, wallet_multi):
103114
node0, node1, node2 = self.nodes
104115
pub_keys = self.pub[0: nkeys]

0 commit comments

Comments
 (0)