From be520c1444d5cee14d5bb204e5f76131a44d28de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Tue, 3 Dec 2024 23:28:22 +1100 Subject: [PATCH] fix(electrum): Avoid fetching prev txout of coinbase txs Coinbase txs do not have previous txs. The previous txout fields are always of empty txids. Requesting such a transaction from electrum will return an error and fail our full-scan/sync request. This will be unfortunate if a miner decides to use a wallet which uses BDK + Electrum. --- crates/electrum/src/bdk_electrum_client.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/electrum/src/bdk_electrum_client.rs b/crates/electrum/src/bdk_electrum_client.rs index f9e53bff8..6449ad4ac 100644 --- a/crates/electrum/src/bdk_electrum_client.rs +++ b/crates/electrum/src/bdk_electrum_client.rs @@ -422,6 +422,11 @@ impl BdkElectrumClient { ) -> Result<(), Error> { let mut no_dup = HashSet::::new(); for tx in &tx_update.txs { + // Do not try fetch `previous_output`s of coinbase transactions. This will always error + // and make our full-scan/sync request fail. + if tx.is_coinbase() { + continue; + } if no_dup.insert(tx.compute_txid()) { for vin in &tx.input { let outpoint = vin.previous_output;