mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-04 04:32:20 +02:00
Merge bitcoin/bitcoin#28307: rpc, wallet: fix incorrect segwit redeem script size limit
2451a217dd
test: addmultisigaddress, coverage for script size limits (furszy)53302a0981
bugfix: addmultisigaddress, add unsupported operation for redeem scripts over 520 bytes (furszy)9be6065cc0
test: coverage for 16-20 segwit multisig scripts (furszy)9d9a91c4ea
rpc: bugfix, incorrect segwit redeem script size used in signrawtransactionwithkey (furszy)0c9fedfc45
fix incorrect multisig redeem script size limit for segwit (furszy)f7a173b578
test: rpc_createmultisig, decouple 'test_sortedmulti_descriptors_bip67' (furszy)4f33dbd8f8
test: rpc_createmultisig, decouple 'test_mixing_uncompressed_and_compressed_keys' (furszy)25a81705d3
test: rpc_createmultisig, remove unnecessary checkbalances() (furszy)b5a3289433
test: refactor, multiple cleanups in rpc_createmultisig.py (furszy)3635d43268
test: rpc_createmultisig, remove manual wallet initialization (furszy) Pull request description: Fixing https://github.com/bitcoin/bitcoin/issues/28250#issuecomment-1674830104 and more. Currently, redeem scripts longer than 520 bytes, which are technically valid under segwit rules, have flaws in the following processes: 1) 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. 2) The `signrawtransactionwithkey` RPC command fail to sign them. 3) 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](ded6873340/src/script/signingprovider.cpp (L160)
) 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: 1) 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. 2) 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. ACKs for top commit: pinheadmz: ACK2451a217dd
theStack: Code-review ACK2451a217dd
achow101: ACK2451a217dd
Tree-SHA512: 71794533cbd46b3a1079fb4e9d190d3ea3b615de0cbfa443466e14f05e4616ca90e12ce2bf07113515ea8113e64a560ad572bb9ea9d4835b6fb67b6ae596167f
This commit is contained in:
@ -444,6 +444,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
n.createwallet(wallet_name=wallet_name, descriptors=self.options.descriptors, load_on_startup=True)
|
||||
n.importprivkey(privkey=n.get_deterministic_priv_key().key, label='coinbase', rescan=True)
|
||||
|
||||
# Only enables wallet support when the module is available
|
||||
def enable_wallet_if_possible(self):
|
||||
self._requires_wallet = self.is_wallet_compiled()
|
||||
|
||||
def run_test(self):
|
||||
"""Tests must override this method to define test logic"""
|
||||
raise NotImplementedError
|
||||
|
Reference in New Issue
Block a user