@@ -135,7 +135,9 @@ def run_test(self):
135
135
node_v17 = self .nodes [self .num_nodes - 2 ]
136
136
node_v16 = self .nodes [self .num_nodes - 1 ]
137
137
138
- legacy_nodes = self .nodes [2 :]
138
+ legacy_nodes = self .nodes [2 :] # Nodes that support legacy wallets
139
+ legacy_only_nodes = self .nodes [- 5 :] # Nodes that only support legacy wallets
140
+ descriptors_nodes = self .nodes [2 :- 5 ] # Nodes that support descriptor wallets
139
141
140
142
self .generatetoaddress (node_miner , COINBASE_MATURITY + 1 , node_miner .getnewaddress ())
141
143
@@ -209,52 +211,60 @@ def run_test(self):
209
211
210
212
self .test_v19_addmultisigaddress ()
211
213
212
- if not self .options .descriptors :
213
- # Descriptor wallets break compatibility, only run this test for legacy wallet
214
- # Load modern wallet with older nodes
215
- for node in legacy_nodes :
216
- for wallet_name in ["w1" , "w2" , "w3" ]:
217
- if node .version < 170000 :
218
- # loadwallet was introduced in v0.17.0
219
- continue
220
- if node .version < 180000 and wallet_name == "w3" :
221
- # Blank wallets were introduced in v0.18.0. We test the loading error below.
222
- continue
223
- node .loadwallet (wallet_name )
224
- wallet = node .get_wallet_rpc (wallet_name )
225
- info = wallet .getwalletinfo ()
226
- if wallet_name == "w1" :
227
- assert info ['private_keys_enabled' ] == True
228
- assert info ['keypoolsize' ] > 0
229
- txs = wallet .listtransactions ()
230
- assert_equal (len (txs ), 5 )
231
- assert_equal (txs [1 ]["txid" ], tx1_id )
232
- assert_equal (txs [2 ]["walletconflicts" ], [tx1_id ])
233
- assert_equal (txs [1 ]["replaced_by_txid" ], tx2_id )
234
- assert not txs [1 ]["abandoned" ]
235
- assert_equal (txs [1 ]["confirmations" ], - 1 )
236
- assert_equal (txs [2 ]["blockindex" ], 1 )
237
- assert txs [3 ]["abandoned" ]
238
- assert_equal (txs [4 ]["walletconflicts" ], [tx3_id ])
239
- assert_equal (txs [3 ]["replaced_by_txid" ], tx4_id )
240
- assert not hasattr (txs [3 ], "blockindex" )
241
- elif wallet_name == "w2" :
242
- assert info ['private_keys_enabled' ] == False
243
- assert info ['keypoolsize' ] == 0
244
- else :
245
- assert info ['private_keys_enabled' ] == True
246
- assert info ['keypoolsize' ] == 0
247
- else :
248
- for node in legacy_nodes :
214
+ self .log .info ("Test that a wallet made on master can be opened on:" )
215
+ # In descriptors wallet mode, run this test on the nodes that support descriptor wallets
216
+ # In legacy wallets mode, run this test on the nodes that support legacy wallets
217
+ for node in descriptors_nodes if self .options .descriptors else legacy_nodes :
218
+ if self .major_version_less_than (node , 17 ):
219
+ # loadwallet was introduced in v0.17.0
220
+ continue
221
+ self .log .info (f"- { node .version } " )
222
+ for wallet_name in ["w1" , "w2" , "w3" ]:
223
+ if self .major_version_less_than (node , 18 ) and wallet_name == "w3" :
224
+ # Blank wallets were introduced in v0.18.0. We test the loading error below.
225
+ continue
226
+ if self .major_version_less_than (node , 22 ) and wallet_name == "w1" and self .options .descriptors :
227
+ # Descriptor wallets created after 0.21 have taproot descriptors which 0.21 does not support, tested below
228
+ continue
229
+ node .loadwallet (wallet_name )
230
+ wallet = node .get_wallet_rpc (wallet_name )
231
+ info = wallet .getwalletinfo ()
232
+ if wallet_name == "w1" :
233
+ assert info ['private_keys_enabled' ] == True
234
+ assert info ['keypoolsize' ] > 0
235
+ txs = wallet .listtransactions ()
236
+ assert_equal (len (txs ), 5 )
237
+ assert_equal (txs [1 ]["txid" ], tx1_id )
238
+ assert_equal (txs [2 ]["walletconflicts" ], [tx1_id ])
239
+ assert_equal (txs [1 ]["replaced_by_txid" ], tx2_id )
240
+ assert not txs [1 ]["abandoned" ]
241
+ assert_equal (txs [1 ]["confirmations" ], - 1 )
242
+ assert_equal (txs [2 ]["blockindex" ], 1 )
243
+ assert txs [3 ]["abandoned" ]
244
+ assert_equal (txs [4 ]["walletconflicts" ], [tx3_id ])
245
+ assert_equal (txs [3 ]["replaced_by_txid" ], tx4_id )
246
+ assert not hasattr (txs [3 ], "blockindex" )
247
+ elif wallet_name == "w2" :
248
+ assert info ['private_keys_enabled' ] == False
249
+ assert info ['keypoolsize' ] == 0
250
+ else :
251
+ assert info ['private_keys_enabled' ] == True
252
+ assert info ['keypoolsize' ] == 0
253
+
254
+ # Check that descriptor wallets don't work on legacy only nodes
255
+ if self .options .descriptors :
256
+ self .log .info ("Test descriptor wallet incompatibility on:" )
257
+ for node in legacy_only_nodes :
258
+ # RPC loadwallet failure causes bitcoind to exit in <= 0.17, in addition to the RPC
259
+ # call failure, so the following test won't work:
260
+ # assert_raises_rpc_error(-4, "Wallet loading failed.", node_v17.loadwallet, 'w3')
261
+ if self .major_version_less_than (node , 18 ):
262
+ continue
263
+ self .log .info (f"- { node .version } " )
249
264
# Descriptor wallets appear to be corrupted wallets to old software
250
- # and loadwallet is introduced in v0.17.0
251
- if node .version >= 170000 and node .version < 210000 :
252
- for wallet_name in ["w1" , "w2" , "w3" ]:
253
- assert_raises_rpc_error (- 4 , "Wallet file verification failed: wallet.dat corrupt, salvage failed" , node .loadwallet , wallet_name )
254
-
255
- # RPC loadwallet failure causes bitcoind to exit, in addition to the RPC
256
- # call failure, so the following test won't work:
257
- # assert_raises_rpc_error(-4, "Wallet loading failed.", node_v17.loadwallet, 'w3')
265
+ assert self .major_version_at_least (node , 18 ) and self .major_version_less_than (node , 21 )
266
+ for wallet_name in ["w1" , "w2" , "w3" ]:
267
+ assert_raises_rpc_error (- 4 , "Wallet file verification failed: wallet.dat corrupt, salvage failed" , node .loadwallet , wallet_name )
258
268
259
269
# Instead, we stop node and try to launch it with the wallet:
260
270
self .stop_node (node_v17 .index )
0 commit comments