diff --git a/zcash_primitives/src/block.rs b/zcash_primitives/src/block.rs index 1304192d6..8ded03fc4 100644 --- a/zcash_primitives/src/block.rs +++ b/zcash_primitives/src/block.rs @@ -9,9 +9,18 @@ use zcash_encoding::Vector; pub use equihash; -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct BlockHash(pub [u8; 32]); +impl fmt::Debug for BlockHash { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // The (byte-flipped) hex string is more useful than the raw bytes, because we can + // look that up in RPC methods and block explorers. + let block_hash_str = self.to_string(); + f.debug_tuple("BlockHash").field(&block_hash_str).finish() + } +} + impl fmt::Display for BlockHash { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { let mut data = self.0; diff --git a/zcash_primitives/src/transaction/mod.rs b/zcash_primitives/src/transaction/mod.rs index 885116b32..2495822e6 100644 --- a/zcash_primitives/src/transaction/mod.rs +++ b/zcash_primitives/src/transaction/mod.rs @@ -61,9 +61,18 @@ const ZFUTURE_VERSION_GROUP_ID: u32 = 0xFFFFFFFF; #[cfg(feature = "zfuture")] const ZFUTURE_TX_VERSION: u32 = 0x0000FFFF; -#[derive(Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] pub struct TxId([u8; 32]); +impl fmt::Debug for TxId { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // The (byte-flipped) hex string is more useful than the raw bytes, because we can + // look that up in RPC methods and block explorers. + let txid_str = self.to_string(); + f.debug_tuple("TxId").field(&txid_str).finish() + } +} + impl fmt::Display for TxId { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { let mut data = self.0;