|
9 | 9 | //! |
10 | 10 | //! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. |
11 | 11 |
|
12 | | -/// Implements Bitcoin Core JSON-RPC API method `createwallet` with descriptors=true (descriptor wallet). |
| 12 | +/// Implements Bitcoin Core JSON-RPC API method `createwallet`. |
13 | 13 | #[macro_export] |
14 | | -macro_rules! impl_client_v21__create_wallet_with_descriptors { |
| 14 | +macro_rules! impl_client_v21__create_wallet { |
15 | 15 | () => { |
16 | 16 | impl Client { |
17 | | - pub fn create_wallet_with_descriptors(&self, wallet: &str) -> Result<CreateWallet> { |
18 | | - let args = [ |
19 | | - wallet.into(), |
20 | | - false.into(), // disable_private_keys |
21 | | - false.into(), // blank |
22 | | - serde_json::Value::Null, // passphrase |
23 | | - false.into(), // avoid_reuse |
24 | | - true.into(), // descriptors=true |
25 | | - serde_json::Value::Null, // load_on_startup |
26 | | - ]; |
27 | | - self.call("createwallet", &args) |
| 17 | + /// Calls `createwallet` with `wallet` as the only argument. |
| 18 | + /// |
| 19 | + /// In v21 and v22 this creates a legacy wallet. Use `create_descriptor_wallet` to create |
| 20 | + /// a descriptor wallet. |
| 21 | + pub fn create_wallet(&self, wallet: &str) -> Result<CreateWallet> { |
| 22 | + self.call("createwallet", &[wallet.into()]) |
| 23 | + } |
| 24 | + |
| 25 | + /// Creates a wallet with descriptors=true (descriptor wallet). |
| 26 | + /// |
| 27 | + /// > createwallet "wallet_name" ( disable_private_keys blank "passphrase" avoid_reuse descriptors load_on_startup ) |
| 28 | + /// > |
| 29 | + /// > Creates and loads a new wallet. |
| 30 | + /// > |
| 31 | + /// > Arguments: |
| 32 | + /// > 1. wallet_name (string, required) The name for the new wallet. If this is a path, the wallet will be created at the path location. |
| 33 | + /// > 2. disable_private_keys (boolean, optional, default=false) Disable the possibility of private keys (only watchonlys are possible in this mode). |
| 34 | + /// > 3. blank (boolean, optional, default=false) Create a blank wallet. A blank wallet has no keys or HD seed. One can be set using sethdseed. |
| 35 | + /// > 4. passphrase (string, optional) Encrypt the wallet with this passphrase. |
| 36 | + /// > 5. avoid_reuse (boolean, optional, default=false) Keep track of coin reuse, and treat dirty and clean coins differently with privacy considerations in mind. |
| 37 | + /// > 6. descriptors (boolean, optional, default=true) Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation |
| 38 | + /// > 7. load_on_startup (boolean, optional) Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged. |
| 39 | + pub fn create_descriptor_wallet(&self, wallet: &str) -> Result<CreateWallet> { |
| 40 | + let disable_private_keys = false; |
| 41 | + let blank = false; |
| 42 | + let passphrase = String::new(); |
| 43 | + let avoid_reuse = false; |
| 44 | + let descriptors = true; |
| 45 | + |
| 46 | + self.call( |
| 47 | + "createwallet", |
| 48 | + &[ |
| 49 | + wallet.into(), |
| 50 | + disable_private_keys.into(), |
| 51 | + blank.into(), |
| 52 | + passphrase.into(), |
| 53 | + avoid_reuse.into(), |
| 54 | + descriptors.into(), |
| 55 | + ], |
| 56 | + ) |
28 | 57 | } |
29 | 58 | } |
30 | 59 | }; |
|
0 commit comments