]> Untitled Git - bdk/commitdiff
docs(rpc): add README and print ext address for FilterIter example
authorSteve Myers <steve@notmandatory.org>
Sat, 25 Jan 2025 00:29:43 +0000 (18:29 -0600)
committerSteve Myers <steve@notmandatory.org>
Sat, 25 Jan 2025 00:39:25 +0000 (18:39 -0600)
crates/bitcoind_rpc/examples/README.md [new file with mode: 0644]
crates/bitcoind_rpc/examples/filter_iter.rs

diff --git a/crates/bitcoind_rpc/examples/README.md b/crates/bitcoind_rpc/examples/README.md
new file mode 100644 (file)
index 0000000..34cee07
--- /dev/null
@@ -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
index 8952af4f96021aedeae6de29254f98642e3e34a8..55c3325d70a542186b51554588386f9376d75e7c 100644 (file)
@@ -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(())
 }