Skip to content

Commit 8fea469

Browse files
committed
cli: change --pretty short flag to -j and add README example
1 parent e4e6b3b commit 8fea469

2 files changed

Lines changed: 49 additions & 31 deletions

File tree

README.md

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,36 @@
2323
</h4>
2424
</div>
2525

26-
2726
## About
2827

2928
**EXPERIMENTAL**
30-
This crate has been updated to use `bdk_wallet` 1.x. Only use for testing on test networks.
29+
This crate has been updated to use `bdk_wallet` 1.x. Only use for testing on test networks.
3130

3231
This project provides a command-line Bitcoin wallet application using the latest [BDK Wallet APIs](https://docs.rs/bdk_wallet/1.0.0/bdk_wallet/index.html) and chain sources ([RPC](https://docs.rs/bdk_bitcoind_rpc/0.18.0/bdk_bitcoind_rpc/index.html), [Electrum](https://docs.rs/bdk_electrum/0.21.0/bdk_electrum/index.html), [Esplora](https://docs.rs/bdk_esplora/0.21.0/bdk_esplora/), [Kyoto](https://docs.rs/bdk_kyoto/0.9.0/bdk_kyoto/)). This might look tiny and innocent, but by harnessing the power of BDK it provides a powerful generic descriptor based command line wallet tool.
3332
And yes, it can do Taproot!!
3433

3534
This crate can be used for the following purposes:
36-
- Instantly create a miniscript based wallet and connect to your backend of choice (Electrum, Esplora, Core RPC, Kyoto etc) and quickly play around with your own complex bitcoin scripting workflow. With one or many wallets, connected with one or many backends.
37-
- The `tests/integration.rs` module is used to document high level complex workflows between BDK and different Bitcoin infrastructure systems, like Core, Electrum and Lightning(soon TM).
38-
- (Planned) Expose the basic command handler via `wasm` to integrate `bdk-cli` functionality natively into the web platform. See also the [playground](https://bitcoindevkit.org/bdk-cli/playground/) page.
35+
36+
- Instantly create a miniscript based wallet and connect to your backend of choice (Electrum, Esplora, Core RPC, Kyoto etc) and quickly play around with your own complex bitcoin scripting workflow. With one or many wallets, connected with one or many backends.
37+
- The `tests/integration.rs` module is used to document high level complex workflows between BDK and different Bitcoin infrastructure systems, like Core, Electrum and Lightning(soon TM).
38+
- (Planned) Expose the basic command handler via `wasm` to integrate `bdk-cli` functionality natively into the web platform. See also the [playground](https://bitcoindevkit.org/bdk-cli/playground/) page.
3939

4040
If you are considering using BDK in your own wallet project bdk-cli is a nice playground to get started with. It allows easy testnet and regtest wallet operations, to try out what's possible with descriptors, miniscript, and BDK APIs. For more information on BDK refer to the [website](https://bitcoindevkit.org/) and the [rust docs](https://docs.rs/bdk_wallet/1.0.0/bdk_wallet/index.html)
4141

4242
bdk-cli can be compiled with different features to suit your experimental needs.
43-
- Database Options
44-
- `sqlite` : Sets the wallet database to a `sqlite3` db.
45-
- Blockchain Client Options
46-
- `esplora` : Connects the wallet to an esplora server.
47-
- `electrum` : Connects the wallet to an electrum server.
48-
- `kyoto`: Connects the wallet to a kyoto client and server.
49-
- `rpc`: Connects the wallet to Bitcoind server.
50-
- Extra Utility Tools
51-
- `repl` : use bdk-cli as a [REPL](https://codewith.mu/en/tutorials/1.0/repl) shell (useful for quick manual testing of wallet operations).
52-
- `compiler` : opens up bdk-cli policy compiler commands.
53-
54-
The `default` feature set is `repl` and `sqlite`. With the `default` features, `bdk-cli` can be used as an **air-gapped** wallet, and can do everything that doesn't require a network connection.
5543

44+
- Database Options
45+
- `sqlite` : Sets the wallet database to a `sqlite3` db.
46+
- Blockchain Client Options
47+
- `esplora` : Connects the wallet to an esplora server.
48+
- `electrum` : Connects the wallet to an electrum server.
49+
- `kyoto`: Connects the wallet to a kyoto client and server.
50+
- `rpc`: Connects the wallet to Bitcoind server.
51+
- Extra Utility Tools
52+
- `repl` : use bdk-cli as a [REPL](https://codewith.mu/en/tutorials/1.0/repl) shell (useful for quick manual testing of wallet operations).
53+
- `compiler` : opens up bdk-cli policy compiler commands.
54+
55+
The `default` feature set is `repl` and `sqlite`. With the `default` features, `bdk-cli` can be used as an **air-gapped** wallet, and can do everything that doesn't require a network connection.
5656

5757
## Install bdk-cli
5858

@@ -66,8 +66,8 @@ cargo install --path . --features electrum
6666
bdk-cli help # to verify it worked
6767
```
6868

69-
If no blockchain client feature is enabled online wallet commands `sync` and `broadcast` will be
70-
disabled. To enable these commands a blockchain client feature such as `electrum` or another
69+
If no blockchain client feature is enabled online wallet commands `sync` and `broadcast` will be
70+
disabled. To enable these commands a blockchain client feature such as `electrum` or another
7171
blockchain client feature must be enabled. Below is an example of how to run the `bdk-cli` binary with
7272
the `electrum` blockchain client feature.
7373

@@ -79,8 +79,10 @@ Available blockchain client features are:
7979
`electrum`, `esplora`, `kyoto`, `rpc`.
8080

8181
### From crates.io
82-
You can install the binary for the latest tag of `bdk-cli` with online wallet features
82+
83+
You can install the binary for the latest tag of `bdk-cli` with online wallet features
8384
directly from [crates.io](https://crates.io/crates/bdk-cli) with a command as below:
85+
8486
```sh
8587
cargo install bdk-cli --features electrum
8688
```
@@ -114,30 +116,32 @@ cargo run -- key generate
114116

115117
## Justfile
116118

117-
We have added the `just` command runner to help you with common commands (during development) and running regtest `bitcoind` if you are using the `rpc` feature.
119+
We have added the `just` command runner to help you with common commands (during development) and running regtest `bitcoind` if you are using the `rpc` feature.
118120
Visit the [just](https://just.systems/man/en/packages.html) page for setup instructions.
119121

120122
The below are some of the commands included:
121123

122-
``` shell
124+
```shell
123125
just # list all available recipes
124126
just test # test the project
125127
just build # build the project
126128
```
127129

128130
### Using `Justfile` to run `bitcoind` as a Client
129131

130-
If you are testing `bdk-cli` in regtest mode and wants to use your `bitcoind` node as a blockchain client, the `Justfile` can help you to quickly do so. Below are the steps to use your `bitcoind` node in *regtest* mode with `bdk-cli`:
132+
If you are testing `bdk-cli` in regtest mode and wants to use your `bitcoind` node as a blockchain client, the `Justfile` can help you to quickly do so. Below are the steps to use your `bitcoind` node in _regtest_ mode with `bdk-cli`:
131133

132134
Note: You can modify the `Justfile` to reflect your nodes' configuration values. These values are the default values used in `bdk-cli`
133-
> * default wallet: The set default wallet name is `regtest_default_wallet`
134-
> * default data directory: The set default data directory is `~/.bdk-bitcoin`
135-
> * RPC username: The set RPC username is `user`
136-
> * RPC password: The set RPC password is `password`
135+
136+
> - default wallet: The set default wallet name is `regtest_default_wallet`
137+
> - default data directory: The set default data directory is `~/.bdk-bitcoin`
138+
> - RPC username: The set RPC username is `user`
139+
> - RPC password: The set RPC password is `password`
137140
138141
#### Steps
139142

140143
1. Start bitcoind
144+
141145
```shell
142146
just start
143147
```
@@ -147,8 +151,10 @@ Note: You can modify the `Justfile` to reflect your nodes' configuration values.
147151
```shell
148152
just create
149153
```
154+
150155
or
151-
```shell
156+
157+
```shell
152158
just load
153159
```
154160

@@ -157,18 +163,21 @@ Note: You can modify the `Justfile` to reflect your nodes' configuration values.
157163
```shell
158164
just address
159165
```
160-
166+
161167
4. Mine 101 blocks on regtest to bitcoind wallet address
168+
162169
```shell
163170
just generate 101 $(just address)
164171
```
165172

166173
5. Check the bitcoind wallet balance
174+
167175
```shell
168176
just balance
169177
```
170178

171179
6. Setup your `bdk-cli` wallet config and connect it to your regtest node to perform a `sync`
180+
172181
```shell
173182
export NETWORK=regtest
174183
export EXT_DESCRIPTOR='wpkh(tprv8ZgxMBicQKsPdMzWj9KHvoExKJDqfZFuT5D8o9XVZ3wfyUcnPNPJKncq5df8kpDWnMxoKbGrpS44VawHG17ZSwTkdhEtVRzSYXd14vDYXKw/0/*)'
@@ -178,12 +187,14 @@ Note: You can modify the `Justfile` to reflect your nodes' configuration values.
178187
```
179188

180189
7. Generate an address from your `bdk-cli` wallet and fund it with 10 bitcoins from your bitcoind node's wallet
190+
181191
```shell
182192
export address=$(cargo run --features rpc -- wallet -u "127.0.0.1:18443" -c rpc -a user:password new_address | jq '.address')
183193
just send 10 $address
184194
```
185195

186196
8. Mine 6 more blocks to the bitcoind wallet
197+
187198
```shell
188199
just generate 6 $(just address)
189200
```
@@ -196,9 +207,16 @@ Note: You can modify the `Justfile` to reflect your nodes' configuration values.
196207

197208
## Formatting Responses using `--pretty` flag
198209

199-
You can optionally return outputs of commands in human-readable, tabular format instead of `JSON`. To enable this option, simply add the `--pretty` flag as a top level flag. For instance, you wallet's balance in a pretty format, you can run:
210+
You can optionally return outputs of commands in human-readable, tabular format instead of `JSON`. To enable this option, simply add the `--pretty` flag as a top level flag. For instance, you wallet's balance in a pretty format, you can run:
200211

201212
```shell
202213
cargo run --pretty -n signet wallet -w {wallet_name} -d sqlite balance
203214
```
215+
216+
or using the short `-j` for pretty
217+
218+
```shell
219+
cargo run -j -n signet wallet -w {wallet_name} -d sqlite balance
220+
```
221+
204222
This is available for wallet, key, repl and compile features. When ommitted, outputs default to `JSON`.

src/commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct CliOpts {
5151
#[arg(env = "DATADIR", short = 'd', long = "datadir")]
5252
pub datadir: Option<std::path::PathBuf>,
5353
/// Output results in pretty format (instead of JSON).
54-
#[arg(long = "pretty", short = 'P', global = true)]
54+
#[arg(long = "pretty", short = 'j', global = true)]
5555
pub pretty: bool,
5656
/// Top level cli sub-commands.
5757
#[command(subcommand)]

0 commit comments

Comments
 (0)