diff --git a/zebra-consensus/src/script.rs b/zebra-consensus/src/script.rs index 07e4af5a..0b342e1a 100644 --- a/zebra-consensus/src/script.rs +++ b/zebra-consensus/src/script.rs @@ -23,6 +23,7 @@ use crate::BoxError; /// /// After verification, the script future completes. State changes are handled by /// `BlockVerifier` or `MempoolTransactionVerifier`. +#[derive(Debug, Clone)] pub struct Verifier { state: ZS, branch: ConsensusBranchId, @@ -35,9 +36,9 @@ impl Verifier { } #[derive(Debug)] -struct Request { - transaction: Arc, - input_index: usize, +pub struct Request { + pub transaction: Arc, + pub input_index: usize, } impl tower::Service for Verifier diff --git a/zebra-consensus/src/transaction.rs b/zebra-consensus/src/transaction.rs index 505f8240..81daaf80 100644 --- a/zebra-consensus/src/transaction.rs +++ b/zebra-consensus/src/transaction.rs @@ -41,11 +41,8 @@ use crate::{script, BoxError}; /// /// After verification, the transaction future completes. State changes are /// handled by `BlockVerifier` or `MempoolTransactionVerifier`. -pub struct Verifier -where - ZS: Service + Send + Clone + 'static, - ZS::Future: Send + 'static, -{ +#[derive(Debug, Clone)] +pub struct Verifier { script_verifier: script::Verifier, // spend_verifier: groth16::Verifier, // output_verifier: groth16::Verifier, @@ -134,13 +131,14 @@ where }; let mut redjubjub_verifier = crate::primitives::redjubjub::VERIFIER.clone(); + let mut script_verifier = self.script_verifier.clone(); async move { match &*tx { Transaction::V1 { .. } | Transaction::V2 { .. } | Transaction::V3 { .. } => { Err(VerifyTransactionError::WrongVersion) } Transaction::V4 { - // inputs, + inputs, // outputs, // lock_time, // expiry_height, @@ -162,6 +160,14 @@ where } else { // otherwise, check no coinbase inputs // feed all of the inputs to the script verifier + for input_index in 0..inputs.len() { + let rsp = script_verifier.ready_and().await?.call(script::Request { + transaction: tx.clone(), + input_index, + }); + + async_checks.push(rsp); + } } let sighash = tx.sighash(