pub fn check_transaction_proof(proof: &MerkleProof, tr: &Transaction, block_id: &UInt256) -> Result<()> {

    let block_virt_root = proof.proof.clone().virtualize(1);

    let block: Block = Block::construct_from(&mut block_virt_root.into())
        .map_err(
            |err| BlockError::WrongMerkleProof(
                format!("Error extracting block from proof: {}", err)
            )
        )?;

    // check if block id in transaction is corresponds to block in proof
    let block_info = check_block_info_proof(&block, &proof.hash, block_id)?;

    // check if acc is belonged the block's shard
    if !block_info.shard().contains_account(tr.account_id().clone())? {
        fail!(
            BlockError::WrongMerkleProof(
                "Account address in transaction belongs other shardchain".to_string()
            )
        )
    }

    // check if transaction is potencially belonged the block by logical time
    if tr.logical_time() < block_info.start_lt() || tr.logical_time() > block_info.end_lt() {
        fail!(
            BlockError::WrongMerkleProof(
                "Transaction's logical time doesn't belong to \
                 block's logical time interval".to_string()
            )
        )
    }

    // read account block from block and check it

    let block_extra = block.read_extra()
        .map_err(
            |err| BlockError::WrongMerkleProof(
                format!("Error extracting block extra from proof: {}", err)
            )
        )?;

    let account_blocks = block_extra.read_account_blocks()
        .map_err(
            |err| BlockError::WrongMerkleProof(
                format!("Error extracting account blocks from proof: {}", err)
            )
        )?;

    let account_block = account_blocks.get_serialized(tr.account_id().clone())?
        .ok_or_else(|| BlockError::WrongMerkleProof("No account block in proof".to_string()))?;

    // find transaction
    let tr_parent_slice_opt = account_block.transactions().get_as_slice(&tr.logical_time())
        .map_err(
            |err| BlockError::WrongMerkleProof(
                format!("Error extracting transaction from dictionary in proof: {}", err) 
            )
        )?;
    if let Some(mut tr_parent_slice) = tr_parent_slice_opt {
        if let Ok(tr_slice) = tr_parent_slice.checked_drain_reference() {
            // check hash
            if tr_slice.repr_hash() != tr.hash()? {
                fail!(
                    BlockError::WrongMerkleProof("Wrong transaction's hash in proof".to_string())
                )
            }
        }
    } else {
        fail!(BlockError::WrongMerkleProof("No transaction in proof".to_string()))
    }
    Ok(())
}
/// checks if transaction with given id is exist in block.
/// Proof must contain transaction's root cell and block info
checks if transaction with given id is exist in block.
Proof must contain transaction's root cell and block info
checks if transaction with given id is exist in block . Proof must contain transaction ' s root cell and block info
pub fn check_transaction_proof(proof: &MerkleProof, tr: &Transaction, block_id: &UInt256) -> Result<()> {
    let block_virt_root = proof.proof.clone().virtualize(1);
    let block: Block = Block::construct_from(&mut block_virt_root.into())
        .map_err(
            |err| BlockError::WrongMerkleProof(
                format!("Error extracting block from proof: {}", err)
            )
        )?;
    // check if block id in transaction is corresponds to block in proof
    let block_info = check_block_info_proof(&block, &proof.hash, block_id)?;
    // check if acc is belonged the block's shard
    if !block_info.shard().contains_account(tr.account_id().clone())? {
        fail!(
            BlockError::WrongMerkleProof(
                "Account address in transaction belongs other shardchain".to_string()
            )
        )
    }
    // check if transaction is potencially belonged the block by logical time
    if tr.logical_time() < block_info.start_lt() || tr.logical_time() > block_info.end_lt() {
        fail!(
            BlockError::WrongMerkleProof(
                "Transaction's logical time doesn't belong to \
                 block's logical time interval".to_string()
            )
        )
    }
    // read account block from block and check it
    let block_extra = block.read_extra()
        .map_err(
            |err| BlockError::WrongMerkleProof(
                format!("Error extracting block extra from proof: {}", err)
            )
        )?;
    let account_blocks = block_extra.read_account_blocks()
        .map_err(
            |err| BlockError::WrongMerkleProof(
                format!("Error extracting account blocks from proof: {}", err)
            )
        )?;
    let account_block = account_blocks.get_serialized(tr.account_id().clone())?
        .ok_or_else(|| BlockError::WrongMerkleProof("No account block in proof".to_string()))?;
    // find transaction
    let tr_parent_slice_opt = account_block.transactions().get_as_slice(&tr.logical_time())
        .map_err(
            |err| BlockError::WrongMerkleProof(
                format!("Error extracting transaction from dictionary in proof: {}", err) 
            )
        )?;
    if let Some(mut tr_parent_slice) = tr_parent_slice_opt {
        if let Ok(tr_slice) = tr_parent_slice.checked_drain_reference() {
            // check hash
            if tr_slice.repr_hash() != tr.hash()? {
                fail!(
                    BlockError::WrongMerkleProof("Wrong transaction's hash in proof".to_string())
                )
            }
        }
    } else {
        fail!(BlockError::WrongMerkleProof("No transaction in proof".to_string()))
    }
    Ok(())
}
pub fn check_transaction_proof ( proof : & MerkleProof , tr : & Transaction , block_id : & UInt256 ) -> Result < ( ) > { let block_virt_root = proof . proof . clone ( ) . virtualize ( 1 ) ; let block : Block = Block :: construct_from ( & mut block_virt_root . into ( ) ) . map_err ( | err | BlockError :: WrongMerkleProof ( format ! ( " " err ) ) ) ? ; // check if block id in transaction is corresponds to block in proof let block_info = check_block_info_proof ( & block , & proof . hash , block_id ) ? ; // check if acc is belonged the block's shard if ! block_info . shard ( ) . contains_account ( tr . account_id ( ) . clone ( ) ) ? { fail ! ( BlockError WrongMerkleProof ( " " to_string ( ) ) ) } // check if transaction is potencially belonged the block by logical time if tr . logical_time ( ) < block_info . start_lt ( ) || tr . logical_time ( ) > block_info . end_lt ( ) { fail ! ( BlockError WrongMerkleProof ( " \
 " to_string ( ) ) ) } // read account block from block and check it let block_extra = block . read_extra ( ) . map_err ( | err | BlockError :: WrongMerkleProof ( format ! ( " " err ) ) ) ? ; let account_blocks = block_extra . read_account_blocks ( ) . map_err ( | err | BlockError :: WrongMerkleProof ( format ! ( " " err ) ) ) ? ; let account_block = account_blocks . get_serialized ( tr . account_id ( ) . clone ( ) ) ? . ok_or_else ( | | BlockError :: WrongMerkleProof ( " " . to_string ( ) ) ) ? ; // find transaction let tr_parent_slice_opt = account_block . transactions ( ) . get_as_slice ( & tr . logical_time ( ) ) . map_err ( | err | BlockError :: WrongMerkleProof ( format ! ( " " err ) ) ) ? ; if let Some ( mut tr_parent_slice ) = tr_parent_slice_opt { if let Ok ( tr_slice ) = tr_parent_slice . checked_drain_reference ( ) { // check hash if tr_slice . repr_hash ( ) != tr . hash ( ) ? { fail ! ( BlockError WrongMerkleProof ( " " to_string ( ) ) ) } } } else { fail ! ( BlockError WrongMerkleProof ( " " to_string ( ) ) ) } Ok ( ( ) ) }
checks if transaction with given id is exist in block.
checks if transaction with given id is exist in block .
proof
&MerkleProof
tr
&Transaction
block_id
&UInt256
proof
&MerkleProof
tr
&Transaction
block_id
&UInt256