pub fn is_valid(
        &self,
        branch_id: ConsensusBranchId,
        (input_index, previous_output): (u32, transparent::Output),
    ) -> Result<(), Error> {
        let transparent::Output { value, lock_script } = previous_output;
        let script_pub_key: &[u8] = lock_script.as_raw_bytes();

        // This conversion is useful on some platforms, but not others.
        #[allow(clippy::useless_conversion)]
        let n_in = input_index
            .try_into()
            .expect("transaction indexes are much less than c_uint::MAX");

        let script_ptr = script_pub_key.as_ptr();
        let script_len = script_pub_key.len();

        let amount = value.into();

        let flags = zcash_script::zcash_script_SCRIPT_FLAGS_VERIFY_P2SH
            | zcash_script::zcash_script_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY;
        // This conversion is useful on some platforms, but not others.
        #[allow(clippy::useless_conversion)]
        let flags = flags
            .try_into()
            .expect("zcash_script_SCRIPT_FLAGS_VERIFY_* enum values fit in a c_uint");

        let consensus_branch_id = branch_id.into();

        let mut err = 0;

        // SAFETY: `CachedFfiTransaction::new` makes sure `self.precomputed` is not NULL.
        //         The `script_*` fields are created from a valid Rust `slice`.
        let ret = unsafe {
            zcash_script::zcash_script_verify_precomputed(
                self.precomputed,
                n_in,
                script_ptr,
                script_len
                    .try_into()
                    .expect("script lengths are much less than u32::MAX"),
                amount,
                flags,
                consensus_branch_id,
                &mut err,
            )
        };

        if ret == 1 {
            Ok(())
        } else {
            Err(Error::from(err))
        }
    }
/// Verify a script within a transaction given the corresponding
/// `transparent::Output` it is spending and the `ConsensusBranchId` of the block
/// containing the transaction.
///
/// # Details
///
/// The `input_index` corresponds to the index of the `TransparentInput` which in
/// `transaction` used to identify the `previous_output`.
Verify a script within a transaction given the corresponding
`transparent::Output` it is spending and the `ConsensusBranchId` of the block
containing the transaction.
Verify a script within a transaction given the corresponding ` transparent :: Output ` it is spending and the ` ConsensusBranchId ` of the block containing the transaction .
pub fn is_valid(
        &self,
        branch_id: ConsensusBranchId,
        (input_index, previous_output): (u32, transparent::Output),
    ) -> Result<(), Error> {
        let transparent::Output { value, lock_script } = previous_output;
        let script_pub_key: &[u8] = lock_script.as_raw_bytes();
        // This conversion is useful on some platforms, but not others.
        #[allow(clippy::useless_conversion)]
        let n_in = input_index
            .try_into()
            .expect("transaction indexes are much less than c_uint::MAX");
        let script_ptr = script_pub_key.as_ptr();
        let script_len = script_pub_key.len();
        let amount = value.into();
        let flags = zcash_script::zcash_script_SCRIPT_FLAGS_VERIFY_P2SH
            | zcash_script::zcash_script_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY;
        // This conversion is useful on some platforms, but not others.
        #[allow(clippy::useless_conversion)]
        let flags = flags
            .try_into()
            .expect("zcash_script_SCRIPT_FLAGS_VERIFY_* enum values fit in a c_uint");
        let consensus_branch_id = branch_id.into();
        let mut err = 0;
        // SAFETY: `CachedFfiTransaction::new` makes sure `self.precomputed` is not NULL.
        //         The `script_*` fields are created from a valid Rust `slice`.
        let ret = unsafe {
            zcash_script::zcash_script_verify_precomputed(
                self.precomputed,
                n_in,
                script_ptr,
                script_len
                    .try_into()
                    .expect("script lengths are much less than u32::MAX"),
                amount,
                flags,
                consensus_branch_id,
                &mut err,
            )
        };
        if ret == 1 {
            Ok(())
        } else {
            Err(Error::from(err))
        }
    }
pub fn is_valid ( & self , branch_id : ConsensusBranchId , ( input_index , previous_output ) : ( u32 , transparent :: Output ) , ) -> Result < ( ) , Error > { let transparent :: Output { value , lock_script } = previous_output ; let script_pub_key : & [ u8 ] = lock_script . as_raw_bytes ( ) ; // This conversion is useful on some platforms, but not others. # [ allow ( clippy useless_conversion ) ] let n_in = input_index . try_into ( ) . expect ( " " ) ; let script_ptr = script_pub_key . as_ptr ( ) ; let script_len = script_pub_key . len ( ) ; let amount = value . into ( ) ; let flags = zcash_script :: zcash_script_SCRIPT_FLAGS_VERIFY_P2SH | zcash_script :: zcash_script_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY ; // This conversion is useful on some platforms, but not others. # [ allow ( clippy useless_conversion ) ] let flags = flags . try_into ( ) . expect ( " " ) ; let consensus_branch_id = branch_id . into ( ) ; let mut err = 0 ; // SAFETY: `CachedFfiTransaction::new` makes sure `self.precomputed` is not NULL. //         The `script_*` fields are created from a valid Rust `slice`. let ret = unsafe { zcash_script :: zcash_script_verify_precomputed ( self . precomputed , n_in , script_ptr , script_len . try_into ( ) . expect ( " " ) , amount , flags , consensus_branch_id , & mut err , ) } ; if ret == 1 { Ok ( ( ) ) } else { Err ( Error :: from ( err ) ) } }
Verify a script within a transaction given the corresponding
`transparent::Output` it is spending and the `ConsensusBranchId` of the block
containing the transaction.
Verify a script within a transaction given the corresponding ` transparent :: Output ` it is spending and the ` ConsensusBranchId ` of the block containing the transaction .
&self
branch_id
(u32, transparent::Output)
details
The `input_index` corresponds to the index of the `TransparentInput` which in
`transaction` used to identify the `previous_output`.
The ` input_index ` corresponds to the index of the ` TransparentInput ` which in ` transaction ` used to identify the ` previous_output ` .