From 8aef963ef149ed6088715af61b7e2f81bafde937 Mon Sep 17 00:00:00 2001 From: einliterflasche Date: Mon, 23 Feb 2026 19:08:50 +0100 Subject: [PATCH] use call_async for full scans instead of any_client Instead of relying on the single electrum server to work for the full scan (which is required to successfully start the app), we use the electrum pool fallback mechanism (try other servers/clients after one errored). This tries to address the "Failed to initialize Bitcoin wallet: EOF" repeatedly reported, for example in #886. --- bitcoin-wallet/src/wallet.rs | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/bitcoin-wallet/src/wallet.rs b/bitcoin-wallet/src/wallet.rs index 3648d866b..ee2e7c934 100644 --- a/bitcoin-wallet/src/wallet.rs +++ b/bitcoin-wallet/src/wallet.rs @@ -555,24 +555,22 @@ impl Wallet { let progress_handle = tauri_handle.as_ref().map(|th| th.start_full_scan()); - let callback = progress_handle.clone().and_then(|ph| InnerSyncCallback::new(move |consumed, total| { - ph.update(consumed,total); - })).chain(InnerSyncCallback::new(move |consumed, total| { - tracing::debug!( - "Full scanning Bitcoin wallet, currently at index {}. We will scan around {} in total.", - consumed, - total - ); - }).throttle_callback(10.0)).to_full_scan_callback(Self::SCAN_STOP_GAP, 100); - - let full_scan = wallet.start_full_scan().inspect(callback); + let wallet = Arc::new(wallet); + let ph = progress_handle.clone(); + let full_scan_response = client.inner.call_async("full_scan_wallet", move |electrum_client| { + let callback = ph.clone().and_then(|ph| InnerSyncCallback::new(move |consumed, total| { + ph.update(consumed, total); + })).chain(InnerSyncCallback::new(move |consumed, total| { + tracing::debug!( + "Full scanning Bitcoin wallet, currently at index {}. We will scan around {} in total.", + consumed, + total + ); + }).throttle_callback(10.0)).to_full_scan_callback(Self::SCAN_STOP_GAP, 100); - let full_scan_response = client.inner.get_any_client().await?.full_scan( - full_scan, - Self::SCAN_STOP_GAP as usize, - Self::SCAN_BATCH_SIZE as usize, - true, - )?; + let full_scan = wallet.start_full_scan().inspect(callback); + electrum_client.full_scan(full_scan, Self::SCAN_STOP_GAP as usize, Self::SCAN_BATCH_SIZE as usize, true) + }).await?; // Only create the persister once we have the full scan result let mut persister = persister_constructor()?;