From b7d619f31227383a98fafbdce5dee8da5a222fe6 Mon Sep 17 00:00:00 2001 From: Olexandr88 Date: Fri, 15 May 2026 09:52:29 +0300 Subject: [PATCH] refactor: genesis_hash to use built-in bitcoin method Refactor genesis_hash function to use bitcoin's built-in method for retrieving the genesis block hash instead of a custom implementation. --- txindex_common/src/chain.rs | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/txindex_common/src/chain.rs b/txindex_common/src/chain.rs index 6d14cc2..4349144 100644 --- a/txindex_common/src/chain.rs +++ b/txindex_common/src/chain.rs @@ -1,4 +1,3 @@ -use bitcoin::hashes::Hash; pub use bitcoin::network::Network as BNetwork; use serde::Serialize; @@ -83,23 +82,6 @@ impl Network { pub fn genesis_hash(network: Network) -> BlockHash { - return bitcoin_genesis_hash(network.into()); + bitcoin::blockdata::constants::genesis_block(BNetwork::from(network)) + .block_hash() } - -pub fn bitcoin_genesis_hash(network: BNetwork) -> bitcoin::BlockHash { - match network { - BNetwork::Bitcoin => BlockHash::from_byte_array(hex_literal::hex!( - "9156352c1818b32e90c9e792efd6a11a82fe7956a630f03bbee236cedae3911a" - )), - BNetwork::Testnet => BlockHash::from_byte_array(hex_literal::hex!( - "9e555073d0c4f36456db8951f449704d544d2826d9aa60636b40374626780abb" - )), - BNetwork::Regtest => BlockHash::from_byte_array(hex_literal::hex!( - "a573e91c1772076c0d40f70e4408c83a31705f296ae6e7629d4adcb5a360213d" - )), - BNetwork::Signet => BlockHash::from_byte_array(hex_literal::hex!( - "1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691" - )), - _ => panic!("unknown network {:?}", network), - } -} \ No newline at end of file