pub fn validate(&self) -> Result<(), SPVError> {
        if !btcspv::validate_vin(&self.vin) {
            return Err(SPVError::InvalidVin);
        }

        if !btcspv::validate_vout(&self.vout) {
            return Err(SPVError::InvalidVout);
        }

        let mut ver = [0u8; 4];
        ver.copy_from_slice(&self.version);
        let mut lock = [0u8; 4];
        lock.copy_from_slice(&self.locktime);

        let tx_id = validatespv::calculate_txid(
            &ver,
            &Vin::new(&self.vin)?,
            &Vout::new(&self.vout)?,
            &lock,
        );
        if tx_id != self.tx_id {
            return Err(SPVError::WrongTxID);
        }

        self.confirming_header.validate()?;

        if !validatespv::prove(
            tx_id,
            self.confirming_header.merkle_root,
            &MerkleArray::new(&self.intermediate_nodes)?,
            self.index as u64,
        ) {
            return Err(SPVError::BadMerkleProof);
        }
        Ok(())
    }
/// Checks validity of an entire SPV Proof
///
/// # Arguments
///
/// * `self` - The SPV Proof
///
/// # Errors
///
/// * Errors if any of the SPV Proof elements are invalid.
Checks validity of an entire SPV Proof
Checks validity of an entire SPV Proof
pub fn validate(&self) -> Result<(), SPVError> {
        if !btcspv::validate_vin(&self.vin) {
            return Err(SPVError::InvalidVin);
        }
        if !btcspv::validate_vout(&self.vout) {
            return Err(SPVError::InvalidVout);
        }
        let mut ver = [0u8; 4];
        ver.copy_from_slice(&self.version);
        let mut lock = [0u8; 4];
        lock.copy_from_slice(&self.locktime);
        let tx_id = validatespv::calculate_txid(
            &ver,
            &Vin::new(&self.vin)?,
            &Vout::new(&self.vout)?,
            &lock,
        );
        if tx_id != self.tx_id {
            return Err(SPVError::WrongTxID);
        }
        self.confirming_header.validate()?;
        if !validatespv::prove(
            tx_id,
            self.confirming_header.merkle_root,
            &MerkleArray::new(&self.intermediate_nodes)?,
            self.index as u64,
        ) {
            return Err(SPVError::BadMerkleProof);
        }
        Ok(())
    }
pub fn validate ( & self ) -> Result < ( ) , SPVError > { if ! btcspv :: validate_vin ( & self . vin ) { return Err ( SPVError :: InvalidVin ) ; } if ! btcspv :: validate_vout ( & self . vout ) { return Err ( SPVError :: InvalidVout ) ; } let mut ver = [ 0u8 ; 4 ] ; ver . copy_from_slice ( & self . version ) ; let mut lock = [ 0u8 ; 4 ] ; lock . copy_from_slice ( & self . locktime ) ; let tx_id = validatespv :: calculate_txid ( & ver , & Vin :: new ( & self . vin ) ? , & Vout :: new ( & self . vout ) ? , & lock , ) ; if tx_id != self . tx_id { return Err ( SPVError :: WrongTxID ) ; } self . confirming_header . validate ( ) ? ; if ! validatespv :: prove ( tx_id , self . confirming_header . merkle_root , & MerkleArray :: new ( & self . intermediate_nodes ) ? , self . index as u64 , ) { return Err ( SPVError :: BadMerkleProof ) ; } Ok ( ( ) ) }
Checks validity of an entire SPV Proof
Checks validity of an entire SPV Proof
&self
&self
errors
Errors if any of the SPV Proof elements are invalid.
Errors if any of the SPV Proof elements are invalid .