@@ -354,73 +354,75 @@ def run_test(self):
354
354
hdkeypath = v17_info ["hdkeypath" ]
355
355
pubkey = v17_info ["pubkey" ]
356
356
357
- # Copy the 0.16 wallet to the last Bitcoin Core version and open it:
358
- shutil .copyfile (
359
- os .path .join (node_v16_wallets_dir , "wallets/u1_v16" ),
360
- os .path .join (node_master_wallets_dir , "u1_v16" )
361
- )
362
- load_res = node_master .loadwallet ("u1_v16" )
363
- # Make sure this wallet opens without warnings. See https://github.com/bitcoin/bitcoin/pull/19054
364
- assert_equal (load_res ['warning' ], '' )
365
- wallet = node_master .get_wallet_rpc ("u1_v16" )
366
- info = wallet .getaddressinfo (v16_addr )
367
- descriptor = "wpkh([" + info ["hdmasterfingerprint" ] + hdkeypath [1 :] + "]" + v16_pubkey + ")"
368
- assert_equal (info ["desc" ], descsum_create (descriptor ))
369
-
370
- # Now copy that same wallet back to 0.16 to make sure no automatic upgrade breaks it
371
- os .remove (os .path .join (node_v16_wallets_dir , "wallets/u1_v16" ))
372
- shutil .copyfile (
373
- os .path .join (node_master_wallets_dir , "u1_v16" ),
374
- os .path .join (node_v16_wallets_dir , "wallets/u1_v16" )
375
- )
376
- self .start_node (- 1 , extra_args = ["-wallet=u1_v16" ])
377
- wallet = node_v16 .get_wallet_rpc ("u1_v16" )
378
- info = wallet .validateaddress (v16_addr )
379
- assert_equal (info , v16_info )
380
-
381
- # Copy the 0.17 wallet to the last Bitcoin Core version and open it:
382
- node_v17 .unloadwallet ("u1_v17" )
383
- shutil .copytree (
384
- os .path .join (node_v17_wallets_dir , "u1_v17" ),
385
- os .path .join (node_master_wallets_dir , "u1_v17" )
386
- )
387
- node_master .loadwallet ("u1_v17" )
388
- wallet = node_master .get_wallet_rpc ("u1_v17" )
389
- info = wallet .getaddressinfo (address )
390
- descriptor = "wpkh([" + info ["hdmasterfingerprint" ] + hdkeypath [1 :] + "]" + pubkey + ")"
391
- assert_equal (info ["desc" ], descsum_create (descriptor ))
392
-
393
- # Now copy that same wallet back to 0.17 to make sure no automatic upgrade breaks it
394
- node_master .unloadwallet ("u1_v17" )
395
- shutil .rmtree (os .path .join (node_v17_wallets_dir , "u1_v17" ))
396
- shutil .copytree (
397
- os .path .join (node_master_wallets_dir , "u1_v17" ),
398
- os .path .join (node_v17_wallets_dir , "u1_v17" )
399
- )
400
- node_v17 .loadwallet ("u1_v17" )
401
- wallet = node_v17 .get_wallet_rpc ("u1_v17" )
402
- info = wallet .getaddressinfo (address )
403
- assert_equal (info , v17_info )
404
-
405
- # Copy the 0.19 wallet to the last Bitcoin Core version and open it:
406
- shutil .copytree (
407
- os .path .join (node_v19_wallets_dir , "w1_v19" ),
408
- os .path .join (node_master_wallets_dir , "w1_v19" )
409
- )
410
- node_master .loadwallet ("w1_v19" )
411
- wallet = node_master .get_wallet_rpc ("w1_v19" )
412
- assert wallet .getaddressinfo (address_18075 )["solvable" ]
357
+ if self .is_bdb_compiled ():
358
+ # Old wallets are BDB and will only work if BDB is compiled
359
+ # Copy the 0.16 wallet to the last Bitcoin Core version and open it:
360
+ shutil .copyfile (
361
+ os .path .join (node_v16_wallets_dir , "wallets/u1_v16" ),
362
+ os .path .join (node_master_wallets_dir , "u1_v16" )
363
+ )
364
+ load_res = node_master .loadwallet ("u1_v16" )
365
+ # Make sure this wallet opens without warnings. See https://github.com/bitcoin/bitcoin/pull/19054
366
+ assert_equal (load_res ['warning' ], '' )
367
+ wallet = node_master .get_wallet_rpc ("u1_v16" )
368
+ info = wallet .getaddressinfo (v16_addr )
369
+ descriptor = "wpkh([" + info ["hdmasterfingerprint" ] + hdkeypath [1 :] + "]" + v16_pubkey + ")"
370
+ assert_equal (info ["desc" ], descsum_create (descriptor ))
371
+
372
+ # Now copy that same wallet back to 0.16 to make sure no automatic upgrade breaks it
373
+ os .remove (os .path .join (node_v16_wallets_dir , "wallets/u1_v16" ))
374
+ shutil .copyfile (
375
+ os .path .join (node_master_wallets_dir , "u1_v16" ),
376
+ os .path .join (node_v16_wallets_dir , "wallets/u1_v16" )
377
+ )
378
+ self .start_node (- 1 , extra_args = ["-wallet=u1_v16" ])
379
+ wallet = node_v16 .get_wallet_rpc ("u1_v16" )
380
+ info = wallet .validateaddress (v16_addr )
381
+ assert_equal (info , v16_info )
413
382
414
- # Now copy that same wallet back to 0.19 to make sure no automatic upgrade breaks it
415
- node_master .unloadwallet ("w1_v19" )
416
- shutil .rmtree (os .path .join (node_v19_wallets_dir , "w1_v19" ))
417
- shutil .copytree (
418
- os .path .join (node_master_wallets_dir , "w1_v19" ),
419
- os .path .join (node_v19_wallets_dir , "w1_v19" )
420
- )
421
- node_v19 .loadwallet ("w1_v19" )
422
- wallet = node_v19 .get_wallet_rpc ("w1_v19" )
423
- assert wallet .getaddressinfo (address_18075 )["solvable" ]
383
+ # Copy the 0.17 wallet to the last Bitcoin Core version and open it:
384
+ node_v17 .unloadwallet ("u1_v17" )
385
+ shutil .copytree (
386
+ os .path .join (node_v17_wallets_dir , "u1_v17" ),
387
+ os .path .join (node_master_wallets_dir , "u1_v17" )
388
+ )
389
+ node_master .loadwallet ("u1_v17" )
390
+ wallet = node_master .get_wallet_rpc ("u1_v17" )
391
+ info = wallet .getaddressinfo (address )
392
+ descriptor = "wpkh([" + info ["hdmasterfingerprint" ] + hdkeypath [1 :] + "]" + pubkey + ")"
393
+ assert_equal (info ["desc" ], descsum_create (descriptor ))
394
+
395
+ # Now copy that same wallet back to 0.17 to make sure no automatic upgrade breaks it
396
+ node_master .unloadwallet ("u1_v17" )
397
+ shutil .rmtree (os .path .join (node_v17_wallets_dir , "u1_v17" ))
398
+ shutil .copytree (
399
+ os .path .join (node_master_wallets_dir , "u1_v17" ),
400
+ os .path .join (node_v17_wallets_dir , "u1_v17" )
401
+ )
402
+ node_v17 .loadwallet ("u1_v17" )
403
+ wallet = node_v17 .get_wallet_rpc ("u1_v17" )
404
+ info = wallet .getaddressinfo (address )
405
+ assert_equal (info , v17_info )
406
+
407
+ # Copy the 0.19 wallet to the last Bitcoin Core version and open it:
408
+ shutil .copytree (
409
+ os .path .join (node_v19_wallets_dir , "w1_v19" ),
410
+ os .path .join (node_master_wallets_dir , "w1_v19" )
411
+ )
412
+ node_master .loadwallet ("w1_v19" )
413
+ wallet = node_master .get_wallet_rpc ("w1_v19" )
414
+ assert wallet .getaddressinfo (address_18075 )["solvable" ]
415
+
416
+ # Now copy that same wallet back to 0.19 to make sure no automatic upgrade breaks it
417
+ node_master .unloadwallet ("w1_v19" )
418
+ shutil .rmtree (os .path .join (node_v19_wallets_dir , "w1_v19" ))
419
+ shutil .copytree (
420
+ os .path .join (node_master_wallets_dir , "w1_v19" ),
421
+ os .path .join (node_v19_wallets_dir , "w1_v19" )
422
+ )
423
+ node_v19 .loadwallet ("w1_v19" )
424
+ wallet = node_v19 .get_wallet_rpc ("w1_v19" )
425
+ assert wallet .getaddressinfo (address_18075 )["solvable" ]
424
426
425
427
if __name__ == '__main__' :
426
428
BackwardsCompatibilityTest ().main ()
0 commit comments