Skip to content

A CLI wallet library and REPL tool to demo and test the BDK library

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

bitcoindevkit/bdk-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2fa18a0 · Apr 13, 2025
Mar 12, 2025
Mar 12, 2025
Apr 13, 2025
Mar 6, 2025
Aug 12, 2021
Mar 27, 2023
Nov 24, 2020
Mar 12, 2025
Mar 6, 2025
Jan 11, 2023
Mar 14, 2022
Mar 14, 2022
Mar 14, 2022
Mar 12, 2025
Feb 18, 2025

BDK-CLI

A Command-line Bitcoin Wallet App in pure rust using BDK

Crate Info MIT or Apache-2.0 Licensed CI Status API Docs Rustc Version 1.57.0+ Chat on Discord

About

EXPERIMENTAL This crate is in to process of being updated to bdk_wallet 1.x. Only use with for testing on test networks.

This project provides a command-line Bitcoin wallet application using the latest BDK APIs. 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, 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 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 and the rust docs

bdk-cli can be compiled with different features to suit your experimental needs.

  • Database Options
    • sqlite : Sets the wallet database to a sqlite3 db.
  • Blockchain Client Options
    • esplora : Connects the wallet to an esplora server.
    • electrum : Connects the wallet to an electrum server.
  • Extra Utility Tools
    • repl : use bdk-cli as a REPL shell (useful for quick manual testing of wallet operations).
    • compiler : opens up bdk-cli policy compiler commands.

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.

Install bdk-cli

From source

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

cd <bdk-cli git repo directory>
cargo install --path . --features electrum
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 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 blockchain client feature.

RUST_LOG=debug cargo run --features esplora -- wallet --client-type esplora --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync

Available blockchain client features are: electrum, esplora.

From crates.io

You can install the binary for the latest tag of bdk-cli with online wallet features directly from crates.io with a command as below:

cargo install bdk-cli --features electrum

bdk-cli bin usage examples

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

cargo run

To sync a wallet to the default electrum server:

cargo run --features electrum -- wallet -c electrum --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" sync

To get a wallet balance with customized logging:

RUST_LOG=debug,rusqlite=info,rustls=info cargo run -- wallet --descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" get_balance

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

cargo run -- key generate

Minimum Supported Rust Version (MSRV)

This library should always compile with any valid combination of features on Rust 1.75.0.

Resources

Docs: bitcoindevkit.org CLI Section
Episode on the Bitcoin Developers Show: Youtube
Video Tutorials: Youtube Playlist