33
33
"0211c7b2e18b6fd330f322de087da62da92ae2ae3d0b7cec7e616479cce175f183" ,
34
34
]
35
35
36
- MINISCRIPTS = [
36
+ P2WSH_MINISCRIPTS = [
37
37
# One of two keys
38
38
f"or_b(pk({ TPUBS [0 ]} /*),s:pk({ TPUBS [1 ]} /*))" ,
39
39
# A script similar (same spending policy) to BOLT3's offered HTLC (with anchor outputs)
44
44
f"or_i(and_b(pk({ PUBKEYS [0 ]} ),a:and_b(pk({ PUBKEYS [1 ]} ),a:and_b(pk({ PUBKEYS [2 ]} ),a:and_b(pk({ PUBKEYS [3 ]} ),s:pk({ PUBKEYS [4 ]} ))))),and_v(v:thresh(2,pkh({ TPUBS [0 ]} /*),a:pkh({ PUBKEYS [5 ]} ),a:pkh({ PUBKEYS [6 ]} )),older(4209713)))" ,
45
45
]
46
46
47
+ DESCS = [
48
+ * [f"wsh({ ms } )" for ms in P2WSH_MINISCRIPTS ],
49
+ # A Taproot with one of the above scripts as the single script path.
50
+ f"tr(4d54bb9928a0683b7e383de72943b214b0716f58aa54c7ba6bcea2328bc9c768,{ P2WSH_MINISCRIPTS [0 ]} )" ,
51
+ # A Taproot with two script paths among the above scripts.
52
+ f"tr(4d54bb9928a0683b7e383de72943b214b0716f58aa54c7ba6bcea2328bc9c768,{{{ P2WSH_MINISCRIPTS [0 ]} ,{ P2WSH_MINISCRIPTS [1 ]} }})" ,
53
+ # A Taproot with three script paths among the above scripts.
54
+ f"tr(4d54bb9928a0683b7e383de72943b214b0716f58aa54c7ba6bcea2328bc9c768,{{{{{ P2WSH_MINISCRIPTS [0 ]} ,{ P2WSH_MINISCRIPTS [1 ]} }},{ P2WSH_MINISCRIPTS [2 ].replace ('multi' , 'multi_a' )} }})" ,
55
+ # A Taproot with all above scripts in its tree.
56
+ f"tr(4d54bb9928a0683b7e383de72943b214b0716f58aa54c7ba6bcea2328bc9c768,{{{{{ P2WSH_MINISCRIPTS [0 ]} ,{ P2WSH_MINISCRIPTS [1 ]} }},{{{ P2WSH_MINISCRIPTS [2 ].replace ('multi' , 'multi_a' )} ,{ P2WSH_MINISCRIPTS [3 ]} }}}})" ,
57
+ ]
58
+
47
59
MINISCRIPTS_PRIV = [
48
60
# One of two keys, of which one private key is known
49
61
{
@@ -150,9 +162,9 @@ def skip_test_if_missing_module(self):
150
162
self .skip_if_no_wallet ()
151
163
self .skip_if_no_sqlite ()
152
164
153
- def watchonly_test (self , ms ):
154
- self .log .info (f"Importing Miniscript '{ ms } '" )
155
- desc = descsum_create (f"wsh( { ms } ) " )
165
+ def watchonly_test (self , desc ):
166
+ self .log .info (f"Importing descriptor '{ desc } '" )
167
+ desc = descsum_create (f"{ desc } " )
156
168
assert self .ms_wo_wallet .importdescriptors (
157
169
[
158
170
{
@@ -166,11 +178,14 @@ def watchonly_test(self, ms):
166
178
)[0 ]["success" ]
167
179
168
180
self .log .info ("Testing we derive new addresses for it" )
181
+ addr_type = "bech32m" if desc .startswith ("tr(" ) else "bech32"
169
182
assert_equal (
170
- self .ms_wo_wallet .getnewaddress (), self .funder .deriveaddresses (desc , 0 )[0 ]
183
+ self .ms_wo_wallet .getnewaddress (address_type = addr_type ),
184
+ self .funder .deriveaddresses (desc , 0 )[0 ],
171
185
)
172
186
assert_equal (
173
- self .ms_wo_wallet .getnewaddress (), self .funder .deriveaddresses (desc , 1 )[1 ]
187
+ self .ms_wo_wallet .getnewaddress (address_type = addr_type ),
188
+ self .funder .deriveaddresses (desc , 1 )[1 ],
174
189
)
175
190
176
191
self .log .info ("Testing we detect funds sent to one of them" )
@@ -290,8 +305,8 @@ def run_test(self):
290
305
assert not res ["success" ] and "is not satisfiable" in res ["error" ]["message" ]
291
306
292
307
# Test we can track any type of Miniscript
293
- for ms in MINISCRIPTS :
294
- self .watchonly_test (ms )
308
+ for desc in DESCS :
309
+ self .watchonly_test (desc )
295
310
296
311
# Test we can sign for any Miniscript.
297
312
for ms in MINISCRIPTS_PRIV :
0 commit comments