@@ -284,18 +284,54 @@ pub trait RpcApi: Sized {
284
284
blank : Option < bool > ,
285
285
passphrase : Option < & str > ,
286
286
avoid_reuse : Option < bool > ,
287
+ descriptors : Option < bool > ,
287
288
) -> Result < json:: LoadWalletResult > {
288
- let mut args = [
289
- wallet. into ( ) ,
290
- opt_into_json ( disable_private_keys) ?,
291
- opt_into_json ( blank) ?,
292
- opt_into_json ( passphrase) ?,
293
- opt_into_json ( avoid_reuse) ?,
294
- ] ;
295
- self . call (
296
- "createwallet" ,
297
- handle_defaults ( & mut args, & [ false . into ( ) , false . into ( ) , into_json ( "" ) ?, false . into ( ) ] ) ,
298
- )
289
+ // the descriptors argument was added in version 21
290
+ if self . version ( ) ? < 210000 {
291
+ // note: we allow Some(false) since it's the default behavior
292
+ if let Some ( true ) = descriptors {
293
+ return Err ( Error :: Unsupported ) ;
294
+ }
295
+ // no descriptors argument yet
296
+ let mut args = [
297
+ wallet. into ( ) ,
298
+ opt_into_json ( disable_private_keys) ?,
299
+ opt_into_json ( blank) ?,
300
+ opt_into_json ( passphrase) ?,
301
+ opt_into_json ( avoid_reuse) ?,
302
+ ] ;
303
+ self . call (
304
+ "createwallet" ,
305
+ handle_defaults (
306
+ & mut args,
307
+ & [ false . into ( ) , false . into ( ) , into_json ( "" ) ?, false . into ( ) ] ,
308
+ ) ,
309
+ )
310
+ } else {
311
+ let mut args = [
312
+ wallet. into ( ) ,
313
+ opt_into_json ( disable_private_keys) ?,
314
+ opt_into_json ( blank) ?,
315
+ opt_into_json ( passphrase) ?,
316
+ opt_into_json ( avoid_reuse) ?,
317
+ opt_into_json ( descriptors) ?,
318
+ ] ;
319
+ // from 23 on, the default value of the descriptors argument is true
320
+ let default_descriptors = self . version ( ) ? >= 230000 ;
321
+ self . call (
322
+ "createwallet" ,
323
+ handle_defaults (
324
+ & mut args,
325
+ & [
326
+ false . into ( ) ,
327
+ false . into ( ) ,
328
+ into_json ( "" ) ?,
329
+ false . into ( ) ,
330
+ default_descriptors. into ( ) ,
331
+ ] ,
332
+ ) ,
333
+ )
334
+ }
299
335
}
300
336
301
337
fn list_wallets ( & self ) -> Result < Vec < String > > {
0 commit comments