| Crates.io | bdk-cli |
| lib.rs | bdk-cli |
| version | 2.0.0 |
| created_at | 2021-01-08 19:31:42.401064+00 |
| updated_at | 2025-09-10 18:22:06.411729+00 |
| description | An experimental CLI wallet application and playground, powered by BDK |
| homepage | https://bitcoindevkit.org |
| repository | https://github.com/bitcoindevkit/bdk-cli |
| max_upload_size | |
| id | 334688 |
| size | 235,741 |
EXPERIMENTAL
This crate has been updated to use bdk_wallet 1.x. Only use for testing on test networks.
This project provides a command-line Bitcoin wallet application using the latest BDK Wallet APIs and chain sources (RPC, Electrum, Esplora, 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. And yes, it can do Taproot!!
This crate can be used for the following purposes:
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).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.
sqlite : Sets the wallet database to a sqlite3 db.esplora : Connects the wallet to an esplora server.electrum : Connects the wallet to an electrum server.kyoto: Connects the wallet to a kyoto client and server.rpc: Connects the wallet to Bitcoind server.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.
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 electrum blockchain client feature.
RUST_LOG=debug cargo run --features electrum -- --network testnet4 wallet --wallet testnetwallet --ext-descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" --client-type electrum --database-type sqlite --url "ssl://mempool.space:40002" sync
Available blockchain client features are:
electrum, esplora, kyoto, rpc.
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
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 -- --network testnet4 wallet --wallet sample_wallet --ext-descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" --database-type sqlite --client-type electrum --url "ssl://mempool.space:40002" sync
To get a wallet balance with customized logging:
RUST_LOG=debug,rusqlite=info,rustls=info cargo run -- wallet --external-descriptor "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)" balance
To generate a new extended master key, suitable for use in a descriptor:
cargo run -- key generate
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.
Visit the just page for setup instructions.
The below are some of the commands included:
just # list all available recipes
just test # test the project
just build # build the project
Justfile to run bitcoind as a ClientIf 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:
Note: You can modify the Justfile to reflect your nodes' configuration values. These values are the default values used in bdk-cli
- default wallet: The set default wallet name is
regtest_default_wallet- default data directory: The set default data directory is
~/.bdk-bitcoin- RPC username: The set RPC username is
user- RPC password: The set RPC password is
password
Start bitcoind
just start
Create or load a bitcoind wallet with default wallet name
just create
or
just load
Generate a bitcoind wallet address to send regtest bitcoins to.
just address
Mine 101 blocks on regtest to bitcoind wallet address
just generate 101 $(just address)
Check the bitcoind wallet balance
just balance
Setup your bdk-cli wallet config and connect it to your regtest node to perform a sync
export NETWORK=regtest
export EXT_DESCRIPTOR='wpkh(tprv8ZgxMBicQKsPdMzWj9KHvoExKJDqfZFuT5D8o9XVZ3wfyUcnPNPJKncq5df8kpDWnMxoKbGrpS44VawHG17ZSwTkdhEtVRzSYXd14vDYXKw/0/*)'
export INT_DESCRIPTOR='wpkh(tprv8ZgxMBicQKsPdMzWj9KHvoExKJDqfZFuT5D8o9XVZ3wfyUcnPNPJKncq5df8kpDWnMxoKbGrpS44VawHG17ZSwTkdhEtVRzSYXd14vDYXKw/1/*)'
export DATABASE_TYPE=sqlite
cargo run --features rpc -- wallet -u "127.0.0.1:18443" -c rpc -a user:password sync
Generate an address from your bdk-cli wallet and fund it with 10 bitcoins from your bitcoind node's wallet
export address=$(cargo run --features rpc -- wallet -u "127.0.0.1:18443" -c rpc -a user:password new_address | jq '.address')
just send 10 $address
Mine 6 more blocks to the bitcoind wallet
just generate 6 $(just address)
You can sync your bdk-cli wallet now and the balance should reflect the regtest bitcoin you received
cargo run --features rpc -- wallet -u "127.0.0.1:18443" -c rpc -a user:password sync
cargo run --features rpc -- wallet -u "127.0.0.1:18443" -c rpc -a user:password balance
--pretty flagYou 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:
cargo run --pretty -n signet wallet -w {wallet_name} -d sqlite balance
This is available for wallet, key, repl and compile features. When ommitted, outputs default to JSON.