Skip to content

Commit

Permalink
Merge #104: Update crate documentation
Browse files Browse the repository at this point in the history
f8a5999 Minor grammar and puctuation fixes (Steve Myers)
e7b6854 Update with Readme fixes (rajarshimaitra)
52e8c61 Add all `possible_values` to network command option (Leonardo Lima)
179618c Update crate documentation (rajarshimaitra)

Pull request description:

  ### Description

  After #99 the previous documentation have been removed and new docs as per `structopts` documentation. This PR adds more documentation across the crate..

  This PR is above #102 , to accommodate all the further refactoring changes.

  The Readme About section have been updated with more details.. Readme format made aligned with the BDK project itself..

  The Readme file is used itself as the crate level documentation in docs.rs too..

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk-cli/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  notmandatory:
    ACK f8a5999

Tree-SHA512: 26c5b3903b0215aa9841c4d1079bbdeb9f9d9d458c7e27dddb625db24eb364b73ca978bb2018f486215878f3601b5572ca58d5c202cb74325c992f3e7107d850
  • Loading branch information
rajarshimaitra committed Sep 20, 2022
2 parents 7869bdb + f8a5999 commit 352d6c8
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 142 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Change rpc `--skip-blocks` option to `--start-time` which specifies time initial sync will start scanning from.
- Add new `bdk-cli node <command> [<args>]` to control the backend node deployed by `regtest-*` features.
- Add an integration testing framework in `src/tests/integration.rs`. This framework uses the `regtest-*` feature to run automated testing with bdk-cli.
- Add possible values for `network` option to improve help message, and fix typo in doc.

## [0.5.0]

Expand Down
76 changes: 63 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,66 @@
# bdk-cli lib and example bin tool
<div align="center">
<h1>BDK-CLI</h1>

<img src="https://github.com/bitcoindevkit/bdk/raw/master/static/bdk.png" width="220" />

<p>
<strong>A Command-line Bitcoin Wallet App in pure rust using BDK</strong>
</p>

<p>
<a href="https://crates.io/crates/bdk-cli"><img alt="Crate Info" src="https://img.shields.io/crates/v/bdk-cli.svg"/></a>
<a href="https://github.com/bitcoindevkit/bdk-cli/blob/master/LICENSE"><img alt="MIT or Apache-2.0 Licensed" src="https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg"/></a>
<a href="https://github.com/bitcoindevkit/bdk-cli/actions?query=workflow%3ACI"><img alt="CI Status" src="https://github.com/bitcoindevkit/bdk-cli/workflows/CI/badge.svg"></a>
<a href="https://codecov.io/gh/bitcoindevkit/bdk-cli"><img src="https://codecov.io/gh/bitcoindevkit/bdk-cli/branch/master/graph/badge.svg"/></a>
<a href="https://docs.rs/bdk-cli"><img alt="API Docs" src="https://img.shields.io/badge/docs.rs-bdk_cli-green"/></a>
<a href="https://blog.rust-lang.org/2020/08/27/Rust-1.56.0.html"><img alt="Rustc Version 1.56+" src="https://img.shields.io/badge/rustc-1.56%2B-lightgrey.svg"/></a>
<a href="https://discord.gg/d7NkDKm"><img alt="Chat on Discord" src="https://img.shields.io/discord/753336465005608961?logo=discord"></a>
</p>

<h4>
<a href="https://bitcoindevkit.org">Project Homepage</a>
<span> | </span>
<a href="https://docs.rs/bdk-cli">Documentation</a>
</h4>
</div>

![CI](https://github.com/bitcoindevkit/bdk-cli/workflows/CI/badge.svg)
![Code Coverage](https://github.com/bitcoindevkit/bdk-cli/workflows/Code%20Coverage/badge.svg)

## About

This project provides a command line interface (cli) Bitcoin wallet library and [`REPL`](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)
wallet tool based on the [bdk](https://github.com/bitcoindevkit/bdk) library.
This project provides a command-line Bitcoin wallet application using the latest [BDK APIs](https://docs.rs/bdk/latest/bdk/wallet/struct.Wallet.html). This might look tiny and innocent, but by harnessing the power of BDK it provides a powerful generic descriptor based command line wallet tool.
And yes, it can do Taproot!!

This crate can be used for the following purposes:
- Instantly create a miniscript based wallet and connect to your backend of choice (Electrum, Esplora, Core RPC, CBF etc) and quickly play around with your own complex bitcoin scripting workflow. With one or many wallets, connected with one or many backends.
- 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).
- (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.

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/latest/bdk/index.html)

bdk-cli can be compiled with different features to suit your experimental needs.
- Database Options
- `key-value-db` : Sets the wallet database to a `sled` db.
- `sqlite-db` : Sets the wallet database to a `sqlite3` db.
- Blockchain Options
- `rpc` : Connects the wallet to bitcoin core via RPC.
- `electrum` : Connects the wallet to an electrum server.
- `compact_filters` : Deploy a BIP157 node to get blockchain data from the bitcoin p2p network.
- `esplora-ureq` or `esplora-reqwest` : Connects the wallet to an esplora server synchronously or asynchronously.
- Extra Utility Tools
- `repl` : use bdk-cli as a [REPL](https://codewith.mu/en/tutorials/1.0/repl) shell (useful for quick manual testing of wallet operations).
- `compiler` : opens up bdk-cli policy compiler commands.
- `verify` : uses `bitcoinconsensus` to verify transactions at every `sync` call of the wallet.
- `reserves` : opens up bdk-cli **Proof of Reserves** operation commands using the [bdk-reserves plugin](https://github.com/bitcoindevkit/bdk-reserves). (requires the `electrum` feature)
- Automated Node Backend
- `regtest-bitcoin` : Auto deploys a regtest `bitcoind` node, connects the wallet, and exposes core rpc commands via `bdk-cli node` subcommands.
- `regtest-electrum` : Auto deploys `electrsd` and connected `bitcoind` nodes, exposes core rpc commands via `bdk-cli node` and provides a wallet connected to the local `electrsd`.

The `default` feature set is `repl` and `sqlite-db`. 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.


## Install bdk-cli
### From source
To install dev version of `bdk-cli` from local git repo with the `electrum` blockchain client enabled:
To install a dev version of `bdk-cli` from a local git repo with the `electrum` blockchain client enabled:

```shell
cd <bdk-cli git repo directory>
Expand All @@ -19,8 +69,8 @@ bdk-cli help # to verify it worked
```

If no blockchain client feature is enabled online wallet commands `sync` and `broadcast` will be
disabled. To enable these commands a blockchain client features such as `electrum` or another
blockchain backend feature must be enabled. Below is an example of how run the `bdk-cli` bin with
disabled. To enable these commands a blockchain client feature such as `electrum` or another
blockchain client feature must be enabled. Below is an example of how to run the `bdk-cli` binary with
the `esplora-ureq` blockchain client feature.

```shell
Expand All @@ -31,15 +81,15 @@ At most one blockchain feature can be enabled, available blockchain client featu
`electrum`, `esplora-ureq` (blocking), `esplora-reqwest` (async), `compact_filters` and `rpc`.

### From crates.io
You can the install the binaries for the latest tag of `bdk-cli` with online wallet features
You can install the binary for the latest tag of `bdk-cli` with online wallet features
directly from [crates.io](https://crates.io/crates/bdk-cli) with a command as below:
```sh
cargo install bdk-cli --features electrum
```

### bdk-cli bin usage examples

To get usage information for the `bdk-cli` bin use the below command which returns a list of
To get usage information for the `bdk-cli` binary use the below command which returns a list of
available wallet options and commands:

```shell
Expand All @@ -52,13 +102,13 @@ To sync a wallet to the default electrum server:
cargo run --features electrum -- wallet --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync
```

To sync a wallet to Bitcoin Core node (assuming a regtest node at 127.0.0.1:18443) using the core rpc:
To sync a wallet to a Bitcoin Core node (assuming a regtest node at 127.0.0.1:18443) using the core rpc:

```shell
cargo run --features rpc -- --network regtest wallet --node 127.0.0.1:18443 --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync
```

To sync a wallet to Bitcoin Core node (assuming a regtest node at 127.0.0.1:18444) serving compact filters:
To sync a wallet to a Bitcoin Core node (assuming a regtest node at 127.0.0.1:18444) serving compact filters:
Note:
- This will increase build time by few minutes for the binaries because of `librocksdb`.
- Bitcoin Core v0.21.0 or higher is required to serve compact filters.
Expand All @@ -73,7 +123,7 @@ To get a wallet balance with customized logging:
RUST_LOG=debug,sled=info,rustls=info cargo run -- wallet --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" get_balance
```

To generate a new extended master key, suitable for using in a descriptor:
To generate a new extended master key, suitable for use in a descriptor:

```shell
cargo run -- key generate
Expand Down
Loading

0 comments on commit 352d6c8

Please sign in to comment.