@@ -40,11 +40,13 @@ def assert_is_sqlite(self, wallet_name):
40
40
assert_equal (file_magic , b'SQLite format 3\x00 ' )
41
41
assert_equal (self .nodes [0 ].get_wallet_rpc (wallet_name ).getwalletinfo ()["format" ], "sqlite" )
42
42
43
- def create_legacy_wallet (self , wallet_name ):
44
- self .nodes [0 ].createwallet (wallet_name = wallet_name )
43
+ def create_legacy_wallet (self , wallet_name , disable_private_keys = False ):
44
+ self .nodes [0 ].createwallet (wallet_name = wallet_name , descriptors = False , disable_private_keys = disable_private_keys )
45
45
wallet = self .nodes [0 ].get_wallet_rpc (wallet_name )
46
- assert_equal (wallet .getwalletinfo ()["descriptors" ], False )
47
- assert_equal (wallet .getwalletinfo ()["format" ], "bdb" )
46
+ info = wallet .getwalletinfo ()
47
+ assert_equal (info ["descriptors" ], False )
48
+ assert_equal (info ["format" ], "bdb" )
49
+ assert_equal (info ["private_keys_enabled" ], not disable_private_keys )
48
50
return wallet
49
51
50
52
def assert_addr_info_equal (self , addr_info , addr_info_old ):
@@ -187,11 +189,9 @@ def test_multisig(self):
187
189
188
190
# Some keys in multisig do not belong to this wallet
189
191
self .log .info ("Test migration of a wallet that has some keys in a multisig" )
190
- self .nodes [0 ].createwallet (wallet_name = "multisig1" )
191
- multisig1 = self .nodes [0 ].get_wallet_rpc ("multisig1" )
192
+ multisig1 = self .create_legacy_wallet ("multisig1" )
192
193
ms_info = multisig1 .addmultisigaddress (2 , [multisig1 .getnewaddress (), pub1 , pub2 ])
193
194
ms_info2 = multisig1 .addmultisigaddress (2 , [multisig1 .getnewaddress (), pub1 , pub2 ])
194
- assert_equal (multisig1 .getwalletinfo ()["descriptors" ], False )
195
195
196
196
addr1 = ms_info ["address" ]
197
197
addr2 = ms_info2 ["address" ]
@@ -256,9 +256,7 @@ def test_other_watchonly(self):
256
256
257
257
# Wallet with an imported address. Should be the same thing as the multisig test
258
258
self .log .info ("Test migration of a wallet with watchonly imports" )
259
- self .nodes [0 ].createwallet (wallet_name = "imports0" )
260
- imports0 = self .nodes [0 ].get_wallet_rpc ("imports0" )
261
- assert_equal (imports0 .getwalletinfo ()["descriptors" ], False )
259
+ imports0 = self .create_legacy_wallet ("imports0" )
262
260
263
261
# Exteranl address label
264
262
imports0 .setlabel (default .getnewaddress (), "external" )
@@ -318,11 +316,7 @@ def test_no_privkeys(self):
318
316
319
317
# Migrating an actual watchonly wallet should not create a new watchonly wallet
320
318
self .log .info ("Test migration of a pure watchonly wallet" )
321
- self .nodes [0 ].createwallet (wallet_name = "watchonly0" , disable_private_keys = True )
322
- watchonly0 = self .nodes [0 ].get_wallet_rpc ("watchonly0" )
323
- info = watchonly0 .getwalletinfo ()
324
- assert_equal (info ["descriptors" ], False )
325
- assert_equal (info ["private_keys_enabled" ], False )
319
+ watchonly0 = self .create_legacy_wallet ("watchonly0" , disable_private_keys = True )
326
320
327
321
addr = default .getnewaddress ()
328
322
desc = default .getaddressinfo (addr )["desc" ]
@@ -345,11 +339,7 @@ def test_no_privkeys(self):
345
339
346
340
# Migrating a wallet with pubkeys added to the keypool
347
341
self .log .info ("Test migration of a pure watchonly wallet with pubkeys in keypool" )
348
- self .nodes [0 ].createwallet (wallet_name = "watchonly1" , disable_private_keys = True )
349
- watchonly1 = self .nodes [0 ].get_wallet_rpc ("watchonly1" )
350
- info = watchonly1 .getwalletinfo ()
351
- assert_equal (info ["descriptors" ], False )
352
- assert_equal (info ["private_keys_enabled" ], False )
342
+ watchonly1 = self .create_legacy_wallet ("watchonly1" , disable_private_keys = True )
353
343
354
344
addr1 = default .getnewaddress (address_type = "bech32" )
355
345
addr2 = default .getnewaddress (address_type = "bech32" )
0 commit comments