From 2524da3a128a0adf9d441b945c727c7a4c247ec2 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Thu, 12 Jun 2025 20:06:42 -0500 Subject: [PATCH] docs: reformat and simplify README steps for just & bitcoind --- Justfile | 5 ++++ README.md | 87 ++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 59 insertions(+), 33 deletions(-) diff --git a/Justfile b/Justfile index c1c462a..013c407 100644 --- a/Justfile +++ b/Justfile @@ -95,3 +95,8 @@ send n address wallet=default_wallet: [group('rpc')] descriptors private wallet=default_wallet: bitcoin-cli -datadir={{default_datadir}} -regtest -rpcwallet={{wallet}} -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} listdescriptors {{private}} + +# run any bitcoin-cli rpc command +[group('rpc')] +rpc command wallet=default_wallet: + bitcoin-cli -datadir={{default_datadir}} -regtest -rpcwallet={{wallet}} -rpcuser={{rpc_user}} -rpcpassword={{rpc_password}} {{command}} \ No newline at end of file diff --git a/README.md b/README.md index 20ea115..e5d8774 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ just build # build the project ### Using `Justfile` to run `bitcoind` as a Client -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 `start`, `connect` and `run` your `bitcoind` node: +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`: 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` @@ -139,40 +139,61 @@ Note: You can modify the `Justfile` to reflect your nodes' configuration values. #### Steps 1. Start bitcoind - ->> `just start` - -2. Create or load a wallet - - >> `just create` # if you do not have an existing default wallet (regtest_default_wallet) - - >> `load wallet` # if you have an existing default wallet - -3. Generate an address to mine regtest bitcoins. - ->> `just address` # if you want to save to use in the next step `address=$(just address)` - -4. Mine bitcoin - ->> `just generate 101 $address` # or just generate to a new addres `just generate 101 (just address)` - -5. Check Balance - ->> `just balance` - -6. Connect your `bdk-cli` wallet to your node and perform a full_scan - ->> `cargo run --features rpc -- -n regtest wallet -w {your-bdk-cli-wallet-name} -u "127.0.0.1:18443" -c rpc -a user:password -d sqlite full_scan` + ```shell + just start + ``` + +2. Create or load a bitcoind wallet with default wallet name + + ```shell + just create + ``` + or + ```shell + just load + ``` + +3. Generate a bitcoind wallet address to send regtest bitcoins to. + + ```shell + just address + ``` + +4. Mine 101 blocks on regtest to bitcoind wallet address + ```shell + just generate 101 $(just address) + ``` + +5. Check the bitcoind wallet balance + ```shell + just balance + ``` + +6. Setup your `bdk-cli` wallet config and connect it to your regtest node to perform a `sync` + ```shell + 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 + ``` 7. Generate an address from your `bdk-cli` wallet and fund it with 10 bitcoins from your bitcoind node's wallet - ->> `just send 10 {your-bdk-cli-wallet-address-here}` - -8. Mine 6 more blocks - ->> `just generate 6 $address` - -You can `sync` your `bdk-cli` wallet now and the balance should reflect + ```shell + 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 + ``` + +8. Mine 6 more blocks to the bitcoind wallet + ```shell + just generate 6 $(just address) + ``` + +9. You can `sync` your `bdk-cli` wallet now and the balance should reflect the regtest bitcoin you received + ```shell + 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 + ``` ## Minimum Supported Rust Version (MSRV) -- 2.49.0