diff --git a/src/access.rs b/src/access.rs index 3ad52ecdf..f2ef1cda4 100644 --- a/src/access.rs +++ b/src/access.rs @@ -221,22 +221,25 @@ where &self, confirmables: &Vec<&(dyn Confirm + Sync)>, ) -> Result<(), Error> { let client = &*self.blockchain; - // Query the interface for relevant txids and check whether they have been - // reorged-out of the chain. - let relevant_txids = - confirmables.iter().flat_map(|c| c.get_relevant_txids()).collect::>(); - for txid in relevant_txids { - let tx_unconfirmed = client - .get_tx_status(&txid) - .await - .ok() - .unwrap_or(None) - .map_or(true, |status| !status.confirmed); - if tx_unconfirmed { - for c in confirmables { - c.transaction_unconfirmed(&txid); + // Query the interface for relevant txids and check whether the relevant blocks are still + // in the best chain, mark them unconfirmed otherwise. If the transactions have been + // reconfirmed in another block, we'll confirm them in the next sync iteration. + let relevant_txids = confirmables + .iter() + .flat_map(|c| c.get_relevant_txids()) + .collect::)>>(); + for (txid, block_hash_opt) in relevant_txids { + if let Some(block_hash) = block_hash_opt { + let block_status = client.get_block_status(&block_hash).await?; + if block_status.in_best_chain { + // Skip if the block in queestion is still confirmed. + continue; } } + + for c in confirmables { + c.transaction_unconfirmed(&txid); + } } Ok(())