Merge rust-bitcoin/rust-bitcoin#1753: Add `ChainHash::from_genesis_block_hash`
ed80df5ebc
Add `ChainHash::from_genesis_block_hash` (Martin Habovstiak) Pull request description: This improves readability of converting `BlockHash` into `ChainHash`. It's useful in e.g. Electrum protocol which sends `BlockHash` (serialized backward). Closes #1751 ACKs for top commit: apoelstra: ACKed80df5ebc
tcharding: ACKed80df5ebc
Tree-SHA512: b03eb9ca0a1eb38196cc8e43751c2def0d00b463b774003c5319bf56599db598ddd4bb0e2ad0bd3803f21a925135992d421848e7b1ba5e7bab3a405f60fc973c
This commit is contained in:
commit
dc72dfb9f2
|
@ -185,6 +185,11 @@ impl ChainHash {
|
||||||
let hashes = [Self::BITCOIN, Self::TESTNET, Self::SIGNET, Self::REGTEST];
|
let hashes = [Self::BITCOIN, Self::TESTNET, Self::SIGNET, Self::REGTEST];
|
||||||
hashes[network as usize]
|
hashes[network as usize]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Converts genesis block hash into `ChainHash`.
|
||||||
|
pub fn from_genesis_block_hash(block_hash: crate::BlockHash) -> Self {
|
||||||
|
ChainHash(block_hash.to_byte_array())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in New Issue