@@ -72,11 +72,6 @@ def setup_nodes(self):
72
72
self .start_nodes ()
73
73
self .import_deterministic_coinbase_privkeys ()
74
74
75
- def nodes_wallet_dir (self , node ):
76
- if node .version < 170000 :
77
- return node .chain_path
78
- return node .wallets_path
79
-
80
75
def split_version (self , node ):
81
76
major = node .version // 10000
82
77
minor = (node .version % 10000 ) // 100
@@ -178,18 +173,21 @@ def run_test(self):
178
173
node_master_wallets_dir = node_master .wallets_path
179
174
node_v19_wallets_dir = node_v19 .wallets_path
180
175
node_v17_wallets_dir = node_v17 .wallets_path
181
- node_v16_wallets_dir = node_v16 .chain_path
176
+ node_v16_wallets_dir = node_v16 .wallets_path
182
177
node_master .unloadwallet ("w1" )
183
178
node_master .unloadwallet ("w2" )
184
179
node_master .unloadwallet ("w3" )
185
180
186
181
for node in legacy_nodes :
187
182
# Copy wallets to previous version
188
183
for wallet in os .listdir (node_master_wallets_dir ):
189
- shutil .copytree (
190
- os .path .join (node_master_wallets_dir , wallet ),
191
- os .path .join (self .nodes_wallet_dir (node ), wallet )
192
- )
184
+ dest = node .wallets_path / wallet
185
+ source = node_master_wallets_dir / wallet
186
+ if self .major_version_equals (node , 16 ):
187
+ # 0.16 node expect the wallet to be in the wallet dir but as a plain file rather than in directories
188
+ shutil .copyfile (source / "wallet.dat" , dest )
189
+ else :
190
+ shutil .copytree (source , dest )
193
191
194
192
if not self .options .descriptors :
195
193
# Descriptor wallets break compatibility, only run this test for legacy wallet
@@ -249,13 +247,14 @@ def run_test(self):
249
247
node_v17 .assert_start_raises_init_error (["-wallet=w3" ], "Error: Error loading w3: Wallet requires newer version of Bitcoin Core" )
250
248
self .start_node (node_v17 .index )
251
249
252
- if not self .options .descriptors :
253
- # Descriptor wallets break compatibility, only run this test for legacy wallets
254
- # Open most recent wallet in v0.16 (no loadwallet RPC)
255
- self .restart_node (node_v16 .index , extra_args = ["-wallet=w2" ])
256
- wallet = node_v16 .get_wallet_rpc ("w2" )
257
- info = wallet .getwalletinfo ()
258
- assert info ['keypoolsize' ] == 1
250
+ # No wallet created in master can be opened in 0.16
251
+ self .log .info ("Test that wallets created in master are too new for 0.16" )
252
+ self .stop_node (node_v16 .index )
253
+ for wallet_name in ["w1" , "w2" , "w3" ]:
254
+ if self .options .descriptors :
255
+ node_v16 .assert_start_raises_init_error ([f"-wallet={ wallet_name } " ], f"Error: { wallet_name } corrupt, salvage failed" )
256
+ else :
257
+ node_v16 .assert_start_raises_init_error ([f"-wallet={ wallet_name } " ], f"Error: Error loading { wallet_name } : Wallet requires newer version of Bitcoin Core" )
259
258
260
259
# Create upgrade wallet in v0.16
261
260
self .restart_node (node_v16 .index , extra_args = ["-wallet=u1_v16" ])
@@ -278,7 +277,7 @@ def run_test(self):
278
277
# Old wallets are BDB and will only work if BDB is compiled
279
278
# Copy the 0.16 wallet to the last Bitcoin Core version and open it:
280
279
shutil .copyfile (
281
- os .path .join (node_v16_wallets_dir , "wallets/ u1_v16" ),
280
+ os .path .join (node_v16_wallets_dir , "u1_v16" ),
282
281
os .path .join (node_master_wallets_dir , "u1_v16" )
283
282
)
284
283
load_res = node_master .loadwallet ("u1_v16" )
@@ -297,10 +296,10 @@ def run_test(self):
297
296
298
297
# Now copy that same wallet back to 0.16 to make sure no automatic upgrade breaks it
299
298
node_master .unloadwallet ("u1_v16" )
300
- os .remove (os .path .join (node_v16_wallets_dir , "wallets/ u1_v16" ))
299
+ os .remove (os .path .join (node_v16_wallets_dir , "u1_v16" ))
301
300
shutil .copyfile (
302
301
os .path .join (node_master_wallets_dir , "u1_v16" ),
303
- os .path .join (node_v16_wallets_dir , "wallets/ u1_v16" )
302
+ os .path .join (node_v16_wallets_dir , "u1_v16" )
304
303
)
305
304
self .start_node (node_v16 .index , extra_args = ["-wallet=u1_v16" ])
306
305
wallet = node_v16 .get_wallet_rpc ("u1_v16" )
0 commit comments