]> Untitled Git - bdk/commitdiff
fix(electrum): fixed `sync` functionality
authorWei Chen <wzc110@gmail.com>
Mon, 6 May 2024 07:52:57 +0000 (15:52 +0800)
committer志宇 <hello@evanlinjin.me>
Fri, 10 May 2024 06:54:28 +0000 (14:54 +0800)
crates/electrum/src/electrum_ext.rs

index a746c52cf472d778e4c719ff7abcb9d2eec3afe1..4c6786557cd6444c623688c78e46a4251c367e81 100644 (file)
@@ -147,7 +147,7 @@ impl<E: ElectrumApi> ElectrumExt for E {
         let full_scan_req = FullScanRequest::from_chain_tip(request.chain_tip.clone())
             .cache_txs(request.tx_cache)
             .set_spks_for_keychain((), request.spks.enumerate().map(|(i, spk)| (i as u32, spk)));
-        let full_scan_res = self.full_scan(full_scan_req, usize::MAX, batch_size)?;
+        let mut full_scan_res = self.full_scan(full_scan_req, usize::MAX, batch_size)?;
 
         let (tip, _) = construct_update_tip(self, request.chain_tip)?;
         let cps = tip
@@ -156,9 +156,20 @@ impl<E: ElectrumApi> ElectrumExt for E {
             .map(|cp| (cp.height(), cp))
             .collect::<BTreeMap<u32, CheckPoint>>();
 
-        let mut tx_graph = TxGraph::<ConfirmationHeightAnchor>::default();
-        populate_with_txids(self, &cps, &mut tx_cache, &mut tx_graph, request.txids)?;
-        populate_with_outpoints(self, &cps, &mut tx_cache, &mut tx_graph, request.outpoints)?;
+        populate_with_txids(
+            self,
+            &cps,
+            &mut tx_cache,
+            &mut full_scan_res.graph_update,
+            request.txids,
+        )?;
+        populate_with_outpoints(
+            self,
+            &cps,
+            &mut tx_cache,
+            &mut full_scan_res.graph_update,
+            request.outpoints,
+        )?;
 
         Ok(SyncResult {
             chain_update: full_scan_res.chain_update,