From: Steve Myers Date: Sat, 25 Jan 2025 00:29:43 +0000 (-0600) Subject: docs(rpc): add README and print ext address for FilterIter example X-Git-Tag: bitcoind_rpc-0.18.0~3^2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/scripts/combine.html?a=commitdiff_plain;h=a6364e20500fba7c16f31fa97d106893110751c6;p=bdk docs(rpc): add README and print ext address for FilterIter example --- diff --git a/crates/bitcoind_rpc/examples/README.md b/crates/bitcoind_rpc/examples/README.md new file mode 100644 index 00000000..34cee07b --- /dev/null +++ b/crates/bitcoind_rpc/examples/README.md @@ -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 + ``` \ No newline at end of file diff --git a/crates/bitcoind_rpc/examples/filter_iter.rs b/crates/bitcoind_rpc/examples/filter_iter.rs index 8952af4f..55c3325d 100644 --- a/crates/bitcoind_rpc/examples/filter_iter.rs +++ b/crates/bitcoind_rpc/examples/filter_iter.rs @@ -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 @@ -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(()) }