diff --git a/zebra-chain/src/block.rs b/zebra-chain/src/block.rs index 2ffed136..86ce1dac 100644 --- a/zebra-chain/src/block.rs +++ b/zebra-chain/src/block.rs @@ -67,6 +67,18 @@ impl ZcashDeserialize for BlockHeaderHash { } } +impl std::str::FromStr for BlockHeaderHash { + type Err = SerializationError; + fn from_str(s: &str) -> Result { + let mut bytes = [0; 32]; + if hex::decode_to_slice(s, &mut bytes[..]).is_err() { + Err(SerializationError::Parse("hex decoding error")) + } else { + Ok(BlockHeaderHash(bytes)) + } + } +} + /// Block header. /// /// How are blocks chained together? They are chained together via the