diff --git a/src/blockchain/electrum.rs b/src/blockchain/electrum.rs index 9ebde98922..1ab0db1c3e 100644 --- a/src/blockchain/electrum.rs +++ b/src/blockchain/electrum.rs @@ -190,19 +190,6 @@ impl Blockchain for ElectrumBlockchain { .output .get(input.previous_output.vout as usize) .ok_or_else(electrum_goof)?; - // Verify this input if requested via feature flag - #[cfg(feature = "verify")] - { - use crate::wallet::verify::VerifyError; - let serialized_tx = bitcoin::consensus::serialize(&tx); - bitcoinconsensus::verify( - txout.script_pubkey.to_bytes().as_ref(), - txout.value, - &serialized_tx, - input_index, - ) - .map_err(|e| VerifyError::from(e))?; - } input_index += 1; Ok(Some(txout.clone())) }) diff --git a/src/blockchain/esplora/reqwest.rs b/src/blockchain/esplora/reqwest.rs index f1f39f9dcc..494c6d307e 100644 --- a/src/blockchain/esplora/reqwest.rs +++ b/src/blockchain/esplora/reqwest.rs @@ -167,24 +167,6 @@ impl Blockchain for EsploraBlockchain { .request() .map(|txid| { let tx = tx_index.get(txid).expect("must be in index"); - // Verify this transaction if requested via feature flag - #[cfg(feature = "verify")] - { - use crate::wallet::verify::VerifyError; - let prev_outs = tx.previous_outputs(); - let tx_bytes = serialize(&tx.to_tx()); - for (index, output) in prev_outs.iter().enumerate() { - if let Some(output) = output { - bitcoinconsensus::verify( - output.script_pubkey.to_bytes().as_ref(), - output.value, - &tx_bytes, - index, - ) - .map_err(|e| VerifyError::from(e))?; - } - } - } Ok((tx.previous_outputs(), tx.to_tx())) }) .collect::>()?; diff --git a/src/blockchain/esplora/ureq.rs b/src/blockchain/esplora/ureq.rs index a32d8137da..856f6958e1 100644 --- a/src/blockchain/esplora/ureq.rs +++ b/src/blockchain/esplora/ureq.rs @@ -166,24 +166,6 @@ impl Blockchain for EsploraBlockchain { .request() .map(|txid| { let tx = tx_index.get(txid).expect("must be in index"); - // Verify this transaction if requested via feature flag - #[cfg(feature = "verify")] - { - use crate::wallet::verify::VerifyError; - let prev_outs = tx.previous_outputs(); - let tx_bytes = serialize(&tx.to_tx()); - for (index, output) in prev_outs.iter().enumerate() { - if let Some(output) = output { - bitcoinconsensus::verify( - output.script_pubkey.to_bytes().as_ref(), - output.value, - &tx_bytes, - index, - ) - .map_err(|e| VerifyError::from(e))?; - } - } - } Ok((tx.previous_outputs(), tx.to_tx())) }) .collect::>()?; diff --git a/src/blockchain/script_sync.rs b/src/blockchain/script_sync.rs index 0d450ef179..0702a5f0a6 100644 --- a/src/blockchain/script_sync.rs +++ b/src/blockchain/script_sync.rs @@ -178,7 +178,9 @@ impl<'a, D: BatchDatabase> TxReq<'a, D> { let mut inputs_sum: u64 = 0; let mut outputs_sum: u64 = 0; - for (txout, input) in vout.into_iter().zip(tx.input.iter()) { + for (txout, (input_index, input)) in + vout.into_iter().zip(tx.input.iter().enumerate()) + { let txout = match txout { Some(txout) => txout, None => { @@ -190,7 +192,19 @@ impl<'a, D: BatchDatabase> TxReq<'a, D> { continue; } }; - + // Verify this input if requested via feature flag + #[cfg(feature = "verify")] + { + use crate::wallet::verify::VerifyError; + let serialized_tx = bitcoin::consensus::serialize(&tx); + bitcoinconsensus::verify( + txout.script_pubkey.to_bytes().as_ref(), + txout.value, + &serialized_tx, + input_index, + ) + .map_err(|e| VerifyError::from(e))?; + } inputs_sum += txout.value; if self.state.db.is_mine(&txout.script_pubkey)? { sent += txout.value;