Use compute_merkle_root

Remove manual implementation of merkle root calculation and just use the
function we already have.

Refactor only, no logic change.
This commit is contained in:
Tobin C. Harding 2025-03-21 09:07:00 +11:00
parent 20c50e337f
commit 200ff47327
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 1 additions and 4 deletions

View File

@ -6,8 +6,6 @@
//! consensus code. In particular, it defines the genesis block and its
//! single transaction.
use hashes::sha256d;
use crate::block::{self, Block, Checked};
use crate::internal_macros::{impl_array_newtype, impl_array_newtype_stringify};
use crate::locktime::absolute;
@ -124,8 +122,7 @@ fn bitcoin_genesis_tx(params: &Params) -> Transaction {
pub fn genesis_block(params: impl AsRef<Params>) -> Block<Checked> {
let params = params.as_ref();
let transactions = vec![bitcoin_genesis_tx(params)];
let hash: sha256d::Hash = transactions[0].compute_txid().into();
let merkle_root: crate::TxMerkleNode = hash.into();
let merkle_root = block::compute_merkle_root(&transactions).expect("transactions is not empty");
let witness_root = block::compute_witness_root(&transactions);
match params.network {