Skip to content

Commit

Permalink
docs(rpc): add README and print ext address for FilterIter example
Browse files Browse the repository at this point in the history
  • Loading branch information
notmandatory committed Jan 25, 2025
1 parent 8fc03ee commit a6364e2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions crates/bitcoind_rpc/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Example bitcoind RPC sync

### Simple Signet Test with FilterIter

1. Start local signet bitcoind. (~8 GB space required)
```
mkdir -p /tmp/signet/bitcoind
bitcoind -signet -server -fallbackfee=0.0002 -blockfilterindex -datadir=/tmp/signet/bitcoind -daemon
tail -f /tmp/signet/bitcoind/signet/debug.log
```
Watch debug.log and wait for bitcoind to finish syncing.

2. Set bitcoind env variables.
```
export RPC_URL=127.0.0.1:38332
export RPC_COOKIE=/tmp/signet/bitcoind/signet/.cookie
```
3. Run `filter_iter` example.
```
cargo run -p bdk_bitcoind_rpc --example filter_iter
```
5 changes: 5 additions & 0 deletions crates/bitcoind_rpc/examples/filter_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use bdk_chain::local_chain::LocalChain;
use bdk_chain::miniscript::Descriptor;
use bdk_chain::{BlockId, ConfirmationBlockTime, IndexedTxGraph, SpkIterator};
use bdk_testenv::anyhow;
use bitcoin::Address;

// This example shows how BDK chain and tx-graph structures are updated using compact
// filters syncing. Assumes a connection can be made to a bitcoin node via environment
Expand Down Expand Up @@ -102,5 +103,9 @@ fn main() -> anyhow::Result<()> {
}
}

let unused_spk = graph.index.reveal_next_spk("external").unwrap().0 .1;
let unused_address = Address::from_script(&unused_spk, NETWORK)?;
println!("Next external address: {}", unused_address);

Ok(())
}

0 comments on commit a6364e2

Please sign in to comment.