]> Untitled Git - bdk-cli/commitdiff
chore: Update bdk_wallet to v2.3
authorVihiga Tyonum <withtvpeter@gmail.com>
Wed, 11 Feb 2026 16:34:15 +0000 (17:34 +0100)
committerVihiga Tyonum <withtvpeter@gmail.com>
Tue, 30 Jun 2026 19:12:25 +0000 (20:12 +0100)
- Add wallet events to full_scan and sync
subcommands

Cargo.lock
Cargo.toml
src/handlers.rs
src/utils.rs

index d984ac41a0f535cddaafbb1326a3291b21657263..e20f66f1cedca10623900bd6732d0785cd4dcfdd 100644 (file)
@@ -325,9 +325,9 @@ dependencies = [
 
 [[package]]
 name = "bdk_wallet"
-version = "2.1.0"
+version = "2.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d30b5dba770184863b5d966ccbc6a11d12c145450be3b6a4435308297e6a12dc"
+checksum = "b03f1e31ccc562f600981f747d2262b84428cbff52c9c9cdf14d15fb15bd2286"
 dependencies = [
  "bdk_chain",
  "bip39",
index 460366214c558a1b4f00614e58adaf86e6682319..b871f4b3d95ea745b669e525abcc4b360a644a3f 100644 (file)
@@ -12,7 +12,7 @@ readme = "README.md"
 license = "MIT"
 
 [dependencies]
-bdk_wallet = { version = "2.1.0", features = ["rusqlite", "keys-bip39", "compiler", "std"] }
+bdk_wallet = { version = "2.3.0", features = ["rusqlite", "keys-bip39", "compiler", "std"] }
 clap = { version = "4.6", features = ["derive","env"] }
 clap_complete = "4.6"
 dirs = {  version = "6.0.0" }
index 72762336bb5ce39137ed8f9e13c0428647dff7c7..a6e4e293fb321722cc25037b988ce574012b1169 100644 (file)
@@ -888,8 +888,9 @@ pub(crate) async fn handle_online_wallet_subcommand(
                     client
                         .populate_tx_cache(wallet.tx_graph().full_txs().map(|tx_node| tx_node.tx));
 
-                    let update = client.full_scan(request, _stop_gap, *batch_size, false)?;
-                    wallet.apply_update(update)?;
+                    let update = client.full_scan(request, _stop_gap, batch_size, false)?;
+                    let wallet_events = wallet.apply_update_events(update)?;
+                    print_wallet_events(&wallet_events);
                 }
                 #[cfg(feature = "esplora")]
                 Esplora {
@@ -900,7 +901,8 @@ pub(crate) async fn handle_online_wallet_subcommand(
                         .full_scan(request, _stop_gap, *parallel_requests)
                         .await
                         .map_err(|e| *e)?;
-                    wallet.apply_update(update)?;
+                    let wallet_events = wallet.apply_update_events(update)?;
+                    print_wallet_events(&wallet_events);
                 }
 
                 #[cfg(feature = "rpc")]
@@ -1834,10 +1836,12 @@ pub async fn sync_wallet(client: &BlockchainClient, wallet: &mut Wallet) -> Resu
             // already have.
             client.populate_tx_cache(wallet.tx_graph().full_txs().map(|tx_node| tx_node.tx));
 
-            let update = client.sync(request, *batch_size, false)?;
-            wallet
-                .apply_update(update)
-                .map_err(|e| Error::Generic(e.to_string()))
+            let update = client.sync(request, batch_size, false)?;
+            let wallet_events = wallet
+                .apply_update_events(update)
+                .map_err(|e| Error::Generic(e.to_string()))?;
+            print_wallet_events(&wallet_events);
+            Ok(())
         }
         #[cfg(feature = "esplora")]
         Esplora {
@@ -1848,9 +1852,11 @@ pub async fn sync_wallet(client: &BlockchainClient, wallet: &mut Wallet) -> Resu
                 .sync(request, *parallel_requests)
                 .await
                 .map_err(|e| *e)?;
-            wallet
-                .apply_update(update)
-                .map_err(|e| Error::Generic(e.to_string()))
+            let wallet_events = wallet
+                .apply_update_events(update)
+                .map_err(|e| Error::Generic(e.to_string()))?;
+            print_wallet_events(&wallet_events);
+            Ok(())
         }
         #[cfg(feature = "rpc")]
         RpcClient { client } => {
index 34baf8674c26b1ea4e741053ff9a861a940e7470..3f77539a2d4d8632965b6dee5fc1366650a9398e 100644 (file)
@@ -45,6 +45,8 @@ use cli_table::{Cell, CellStruct, Style, Table};
     feature = "cbf"
 ))]
 use crate::commands::ClientType;
+#[cfg(any(feature = "electrum", feature = "esplora",))]
+use bdk_wallet::event::WalletEvent;
 
 use bdk_wallet::Wallet;
 #[cfg(any(feature = "sqlite", feature = "redb"))]
@@ -704,3 +706,45 @@ pub fn load_wallet_config(
 
     Ok((wallet_opts, network))
 }
+#[cfg(any(feature = "electrum", feature = "esplora",))]
+pub fn print_wallet_events(events: &Vec<WalletEvent>) {
+    for event in events {
+        match event {
+            WalletEvent::TxConfirmed {
+                txid,
+                tx: _,
+                block_time,
+                old_block_time: _,
+            } => {
+                eprintln!(
+                    "Transaction {} confirmed in block {:?}",
+                    txid, block_time.block_id
+                );
+            }
+            WalletEvent::TxUnconfirmed {
+                txid,
+                tx: _,
+                old_block_time: _,
+            } => {
+                eprintln!("Transaction {txid} became unconfirmed");
+            }
+            WalletEvent::TxReplaced {
+                txid,
+                tx: _,
+                conflicts: _,
+            } => {
+                eprintln!("Received new transaction: {txid}");
+            }
+            WalletEvent::TxDropped { txid, tx: _ } => {
+                eprintln!("Transaction {txid} has been dropped");
+            }
+            WalletEvent::ChainTipChanged { old_tip, new_tip } => {
+                eprintln!(
+                    "Wallet has synced to {:?} chain tip from {:?}",
+                    new_tip.height, old_tip.height
+                );
+            }
+            _ => eprintln!(),
+        }
+    }
+}