add docs indicating change in Sha256dHash debug output

This commit is contained in:
Andrew Poelstra 2018-03-12 20:02:21 +00:00
parent 8968b081ca
commit 9884bec577
2 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -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() {