Skip to content

Commit

Permalink
Fix derivable-descriptor detection during wallet sync
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
evanlinjin committed Jul 30, 2022
1 parent a147740 commit 9349d3c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"rust-analyzer.cargo.noDefaultFeatures": true,
"rust-analyzer.cargo.features": [
"test-blockchains",
"test-rpc",
// "compact_filters",
"verify",
]
}
5 changes: 3 additions & 2 deletions src/blockchain/script_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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={}",
Expand Down

0 comments on commit 9349d3c

Please sign in to comment.