diff --git a/src/blockchain/esplora/reqwest.rs b/src/blockchain/esplora/reqwest.rs index aaf487e4..f1f39f9d 100644 --- a/src/blockchain/esplora/reqwest.rs +++ b/src/blockchain/esplora/reqwest.rs @@ -167,9 +167,27 @@ impl Blockchain for EsploraBlockchain { .request() .map(|txid| { let tx = tx_index.get(txid).expect("must be in index"); - (tx.previous_outputs(), tx.to_tx()) + // 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(); + .collect::>()?; tx_req.satisfy(full_txs)? } Request::Finish(batch_update) => break batch_update, diff --git a/src/blockchain/esplora/ureq.rs b/src/blockchain/esplora/ureq.rs index f3895a15..a32d8137 100644 --- a/src/blockchain/esplora/ureq.rs +++ b/src/blockchain/esplora/ureq.rs @@ -166,9 +166,27 @@ impl Blockchain for EsploraBlockchain { .request() .map(|txid| { let tx = tx_index.get(txid).expect("must be in index"); - (tx.previous_outputs(), tx.to_tx()) + // 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(); + .collect::>()?; tx_req.satisfy(full_txs)? } Request::Finish(batch_update) => break batch_update,