pub fn verify_hash256_merkle(
    txid: Hash256Digest,
    merkle_root: Hash256Digest,
    intermediate_nodes: &MerkleArray,
    index: u64,
) -> bool {
    let mut idx = index;
    let proof_len = intermediate_nodes.len();

    match proof_len {
        0 => return txid == merkle_root,
        1 => return true,
        _ => {}
    }

    let mut current = txid;

    for i in 0..proof_len {
        let next = intermediate_nodes.index(i);

        if idx % 2 == 1 {
            current = hash256_merkle_step(next.as_ref(), current.as_ref());
        } else {
            current = hash256_merkle_step(current.as_ref(), next.as_ref());
        }
        idx >>= 1;
    }

    current == merkle_root
}
/// Verifies a Bitcoin-style merkle tree.
/// Leaves are 0-indexed.
/// Note that `index` is not a reliable indicator of location within a block.
///
/// # Arguments
///
/// * `proof` - The proof. Tightly packed LE sha256 hashes.  The last hash is the root
/// * `index` - The index of the leaf
Verifies a Bitcoin-style merkle tree.
Leaves are 0-indexed.
Note that `index` is not a reliable indicator of location within a block.
Verifies a Bitcoin - style merkle tree . Leaves are 0 - indexed . Note that ` index ` is not a reliable indicator of location within a block .
pub fn verify_hash256_merkle(
    txid: Hash256Digest,
    merkle_root: Hash256Digest,
    intermediate_nodes: &MerkleArray,
    index: u64,
) -> bool {
    let mut idx = index;
    let proof_len = intermediate_nodes.len();
    match proof_len {
        0 => return txid == merkle_root,
        1 => return true,
        _ => {}
    }
    let mut current = txid;
    for i in 0..proof_len {
        let next = intermediate_nodes.index(i);
        if idx % 2 == 1 {
            current = hash256_merkle_step(next.as_ref(), current.as_ref());
        } else {
            current = hash256_merkle_step(current.as_ref(), next.as_ref());
        }
        idx >>= 1;
    }
    current == merkle_root
}
pub fn verify_hash256_merkle ( txid : Hash256Digest , merkle_root : Hash256Digest , intermediate_nodes : & MerkleArray , index : u64 , ) -> bool { let mut idx = index ; let proof_len = intermediate_nodes . len ( ) ; match proof_len { 0 => return txid == merkle_root , 1 => return true , _ => { } } let mut current = txid ; for i in 0 .. proof_len { let next = intermediate_nodes . index ( i ) ; if idx % 2 == 1 { current = hash256_merkle_step ( next . as_ref ( ) , current . as_ref ( ) ) ; } else { current = hash256_merkle_step ( current . as_ref ( ) , next . as_ref ( ) ) ; } idx >>= 1 ; } current == merkle_root }
Verifies a Bitcoin-style merkle tree.
Verifies a Bitcoin - style merkle tree .
txid
Hash256Digest
merkle_root
Hash256Digest
intermediate_nodes
&MerkleArray
index
u64
txid
Hash256Digest
merkle_root
Hash256Digest
intermediate_nodes
&MerkleArray
index
u64