From 63cd6ead368cdec0511a82a6bfe0634e798ca57b Mon Sep 17 00:00:00 2001 From: Ross Savage <551697+dangeross@users.noreply.github.com> Date: Mon, 31 Mar 2025 10:28:18 +0200 Subject: [PATCH] Only full_scan_to_index when not using waterfalls (#833) --- lib/core/src/wallet.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/core/src/wallet.rs b/lib/core/src/wallet.rs index b8c2a9c..a493478 100644 --- a/lib/core/src/wallet.rs +++ b/lib/core/src/wallet.rs @@ -105,7 +105,7 @@ pub trait OnchainWallet: MaybeSend + MaybeSync { pub enum WalletClient { #[cfg(not(all(target_family = "wasm", target_os = "unknown")))] Electrum(Box), - Esplora(Box), + Esplora(Box, /* waterfalls */ bool), } impl WalletClient { @@ -120,13 +120,14 @@ impl WalletClient { url, use_waterfalls, } => { + let waterfalls = *use_waterfalls; let client = Box::new( EsploraClientBuilder::new(url, config.network.into()) .timeout(3) - .waterfalls(*use_waterfalls) + .waterfalls(waterfalls) .build(), ); - Ok(Self::Esplora(client)) + Ok(Self::Esplora(client, waterfalls)) } } } @@ -141,8 +142,13 @@ impl WalletClient { WalletClient::Electrum(electrum_client) => { electrum_client.full_scan_to_index(&wallet.state(), index)? } - WalletClient::Esplora(esplora_client) => { - esplora_client.full_scan_to_index(wallet, index).await? + WalletClient::Esplora(esplora_client, waterfalls) => { + if *waterfalls { + // Avoid a `UsingWaterfallsWithNonZeroIndex` error by not passing the index + esplora_client.full_scan(wallet).await? + } else { + esplora_client.full_scan_to_index(wallet, index).await? + } } };