You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+63Lines changed: 63 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -195,6 +195,69 @@ Note: You can modify the `Justfile` to reflect your nodes' configuration values.
195
195
cargo run --features rpc -- wallet -u "127.0.0.1:18443" -c rpc -a user:password balance
196
196
```
197
197
198
+
### Initializing a Wallet with `just`
199
+
200
+
When using `bdk-cli`, repeatedly specifying parameter values for each command can be tedious. The `just` command allows you to initialize a wallet with configuration values once, saving them for reuse in subsequent `bdk-cli` commands.
201
+
This eliminate the need to provide repetitive arguments. To set up a wallet with persistent configuration values, use the following just command:
202
+
203
+
```shell
204
+
just init <wallet_name><ext_descriptor><int_descriptor><database_type><client_type><url><rpc_user><rpc_password> [--force]
205
+
```
206
+
The arguments must be provided in the order shown above. Replace each placeholder with the corresponding value:
207
+
208
+
> *`wallet_name`: The unique name for your wallet (e.g., my_wallet)
209
+
> *`ext_descriptor`: The external descriptor for generating receiving addresses (e.g., tr(tprv.../0/*)#checksum)
210
+
> *`int_descriptor`: The internal descriptor for generating change addresses (e.g., tr(tprv.../1/*)#checksum)
211
+
> *`database_type`: The database type for wallet persistence (e.g., sqlite). Defaults to `sqlite` if omitted
212
+
> *`client_type`: The blockchain backend (e.g., electrum, esplora, rpc, cbf)
213
+
> *`url`: The server URL for the blockchain backend (e.g., ssl://mempool.space:60602 for Electrum).
214
+
> *`rpc_user`: The RPC username for rpc client type (e.g., user). Defaults to user if omitted.
215
+
> *`rpc_password`: The RPC password for rpc client type (e.g., password). Defaults to password if omitted.
216
+
> *`--force`: Optional. Overwrites existing configuration for the specified <wallet_name> if set. By default, `just init` fails if the wallet config values already exists.
217
+
218
+
#### Example
219
+
220
+
To initialize a wallet named `my_wallet` with `electrum` as the backend:
221
+
222
+
```shell
223
+
just init my_wallet "tr(tprv8Z.../0/*)#dtdqk3dx""tr(tprv8Z.../1/*)#ulgptya7" sqlite electrum "ssl://mempool.space:60602" user password
224
+
```
225
+
226
+
To overwrite an existing wallet configuration:
227
+
228
+
```shell
229
+
just init-wallet my_wallet "tr(tprv8Z.../0/*)#dtdqk3dx""tr(tprv8Z.../1/*)#ulgptya7" sqlite electrum "ssl://mempool.space:60602" user password --force
230
+
```
231
+
232
+
You can omit the following arguments to use their default values:
233
+
234
+
`database_type`: Defaults to sqlite.
235
+
`rpc_user`: Defaults to user.
236
+
`rpc_password`: Defaults to password.
237
+
238
+
For example, to initialize a wallet with default database_type, rpc_user, and rpc_password:
239
+
240
+
```shell
241
+
just init-wallet my_wallet "tr(tprv8Z.../0/*)#dtdqk3dx""tr(tprv8Z.../1/*)#ulgptya7" electrum "ssl://mempool.space:60602"
242
+
```
243
+
244
+
#### Using Saved Configuration
245
+
246
+
After initializing a wallet with `just init`, the configuration is saved in `~/.bdk-bitcoin/config.toml`. You can then run `bdk-cli` wallet commands without specifying the parameters, referencing only the wallet name and network.
247
+
248
+
With the wallet `my_wallet` initialized, generate a new address and sync the wallet as follow:
* Each wallet has its own configuration, allowing multiple wallets with different settings (e.g., different descriptors or backends).
259
+
* You can override saved configuration values for a single command by specifying them explicitly (e.g., `--client-type esplora` or `--url https://mempool.space/signet/api`).
260
+
198
261
## Minimum Supported Rust Version (MSRV)
199
262
200
263
This library should always compile with any valid combination of features on Rust **1.75.0**.
0 commit comments