aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-05-03 12:11:04 +0800
committerfanquake <fanquake@gmail.com>2021-05-03 12:44:23 +0800
commit60132382a74506f34d3c7b0b162799772505608c (patch)
tree51d3d59e39ca993873c28b455876c32ca67f920b /test/functional
parent2448457cca1858c2fcf3dfcb53de3f388ea72079 (diff)
parentebd4be43cc945e643f91d3a91007b5a35bbbd5a1 (diff)
downloadbitcoin-60132382a74506f34d3c7b0b162799772505608c.tar.xz
Merge bitcoin/bitcoin#20867: Support up to 20 keys for multisig under Segwit context
ebd4be43cc945e643f91d3a91007b5a35bbbd5a1 doc: add release notes for 20867 (Antoine Poinsot) 5aa50ab9cc7994b16cf13e4c73af80f0098f1bea rpc/util: multisig: only check redeemScript size is <= 520 for P2SH (Antoine Poinsot) 063df9e89730fd2c92646577e2fab894e1692130 test/functional: standardness sanity checks for P2(W)SH multisig (Antoine Poinsot) ae0429d3af6de48f6191f144dff4ad4ab672dcd6 script: allow up to 20 keys in wsh() descriptors (Antoine Poinsot) 9fc68faf35c700ae955af194dd7f8c1aee85a05b script: match multisigs with up to MAX_PUBKEYS_PER_MULTISIG keys (Antoine Poinsot) Pull request description: As described in https://github.com/bitcoin/bitcoin/issues/20620 multisigs are currently limited to 16 keys in descriptors and RPC helpers, even for P2WSH and P2SH-P2WSH. This adds support for multisig with up to 20 keys (which are already standard) for Segwit v0 context for descriptors (`wsh()`, `sh(wsh())`) and RPC helpers. Fixes https://github.com/bitcoin/bitcoin/issues/20620 ACKs for top commit: meshcollider: re-utACK ebd4be43cc945e643f91d3a91007b5a35bbbd5a1 instagibbs: re-ACK https://github.com/bitcoin/bitcoin/pull/20867/commits/ebd4be43cc945e643f91d3a91007b5a35bbbd5a1 Tree-SHA512: 36141f10a8288010d17d5c4fe8d24878bcd4533b88a8aba3a44fa8f74ceb3182d70fee01427e0ab7f53ce7fab46c88c1cd3ac3b18ab8a10bd4a6b8b74ed79e46
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/wallet_importdescriptors.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/test/functional/wallet_importdescriptors.py b/test/functional/wallet_importdescriptors.py
index ed62ef0e9d..0a3dd56620 100755
--- a/test/functional/wallet_importdescriptors.py
+++ b/test/functional/wallet_importdescriptors.py
@@ -459,6 +459,77 @@ class ImportDescriptorsTest(BitcoinTestFramework):
assert_equal(tx_signed_2['complete'], True)
self.nodes[1].sendrawtransaction(tx_signed_2['hex'])
+ self.log.info("We can create and use a huge multisig under P2WSH")
+ self.nodes[1].createwallet(wallet_name='wmulti_priv_big', blank=True, descriptors=True)
+ wmulti_priv_big = self.nodes[1].get_wallet_rpc('wmulti_priv_big')
+ xkey = "tprv8ZgxMBicQKsPeZSeYx7VXDDTs3XrTcmZQpRLbAeSQFCQGgKwR4gKpcxHaKdoTNHniv4EPDJNdzA3KxRrrBHcAgth8fU5X4oCndkkxk39iAt/*"
+ xkey_int = "tprv8ZgxMBicQKsPeZSeYx7VXDDTs3XrTcmZQpRLbAeSQFCQGgKwR4gKpcxHaKdoTNHniv4EPDJNdzA3KxRrrBHcAgth8fU5X4oCndkkxk39iAt/1/*"
+ res = wmulti_priv_big.importdescriptors([
+ {
+ "desc": descsum_create(f"wsh(sortedmulti(20,{(xkey + ',') * 19}{xkey}))"),
+ "active": True,
+ "range": 1000,
+ "next_index": 0,
+ "timestamp": "now"
+ },
+ {
+ "desc": descsum_create(f"wsh(sortedmulti(20,{(xkey_int + ',') * 19}{xkey_int}))"),
+ "active": True,
+ "internal": True,
+ "range": 1000,
+ "next_index": 0,
+ "timestamp": "now"
+ }])
+ assert_equal(res[0]['success'], True)
+ assert_equal(res[1]['success'], True)
+
+ addr = wmulti_priv_big.getnewaddress()
+ w0.sendtoaddress(addr, 10)
+ self.nodes[0].generate(1)
+ self.sync_all()
+ # It is standard and would relay.
+ txid = wmulti_priv_big.sendtoaddress(w0.getnewaddress(), 9.999)
+ decoded = wmulti_priv_big.decoderawtransaction(wmulti_priv_big.gettransaction(txid)['hex'])
+ # 20 sigs + dummy + witness script
+ assert_equal(len(decoded['vin'][0]['txinwitness']), 22)
+
+
+ self.log.info("Under P2SH, multisig are standard with up to 15 "
+ "compressed keys")
+ self.nodes[1].createwallet(wallet_name='multi_priv_big_legacy',
+ blank=True, descriptors=True)
+ multi_priv_big = self.nodes[1].get_wallet_rpc('multi_priv_big_legacy')
+ res = multi_priv_big.importdescriptors([
+ {
+ "desc": descsum_create(f"sh(multi(15,{(xkey + ',') * 14}{xkey}))"),
+ "active": True,
+ "range": 1000,
+ "next_index": 0,
+ "timestamp": "now"
+ },
+ {
+ "desc": descsum_create(f"sh(multi(15,{(xkey_int + ',') * 14}{xkey_int}))"),
+ "active": True,
+ "internal": True,
+ "range": 1000,
+ "next_index": 0,
+ "timestamp": "now"
+ }])
+ assert_equal(res[0]['success'], True)
+ assert_equal(res[1]['success'], True)
+
+ addr = multi_priv_big.getnewaddress("", "legacy")
+ w0.sendtoaddress(addr, 10)
+ self.nodes[0].generate(6)
+ self.sync_all()
+ # It is standard and would relay.
+ txid = multi_priv_big.sendtoaddress(w0.getnewaddress(), 10, "", "",
+ True)
+ decoded = multi_priv_big.decoderawtransaction(
+ multi_priv_big.gettransaction(txid)['hex']
+ )
+
+
self.log.info("Combo descriptors cannot be active")
self.test_importdesc({"desc": descsum_create("combo(tpubDCJtdt5dgJpdhW4MtaVYDhG4T4tF6jcLR1PxL43q9pq1mxvXgMS9Mzw1HnXG15vxUGQJMMSqCQHMTy3F1eW5VkgVroWzchsPD5BUojrcWs8/*)"),
"active": True,