Skip to content

Commit 063df9e

Browse files
committed
test/functional: standardness sanity checks for P2(W)SH multisig
Note that it also test for sortedmulti(), which the previous commit didn't. Signed-off-by: Antoine Poinsot <[email protected]>
1 parent ae0429d commit 063df9e

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

test/functional/wallet_importdescriptors.py

+71
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,77 @@ def run_test(self):
459459
assert_equal(tx_signed_2['complete'], True)
460460
self.nodes[1].sendrawtransaction(tx_signed_2['hex'])
461461

462+
self.log.info("We can create and use a huge multisig under P2WSH")
463+
self.nodes[1].createwallet(wallet_name='wmulti_priv_big', blank=True, descriptors=True)
464+
wmulti_priv_big = self.nodes[1].get_wallet_rpc('wmulti_priv_big')
465+
xkey = "tprv8ZgxMBicQKsPeZSeYx7VXDDTs3XrTcmZQpRLbAeSQFCQGgKwR4gKpcxHaKdoTNHniv4EPDJNdzA3KxRrrBHcAgth8fU5X4oCndkkxk39iAt/*"
466+
xkey_int = "tprv8ZgxMBicQKsPeZSeYx7VXDDTs3XrTcmZQpRLbAeSQFCQGgKwR4gKpcxHaKdoTNHniv4EPDJNdzA3KxRrrBHcAgth8fU5X4oCndkkxk39iAt/1/*"
467+
res = wmulti_priv_big.importdescriptors([
468+
{
469+
"desc": descsum_create(f"wsh(sortedmulti(20,{(xkey + ',') * 19}{xkey}))"),
470+
"active": True,
471+
"range": 1000,
472+
"next_index": 0,
473+
"timestamp": "now"
474+
},
475+
{
476+
"desc": descsum_create(f"wsh(sortedmulti(20,{(xkey_int + ',') * 19}{xkey_int}))"),
477+
"active": True,
478+
"internal": True,
479+
"range": 1000,
480+
"next_index": 0,
481+
"timestamp": "now"
482+
}])
483+
assert_equal(res[0]['success'], True)
484+
assert_equal(res[1]['success'], True)
485+
486+
addr = wmulti_priv_big.getnewaddress()
487+
w0.sendtoaddress(addr, 10)
488+
self.nodes[0].generate(1)
489+
self.sync_all()
490+
# It is standard and would relay.
491+
txid = wmulti_priv_big.sendtoaddress(w0.getnewaddress(), 9.999)
492+
decoded = wmulti_priv_big.decoderawtransaction(wmulti_priv_big.gettransaction(txid)['hex'])
493+
# 20 sigs + dummy + witness script
494+
assert_equal(len(decoded['vin'][0]['txinwitness']), 22)
495+
496+
497+
self.log.info("Under P2SH, multisig are standard with up to 15 "
498+
"compressed keys")
499+
self.nodes[1].createwallet(wallet_name='multi_priv_big_legacy',
500+
blank=True, descriptors=True)
501+
multi_priv_big = self.nodes[1].get_wallet_rpc('multi_priv_big_legacy')
502+
res = multi_priv_big.importdescriptors([
503+
{
504+
"desc": descsum_create(f"sh(multi(15,{(xkey + ',') * 14}{xkey}))"),
505+
"active": True,
506+
"range": 1000,
507+
"next_index": 0,
508+
"timestamp": "now"
509+
},
510+
{
511+
"desc": descsum_create(f"sh(multi(15,{(xkey_int + ',') * 14}{xkey_int}))"),
512+
"active": True,
513+
"internal": True,
514+
"range": 1000,
515+
"next_index": 0,
516+
"timestamp": "now"
517+
}])
518+
assert_equal(res[0]['success'], True)
519+
assert_equal(res[1]['success'], True)
520+
521+
addr = multi_priv_big.getnewaddress("", "legacy")
522+
w0.sendtoaddress(addr, 10)
523+
self.nodes[0].generate(6)
524+
self.sync_all()
525+
# It is standard and would relay.
526+
txid = multi_priv_big.sendtoaddress(w0.getnewaddress(), 10, "", "",
527+
True)
528+
decoded = multi_priv_big.decoderawtransaction(
529+
multi_priv_big.gettransaction(txid)['hex']
530+
)
531+
532+
462533
self.log.info("Combo descriptors cannot be active")
463534
self.test_importdesc({"desc": descsum_create("combo(tpubDCJtdt5dgJpdhW4MtaVYDhG4T4tF6jcLR1PxL43q9pq1mxvXgMS9Mzw1HnXG15vxUGQJMMSqCQHMTy3F1eW5VkgVroWzchsPD5BUojrcWs8/*)"),
464535
"active": True,

0 commit comments

Comments
 (0)