From: valued mammal Date: Tue, 14 May 2024 14:43:19 +0000 (-0400) Subject: fix(electrum): Fix `fetch_prev_txout` X-Git-Tag: v1.0.0-alpha.12~4^2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.CodeLengthError.html?a=commitdiff_plain;h=af15ebba94f6d96a4d266fbbdee7c49150f80b96;p=bdk fix(electrum): Fix `fetch_prev_txout` Previously we inserted every TxOut of a previous tx at the same outpoint, which is incorrect because an outpoint only points to a single TxOut. Now just get the TxOut corresponding to the txin prevout and insert it with its outpoint. --- diff --git a/crates/electrum/src/electrum_ext.rs b/crates/electrum/src/electrum_ext.rs index 14344695..d02a7dce 100644 --- a/crates/electrum/src/electrum_ext.rs +++ b/crates/electrum/src/electrum_ext.rs @@ -523,10 +523,10 @@ fn fetch_prev_txout( for tx in full_txs { for vin in &tx.input { let outpoint = vin.previous_output; + let vout = outpoint.vout; let prev_tx = fetch_tx(client, tx_cache, outpoint.txid)?; - for txout in prev_tx.output.clone() { - let _ = graph_update.insert_txout(outpoint, txout); - } + let txout = prev_tx.output[vout as usize].clone(); + let _ = graph_update.insert_txout(outpoint, txout); } } Ok(())