diff --git a/README.md b/README.md index 153e179..2d6ce71 100644 --- a/README.md +++ b/README.md @@ -88,3 +88,5 @@ See Transaction::verify and Script::verify methods. * Replaced Base58 traits with encode_slice, check_encode_slice, from and from_check functions in the base58 module. +* Un-reversed the Debug output for Sha256dHash + diff --git a/src/util/hash.rs b/src/util/hash.rs index 29b8fde..5126734 100644 --- a/src/util/hash.rs +++ b/src/util/hash.rs @@ -354,6 +354,7 @@ impl serde::Deserialize for Sha256dHash { // Debug encodings (no reversing) impl fmt::Debug for Sha256dHash { + /// Output the raw sha256d hash, not reversing it (unlike Display and what Core does for user display) fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let &Sha256dHash(data) = self; for ch in data.iter() { @@ -364,6 +365,7 @@ impl fmt::Debug for Sha256dHash { } impl fmt::Debug for Hash160 { + /// Output the raw hash160 hash, not reversing it (nothing reverses the output of ripemd160 in Bitcoin) fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let &Hash160(data) = self; for ch in data.iter() { @@ -381,10 +383,12 @@ impl_newtype_consensus_encoding!(Sha256dHash); // User RPC/display encoding (reversed) impl fmt::Display for Sha256dHash { + /// Output the sha256d hash in reverse, copying Bitcoin Core's behaviour fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(self, f) } } impl fmt::LowerHex for Sha256dHash { + /// Output the sha256d hash in reverse, copying Bitcoin Core's behaviour fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let &Sha256dHash(data) = self; for ch in data.iter().rev() { @@ -395,6 +399,7 @@ impl fmt::LowerHex for Sha256dHash { } impl fmt::UpperHex for Sha256dHash { + /// Output the sha256d hash in reverse, copying Bitcoin Core's behaviour fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let &Sha256dHash(data) = self; for ch in data.iter().rev() {