bitcoin/test/functional/test_framework
Ava Chow 76a33be21d
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:
    ACK 2451a217dd
  theStack:
    Code-review ACK 2451a217dd
  achow101:
    ACK 2451a217dd

Tree-SHA512: 71794533cbd46b3a1079fb4e9d190d3ea3b615de0cbfa443466e14f05e4616ca90e12ce2bf07113515ea8113e64a560ad572bb9ea9d4835b6fb67b6ae596167f
2024-06-04 21:39:49 -04:00
..
crypto crypto: add NUMS_H const 2024-05-14 10:24:31 +02:00
__init__.py Rename rpc-tests directory to functional 2017-03-20 10:40:31 -04:00
address.py test: add MiniWallet tagging support to avoid UTXO mixing 2024-05-05 12:33:34 +02:00
authproxy.py rpc: JSON-RPC 2.0 should not respond to "notifications" 2024-05-14 11:28:43 -04:00
bdb.py scripted-diff: Bump copyright headers 2021-11-10 11:10:24 +01:00
bip340_test_vectors.csv tests: add BIP340 Schnorr signature support to test framework 2020-10-12 17:18:47 -07:00
blockfilter.py Merge bitcoin/bitcoin#28605: Fix typos 2023-11-16 10:35:49 +00:00
blocktools.py [test]: remove duplicate WITNESS_SCALE_FACTOR 2024-05-03 10:30:50 +01:00
coverage.py test: fix PEP484 no implicit optional argument types errors 2023-06-29 16:14:07 -06:00
descriptors.py Output a descriptor in createmultisig and addmultisigaddress 2020-01-30 23:55:36 -05:00
key.py Merge bitcoin/bitcoin#28374: test: python cryptography required for BIP 324 functional tests 2023-11-07 16:48:57 -05:00
mempool_util.py test: use tagged ephemeral MiniWallet instance in fill_mempool 2024-05-05 12:36:51 +02:00
messages.py test: p2p: check disconnect due to lack of desirable service flags 2024-03-11 15:23:09 +01:00
netutil.py test: cover UNIX sockets in feature_proxy.py 2024-03-01 14:47:29 -05:00
p2p.py test: Extends wait_for_getheaders so a specific block hash can be checked 2024-04-04 13:36:45 +02:00
psbt.py test: PSBT: eliminate magic numbers for global unsigned tx key (0) 2023-03-04 12:43:38 +01:00
script.py test: fix accurate multisig sigop count (BIP16), add unit test 2024-03-10 20:21:48 +01:00
script_util.py scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
segwit_addr.py Use Bech32m encoding for v1+ segwit addresses 2021-03-16 10:48:36 -07:00
socks5.py test: add keep_alive option to socks5 proxy in test_framework 2023-07-10 10:07:45 -04:00
test_framework.py Merge bitcoin/bitcoin#28307: rpc, wallet: fix incorrect segwit redeem script size limit 2024-06-04 21:39:49 -04:00
test_node.py Merge bitcoin/bitcoin#30118: test: improve robustness of connect_nodes() 2024-05-23 10:00:00 -04:00
test_shell.py scripted-diff: Bump copyright headers 2022-12-24 23:49:50 +00:00
util.py test: refactor: move fill_mempool to new module mempool_util 2024-05-05 12:33:30 +02:00
v2_p2p.py [test] make v2transport arg in addconnection mandatory and few cleanups 2024-01-31 22:37:54 +05:30
wallet.py test: add MiniWallet tagging support to avoid UTXO mixing 2024-05-05 12:33:34 +02:00
wallet_util.py Fix typos in description.md and wallet_util.py 2024-04-25 16:14:10 +08:00