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
- add config.rs to store and retrieve
values
- add toml and serde crates for desearilizing and
reading values
- update utils, commands and handlers files
to use values from config.toml
-refactor prepare_wallet_db fn
- fix clippy issues
[Issue: #192]
Copy file name to clipboardExpand all lines: README.md
+67Lines changed: 67 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -193,3 +193,70 @@ Note: You can modify the `Justfile` to reflect your nodes' configuration values.
193
193
cargo run --features rpc -- wallet -u "127.0.0.1:18443" -c rpc -a user:password sync
194
194
cargo run --features rpc -- wallet -u "127.0.0.1:18443" -c rpc -a user:password balance
195
195
```
196
+
197
+
### Initializing a Wallet with `just`
198
+
199
+
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.
200
+
This eliminate the need to provide repetitive arguments. To set up a wallet with persistent configuration values, use the following just command:
201
+
202
+
```shell
203
+
just init <wallet_name><ext_descriptor><int_descriptor><database_type><client_type><url><rpc_user><rpc_password> [--force]
204
+
```
205
+
The arguments must be provided in the order shown above. Replace each placeholder with the corresponding value:
206
+
207
+
> *`wallet_name`: The unique name for your wallet (e.g., my_wallet)
208
+
> *`ext_descriptor`: The external descriptor for generating receiving addresses (e.g., tr(tprv.../0/*)#checksum)
209
+
> *`int_descriptor`: The internal descriptor for generating change addresses (e.g., tr(tprv.../1/*)#checksum)
210
+
> *`database_type`: The database type for wallet persistence (e.g., sqlite). Defaults to `sqlite` if omitted
211
+
> *`client_type`: The blockchain backend (e.g., electrum, esplora, rpc, cbf)
212
+
> *`url`: The server URL for the blockchain backend (e.g., ssl://mempool.space:60602 for Electrum).
213
+
> *`rpc_user`: The RPC username for rpc client type (e.g., user). Defaults to user if omitted.
214
+
> *`rpc_password`: The RPC password for rpc client type (e.g., password). Defaults to password if omitted.
215
+
> *`--force`: Optional. Overwrites existing configuration for the specified <wallet_name> if set. By default, `just init` fails if the wallet config values already exists.
216
+
217
+
#### Example
218
+
219
+
To initialize a wallet named `my_wallet` with `electrum` as the backend:
220
+
221
+
```shell
222
+
just init my_wallet "tr(tprv8Z.../0/*)#dtdqk3dx""tr(tprv8Z.../1/*)#ulgptya7" sqlite electrum "ssl://mempool.space:60602" user password
223
+
```
224
+
225
+
To overwrite an existing wallet configuration:
226
+
227
+
```shell
228
+
just init-wallet my_wallet "tr(tprv8Z.../0/*)#dtdqk3dx""tr(tprv8Z.../1/*)#ulgptya7" sqlite electrum "ssl://mempool.space:60602" user password --force
229
+
```
230
+
231
+
You can omit the following arguments to use their default values:
232
+
233
+
`database_type`: Defaults to sqlite.
234
+
`rpc_user`: Defaults to user.
235
+
`rpc_password`: Defaults to password.
236
+
237
+
For example, to initialize a wallet with default database_type, rpc_user, and rpc_password:
238
+
239
+
```shell
240
+
just init-wallet my_wallet "tr(tprv8Z.../0/*)#dtdqk3dx""tr(tprv8Z.../1/*)#ulgptya7" electrum "ssl://mempool.space:60602"
241
+
```
242
+
243
+
#### Using Saved Configuration
244
+
245
+
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.
246
+
247
+
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).
258
+
* 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`).
259
+
260
+
## Minimum Supported Rust Version (MSRV)
261
+
262
+
This library should always compile with any valid combination of features on Rust **1.75.0**.
0 commit comments