@@ -322,6 +322,15 @@ def run_test(self):
322
322
info = wallet .getwalletinfo ()
323
323
assert info ['keypoolsize' ] == 1
324
324
325
+ # Create upgrade wallet in v0.16
326
+ self .stop_node (- 1 )
327
+ self .start_node (- 1 , extra_args = ["-wallet=u1_v16" ])
328
+ wallet = node_v16 .get_wallet_rpc ("u1_v16" )
329
+ v16_addr = wallet .getnewaddress ('' , "bech32" )
330
+ v16_info = wallet .validateaddress (v16_addr )
331
+ v16_pubkey = v16_info ['pubkey' ]
332
+ self .stop_node (- 1 )
333
+
325
334
self .log .info ("Test wallet upgrade path..." )
326
335
# u1: regular wallet, created with v0.17
327
336
node_v17 .rpc .createwallet (wallet_name = "u1_v17" )
@@ -331,6 +340,30 @@ def run_test(self):
331
340
hdkeypath = v17_info ["hdkeypath" ]
332
341
pubkey = v17_info ["pubkey" ]
333
342
343
+ # Copy the 0.16 wallet to the last Bitcoin Core version and open it:
344
+ shutil .copyfile (
345
+ os .path .join (node_v16_wallets_dir , "wallets/u1_v16" ),
346
+ os .path .join (node_master_wallets_dir , "u1_v16" )
347
+ )
348
+ load_res = node_master .loadwallet ("u1_v16" )
349
+ # Make sure this wallet opens without warnings. See https://github.com/bitcoin/bitcoin/pull/19054
350
+ assert_equal (load_res ['warning' ], '' )
351
+ wallet = node_master .get_wallet_rpc ("u1_v16" )
352
+ info = wallet .getaddressinfo (v16_addr )
353
+ descriptor = "wpkh([" + info ["hdmasterfingerprint" ] + hdkeypath [1 :] + "]" + v16_pubkey + ")"
354
+ assert_equal (info ["desc" ], descsum_create (descriptor ))
355
+
356
+ # Now copy that same wallet back to 0.16 to make sure no automatic upgrade breaks it
357
+ os .remove (os .path .join (node_v16_wallets_dir , "wallets/u1_v16" ))
358
+ shutil .copyfile (
359
+ os .path .join (node_master_wallets_dir , "u1_v16" ),
360
+ os .path .join (node_v16_wallets_dir , "wallets/u1_v16" )
361
+ )
362
+ self .start_node (- 1 , extra_args = ["-wallet=u1_v16" ])
363
+ wallet = node_v16 .get_wallet_rpc ("u1_v16" )
364
+ info = wallet .validateaddress (v16_addr )
365
+ assert_equal (info , v16_info )
366
+
334
367
# Copy the 0.17 wallet to the last Bitcoin Core version and open it:
335
368
node_v17 .unloadwallet ("u1_v17" )
336
369
shutil .copytree (
0 commit comments