def calculate_merkle_root(hashes, hash_function=bin_double_sha256,
                          hex_format=True):
    """ takes in a list of binary hashes, returns a binary hash
    """
    if hex_format:
        hashes = hex_to_bin_reversed_hashes(hashes)
    # keep moving up the merkle tree, constructing one row at a time
    while len(hashes) > 1:
        hashes = calculate_merkle_pairs(hashes, hash_function)
    # get the merkle root
    merkle_root = hashes[0]
    # if the user wants the merkle root in hex format, convert it
    if hex_format:
        return bin_to_hex_reversed(merkle_root)
    # return the binary merkle root
    return merkle_root
def calculate_merkle_root ( hashes , hash_function = bin_double_sha256 , hex_format = True ) : if hex_format : hashes = hex_to_bin_reversed_hashes ( hashes ) while len ( hashes ) > 1 : hashes = calculate_merkle_pairs ( hashes , hash_function ) merkle_root = hashes [ 0 ] if hex_format : return bin_to_hex_reversed ( merkle_root ) return merkle_root
takes in a list of binary hashes, returns a binary hash