]> Untitled Git - bdk/commitdiff
fix(electrum): prevent `fetch_prev_txout` from querying coinbase transactions
authorWei Chen <wzc110@gmail.com>
Wed, 6 Nov 2024 16:33:51 +0000 (00:33 +0800)
committerWei Chen <wzc110@gmail.com>
Fri, 6 Dec 2024 06:03:27 +0000 (14:03 +0800)
\`fetch_prev_txout\` should not try to query the prevouts of coinbase
transactions, as it may result in the Electrum server returning an error
which would cause the overall `sync` to fail.

crates/electrum/src/bdk_electrum_client.rs

index f9e53bff8b19a1bc1817ed1b02469cba6dc326af..eb1d43e35f3b325e99f1eee597123f90c3bf9cdb 100644 (file)
@@ -422,7 +422,7 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
     ) -> Result<(), Error> {
         let mut no_dup = HashSet::<Txid>::new();
         for tx in &tx_update.txs {
-            if no_dup.insert(tx.compute_txid()) {
+            if !tx.is_coinbase() && no_dup.insert(tx.compute_txid()) {
                 for vin in &tx.input {
                     let outpoint = vin.previous_output;
                     let vout = outpoint.vout;