From af15ebba94f6d96a4d266fbbdee7c49150f80b96 Mon Sep 17 00:00:00 2001 From: valued mammal Date: Tue, 14 May 2024 10:43:19 -0400 Subject: [PATCH] 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. --- crates/electrum/src/electrum_ext.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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(())