Add sync verification for esplora
This commit is contained in:
parent
4761155707
commit
acbf0ae08e
@ -167,9 +167,27 @@ impl Blockchain for EsploraBlockchain {
|
|||||||
.request()
|
.request()
|
||||||
.map(|txid| {
|
.map(|txid| {
|
||||||
let tx = tx_index.get(txid).expect("must be in index");
|
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::<Result<_, Error>>()?;
|
||||||
tx_req.satisfy(full_txs)?
|
tx_req.satisfy(full_txs)?
|
||||||
}
|
}
|
||||||
Request::Finish(batch_update) => break batch_update,
|
Request::Finish(batch_update) => break batch_update,
|
||||||
|
@ -166,9 +166,27 @@ impl Blockchain for EsploraBlockchain {
|
|||||||
.request()
|
.request()
|
||||||
.map(|txid| {
|
.map(|txid| {
|
||||||
let tx = tx_index.get(txid).expect("must be in index");
|
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::<Result<_, Error>>()?;
|
||||||
tx_req.satisfy(full_txs)?
|
tx_req.satisfy(full_txs)?
|
||||||
}
|
}
|
||||||
Request::Finish(batch_update) => break batch_update,
|
Request::Finish(batch_update) => break batch_update,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user