Skip to content

Commit

Permalink
Truncate secret hash using precision
Browse files Browse the repository at this point in the history
Currently we are attempting to truncate the hash created using
`bitcoin_hashes` by using the "width" formatting parameter instead of
the "precision" parameter. `hex-conservative` truncates with the
"precision" parameter as is expected since a hash is not an integral
type.

Use the formatting string `"{:.16}"` which is the "precision"
formatting parameter.
  • Loading branch information
tcharding committed Aug 22, 2024
1 parent 4b143d6 commit 3d1ce0d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ macro_rules! impl_display_secret {
engine.input(&self.secret_bytes());
let hash = sha256::Hash::from_engine(engine);

f.debug_tuple(stringify!($thing)).field(&format_args!("#{:016x}", hash)).finish()
f.debug_tuple(stringify!($thing)).field(&format_args!("#{:.16}", hash)).finish()
}
}

Expand Down

0 comments on commit 3d1ce0d

Please sign in to comment.