10
10
except ImportError :
11
11
pass
12
12
13
+ import re
14
+
13
15
from test_framework .blocktools import COINBASE_MATURITY
14
16
from test_framework .test_framework import BitcoinTestFramework
15
17
from test_framework .util import (
@@ -25,7 +27,7 @@ def add_options(self, parser):
25
27
def set_test_params (self ):
26
28
self .setup_clean_chain = True
27
29
self .num_nodes = 1
28
- self .extra_args = [['-keypool=100' ]]
30
+ self .extra_args = [['-keypool=100' , "-unsafesqlitesync=0" ]]
29
31
self .wallet_names = []
30
32
31
33
def skip_test_if_missing_module (self ):
@@ -241,6 +243,35 @@ def run_test(self):
241
243
conn .close ()
242
244
assert_raises_rpc_error (- 4 , "Unexpected legacy entry in descriptor wallet found." , self .nodes [0 ].loadwallet , "crashme" )
243
245
246
+ self .log .info ("Test adding new autogenerated descriptors" )
247
+ self .nodes [0 ].createwallet (wallet_name = "autogen" , descriptors = True , blank = True )
248
+ wallet = self .nodes [0 ].get_wallet_rpc ("autogen" )
249
+
250
+ # Set a new seed without adding new descriptors
251
+ wallet .sethdseed (False )
252
+
253
+ # seed cannot be rotated
254
+ assert_raises_rpc_error (- 4 , "The wallet already has an active HD key set. Create a new wallet if you want to rotate your keys." , wallet .sethdseed )
255
+
256
+ # Now add new autogenerated descriptors
257
+ addr_types = ["legacy" , "p2sh-segwit" , "bech32" , "bech32m" ]
258
+ for t in addr_types [0 :2 ]:
259
+ wallet .createwalletdescriptor (t )
260
+ assert_raises_rpc_error (- 4 , "Descriptor already exists" , wallet .createwalletdescriptor , t )
261
+
262
+ # We can make new change descriptors now
263
+ # Also testing the second parameter
264
+ for t in addr_types [2 :]:
265
+ wallet .createwalletdescriptor (t , True )
266
+ wallet .createwalletdescriptor (t , False )
267
+
268
+ # Check that all descriptors use the same xpub
269
+ descs = wallet .listdescriptors ()["descriptors" ]
270
+ xpub = re .search (r"tpub.+?\/" , descs [0 ]["desc" ]).group ()
271
+ for d in descs :
272
+ desc_xpub = re .search (r"tpub.+?\/" , descs [0 ]["desc" ])
273
+ assert desc_xpub
274
+ assert_equal (xpub , desc_xpub .group ())
244
275
245
276
if __name__ == '__main__' :
246
277
WalletDescriptorTest ().main ()
0 commit comments