From 200ff473276f62866f0db130ecb485c905714aaa Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 21 Mar 2025 09:07:00 +1100 Subject: [PATCH] Use compute_merkle_root Remove manual implementation of merkle root calculation and just use the function we already have. Refactor only, no logic change. --- bitcoin/src/blockdata/constants.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bitcoin/src/blockdata/constants.rs b/bitcoin/src/blockdata/constants.rs index 6e8ef036e..60d528862 100644 --- a/bitcoin/src/blockdata/constants.rs +++ b/bitcoin/src/blockdata/constants.rs @@ -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) -> Block { 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 {