merkleRoot

fun merkleRoot(leaves: List<Sha256Hash>, padHash: Sha256Hash = Digest32.zeros(HASH_SIZE)): Sha256Hash

Computes the merkle root from a list of leaves, padding the right side with padHash when the leaf count is not a power of two. This is the top-level entry point that mirrors merkle_root (it rounds the leaf count up to a power of two and delegates to rootScratch).

Parameters

leaves

the real leaf hashes, in order. Must be non-empty.

padHash

the hash for the right-hand padding (default SHA-256(0), i.e. an all-zero 32-byte node). For the piece layer libtorrent uses pad to derive this; at the block layer it is the all-zero hash.