pub fn new(txs: &[BitcoinTxId]) -> Self {
		if txs.is_empty() {
			return Self { data: vec![] };
		}

		let mut tree = vec![];

		// fill in leaf hashes
		let mut leaf_hashes = vec![];
		for tx in txs {
			let mut hash_slice = [0u8; 32];
			hash_slice.copy_from_slice(tx);
			leaf_hashes.push(hash_slice);
		}
		// must have an even number of hashes
		if txs.len() % 2 == 1 {
			let last_hash_slice = leaf_hashes
				.last()
				.expect(
					"FATAL: unreachable: non-empty vec does not have `last()`",
				)
				.to_owned();
			leaf_hashes.push(last_hash_slice);
		}

		tree.push(leaf_hashes);

		// calculate parent hashes until we reach the root
		let mut last_row_len =
			tree.last().expect("FATAL: unreachable: empty tree").len();
		loop {
			let mut next_row = vec![];
			let last_row = tree.last().expect("FATAL: unreachable: empty tree");
			for i in 0..(last_row_len / 2) {
				let mut intermediate_preimage = [0u8; 64];
				intermediate_preimage[0..32].copy_from_slice(&last_row[2 * i]);
				intermediate_preimage[32..64]
					.copy_from_slice(&last_row[2 * i + 1]);

				let intermediate_hash =
					DoubleSha256Algorithm::hash(&intermediate_preimage);
				next_row.push(intermediate_hash);
			}

			// reached the root
			if next_row.len() == 1 {
				tree.push(next_row);
				break;
			}

			// have more to go -- this row must have an even number of nodes
			if next_row.len() % 2 == 1 {
				let last_hash_slice = next_row
					.last()
					.expect("FATAL: unreachable: next_row is empty")
					.to_owned();
				next_row.push(last_hash_slice);
			}

			last_row_len = next_row.len();
			tree.push(next_row);
		}

		Self { data: tree }
	}
Make a new Merkle tree out of the given Bitcoin txids
romeo/src/proof_data.rs