From 9d2bea240d43ac89b13897b9a79fa8965fd1c24b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Sat, 30 Jul 2022 21:47:09 +0800 Subject: [PATCH] Fix derivable-descriptor detection during wallet sync This fix is for electrum-based blockchains. Previously, it was assumed that containing > 1 spks in database means the descriptor is derivable, however each database tracks two descriptors so it should really check > 2. --- src/blockchain/script_sync.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/blockchain/script_sync.rs b/src/blockchain/script_sync.rs index 2c4b26cef..e1182ad7c 100644 --- a/src/blockchain/script_sync.rs +++ b/src/blockchain/script_sync.rs @@ -131,8 +131,9 @@ impl<'a, D: BatchDatabase> ScriptReq<'a, D> { let current_gap = self.script_index - last; // this is a hack to check whether the scripts are coming from a derivable descriptor - // we assume for non-derivable descriptors, the initial script count is always 1 - let is_derivable = self.initial_scripts_needed > 1; + // we assume for non-derivable descriptors, the initial script count is always 1 and + // as we are working with (at-most) 2 descriptors, we use 2 to determine derivability + let is_derivable = self.initial_scripts_needed > 2; debug!( "sync: last={}, remaining={}, diff={}, stop_gap={}",