From ea21d81b3313664381a8e19af1971599bfb7ced1 Mon Sep 17 00:00:00 2001 From: Alexander Shevtsov Date: Sat, 16 May 2026 02:24:36 +0200 Subject: [PATCH 1/2] Use kyoto's rescan_from(h) instead of rescan() Previously rescan would go from kyoto's build-time checkpoint, which might be a very old block. We can explicitely use rescan_from(height) to process only new blocks. --- src/chain/cbf.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/chain/cbf.rs b/src/chain/cbf.rs index eb53678bbc..8e0a7b3391 100644 --- a/src/chain/cbf.rs +++ b/src/chain/cbf.rs @@ -548,7 +548,14 @@ impl CbfChainSource { let (tx, rx) = oneshot::channel(); *self.sync_completion_tx.lock().expect("lock") = Some(tx); - if let Err(e) = requester.rescan().map_err(|e| { + // Delegate the skip to kyoto so it doesn't re-stream filters we would discard + // client-side via filter_skip_height. Without `_from`, kyoto replays from its + // build-time checkpoint (potentially genesis on a fresh wallet) every tick. + let rescan_res = match skip_before_height { + Some(h) => requester.rescan_from(h), + None => requester.rescan(), + }; + if let Err(e) = rescan_res.map_err(|e| { log_error!(self.logger, "Failed to trigger CBF rescan: {:?}", e); Error::WalletOperationFailed }) { From d7bd7135de2da69d1f0918afc4113c7173c064da Mon Sep 17 00:00:00 2001 From: Alexander Shevtsov Date: Sat, 16 May 2026 02:50:32 +0200 Subject: [PATCH 2/2] Bump kyoto version to 0.6.0 --- Cargo.toml | 2 +- src/chain/cbf.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c58b2b6ff4..5c94ee7fdf 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,7 @@ lightning-dns-resolver = { git = "https://github.com/lightningdevkit/rust-lightn bdk_chain = { version = "0.23.0", default-features = false, features = ["std"] } bdk_esplora = { version = "0.22.0", default-features = false, features = ["async-https-rustls", "tokio"]} bdk_electrum = { version = "0.23.0", default-features = false, features = ["use-rustls-ring"]} -bip157 = { version = "0.5.0", default-features = false } +bip157 = { version = "0.6.0", default-features = false } bdk_wallet = { version = "2.3.0", default-features = false, features = ["std", "keys-bip39"]} bitreq = { version = "0.3", default-features = false, features = ["async-https", "json-using-serde"] } diff --git a/src/chain/cbf.rs b/src/chain/cbf.rs index 8e0a7b3391..07e0cc0d7d 100644 --- a/src/chain/cbf.rs +++ b/src/chain/cbf.rs @@ -17,7 +17,7 @@ use bdk_wallet::{KeychainKind, Update}; use bip157::chain::{BlockHeaderChanges, ChainState}; use bip157::error::FetchBlockError; use bip157::{ - BlockHash, Builder, Client, Event, HeaderCheckpoint, Info, Node as CbfNode, Requester, + BlockHash, Builder, Client, Event, HashCheckpoint, Info, Node as CbfNode, Requester, SyncUpdate, TrustedPeer, Warning, }; use bitcoin::constants::SUBSIDY_HALVING_INTERVAL; @@ -242,7 +242,7 @@ impl CbfChainSource { } } if cursor.height() > 0 { - let header_cp = HeaderCheckpoint::new(cursor.height(), cursor.hash()); + let header_cp = HashCheckpoint::new(cursor.height(), cursor.hash()); builder = builder.chain_state(ChainState::Checkpoint(header_cp)); log_debug!( logger,