29
29
30
30
class BackwardsCompatibilityTest (BitcoinTestFramework ):
31
31
def add_options (self , parser ):
32
- self .add_wallet_options (parser )
32
+ self .add_wallet_options (parser , legacy = False )
33
33
34
34
def set_test_params (self ):
35
35
self .setup_clean_chain = True
@@ -204,12 +204,12 @@ def run_test(self):
204
204
self .test_v19_addmultisigaddress ()
205
205
206
206
self .log .info ("Test that a wallet made on master can be opened on:" )
207
- # In descriptors wallet mode, run this test on the nodes that support descriptor wallets
208
- # In legacy wallets mode, run this test on the nodes that support legacy wallets
209
- for node in descriptors_nodes if self . options . descriptors else legacy_nodes :
207
+ # This test only works on the nodes that support descriptor wallets
208
+ # since we can no longer create legacy wallets.
209
+ for node in descriptors_nodes :
210
210
self .log .info (f"- { node .version } " )
211
211
for wallet_name in ["w1" , "w2" , "w3" ]:
212
- if self .major_version_less_than (node , 22 ) and wallet_name == "w1" and self . options . descriptors :
212
+ if self .major_version_less_than (node , 22 ) and wallet_name == "w1" :
213
213
# Descriptor wallets created after 0.21 have taproot descriptors which 0.21 does not support, tested below
214
214
continue
215
215
# Also try to reopen on master after opening on old
@@ -249,28 +249,23 @@ def run_test(self):
249
249
)
250
250
251
251
# Check that descriptor wallets don't work on legacy only nodes
252
- if self .options .descriptors :
253
- self .log .info ("Test descriptor wallet incompatibility on:" )
254
- for node in legacy_only_nodes :
255
- self .log .info (f"- { node .version } " )
256
- # Descriptor wallets appear to be corrupted wallets to old software
257
- assert self .major_version_less_than (node , 21 )
258
- for wallet_name in ["w1" , "w2" , "w3" ]:
259
- assert_raises_rpc_error (- 4 , "Wallet file verification failed: wallet.dat corrupt, salvage failed" , node .loadwallet , wallet_name )
260
-
261
- # When descriptors are enabled, w1 cannot be opened by 0.21 since it contains a taproot descriptor
262
- if self .options .descriptors :
263
- self .log .info ("Test that 0.21 cannot open wallet containing tr() descriptors" )
264
- assert_raises_rpc_error (- 1 , "map::at" , node_v21 .loadwallet , "w1" )
252
+ self .log .info ("Test descriptor wallet incompatibility on:" )
253
+ for node in legacy_only_nodes :
254
+ self .log .info (f"- { node .version } " )
255
+ # Descriptor wallets appear to be corrupted wallets to old software
256
+ assert self .major_version_less_than (node , 21 )
257
+ for wallet_name in ["w1" , "w2" , "w3" ]:
258
+ assert_raises_rpc_error (- 4 , "Wallet file verification failed: wallet.dat corrupt, salvage failed" , node .loadwallet , wallet_name )
259
+
260
+ # w1 cannot be opened by 0.21 since it contains a taproot descriptor
261
+ self .log .info ("Test that 0.21 cannot open wallet containing tr() descriptors" )
262
+ assert_raises_rpc_error (- 1 , "map::at" , node_v21 .loadwallet , "w1" )
265
263
266
264
self .log .info ("Test that a wallet can upgrade to and downgrade from master, from:" )
267
- for node in descriptors_nodes if self . options . descriptors else legacy_nodes :
265
+ for node in descriptors_nodes :
268
266
self .log .info (f"- { node .version } " )
269
267
wallet_name = f"up_{ node .version } "
270
- if self .major_version_at_least (node , 21 ):
271
- node .rpc .createwallet (wallet_name = wallet_name , descriptors = self .options .descriptors )
272
- else :
273
- node .rpc .createwallet (wallet_name = wallet_name )
268
+ node .rpc .createwallet (wallet_name = wallet_name , descriptors = True )
274
269
wallet_prev = node .get_wallet_rpc (wallet_name )
275
270
address = wallet_prev .getnewaddress ('' , "bech32" )
276
271
addr_info = wallet_prev .getaddressinfo (address )
@@ -288,12 +283,8 @@ def run_test(self):
288
283
# Restore the wallet to master
289
284
load_res = node_master .restorewallet (wallet_name , backup_path )
290
285
291
- # Make sure this wallet opens with only the migration warning. See https://github.com/bitcoin/bitcoin/pull/19054
292
- if not self .options .descriptors :
293
- # Legacy wallets will have only a deprecation warning
294
- assert_equal (load_res ["warnings" ], ["Wallet loaded successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future. Legacy wallets can be migrated to a descriptor wallet with migratewallet." ])
295
- else :
296
- assert "warnings" not in load_res
286
+ # There should be no warnings
287
+ assert "warnings" not in load_res
297
288
298
289
wallet = node_master .get_wallet_rpc (wallet_name )
299
290
info = wallet .getaddressinfo (address )
@@ -308,7 +299,7 @@ def run_test(self):
308
299
# Check that taproot descriptors can be added to 0.21 wallets
309
300
# This must be done after the backup is created so that 0.21 can still load
310
301
# the backup
311
- if self .options . descriptors and self . major_version_equals (node , 21 ):
302
+ if self .major_version_equals (node , 21 ):
312
303
assert_raises_rpc_error (- 12 , "No bech32m addresses available" , wallet .getnewaddress , address_type = "bech32m" )
313
304
xpubs = wallet .gethdkeys (active_only = True )
314
305
assert_equal (len (xpubs ), 1 )
0 commit comments