Fixing #28250 (comment) and more.
Currently, redeem scripts longer than 520 bytes, which are technically valid under segwit rules, have flaws in the following processes:
- The multisig creation process fails to deduce the output descriptor, resulting in the generation of an incorrect descriptor. Additionally, the accompanying user warning is also inaccurate.
- The
signrawtransactionwithkey
RPC command fail to sign them. - The legacy wallet
addmultisigaddress
wrongly discards them.
The issue arises because most of these flows are utilizing the legacy spkm keystore, which imposes
the p2sh max redeem script size rule on all scripts. Which blocks segwit redeem scripts longer than
the max element size in all the previously mentioned processes (createmultisig
, addmultisigaddress
, and
signrawtransactionwithkey
).
This PR fixes the problem, enabling the creation of multisig output descriptors involving more than 15 keys and allowing the signing of these scripts, along with other post-segwit redeem scripts that surpass the 520-byte p2sh limit.
Important note: Instead of adding support for these longer redeem scripts in the legacy wallet, an “unsupported operation” error has been added. The reasons behind this decision are:
-
The introduction of this feature brings about a compatibility-breaking change that requires downgrade protection; older wallets would be unable to interact with these “new” legacy wallets.
-
Considering the ongoing deprecation of the legacy spkm, this issue provides another compelling reason to transition towards descriptors.
Testing notes:
To easily verify each of the fixes, I decoupled the tests into standalone commits. So they can be
cherry-picked on top of master. Where rpc_createmultisig.py
(with and without the --legacy-wallet
arg) will fail without the bugs fixes commits.
Extra note:
The initial commits improves the rpc_createmultisig.py
test in many ways. I found this test very
antiquated, screaming for an update and cleanup.