Merge rust-bitcoin/rust-bitcoin#2388: Use hex-conservative to display pubkey

faa45cf10f Remove stale comment (Tobin C. Harding)
c82f26e960 Use hex-conservative to display pubkey (Tobin C. Harding)

Pull request description:

  We introduced `hex-conservative` ages ago, use it to display the `PublicKey`.

ACKs for top commit:
  Kixunil:
    ACK faa45cf10f
  apoelstra:
    ACK faa45cf10f

Tree-SHA512: 8ad14c7697314f8393ecb9a287215c505924d0655f7bf3536d4be83af983b142e06a96f802beb4548e2de051f1783549d8d1d1a8ebfb678f372a54010717752e
This commit is contained in:
Andrew Poelstra 2024-01-24 15:46:12 +00:00
commit 53808fa9c9
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
2 changed files with 1 additions and 6 deletions

View File

@ -220,12 +220,8 @@ pub struct SortKey(ArrayVec<u8, 65>);
impl fmt::Display for PublicKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// TODO: fast hex encoding
self.with_serialized(|bytes| {
for ch in bytes {
write!(f, "{:02x}", ch)?;
}
Ok(())
fmt::Display::fmt(&bytes.as_hex(), f)
})
}
}

View File

@ -832,7 +832,6 @@ impl crate::serde::Serialize for U256 {
}
if serializer.is_human_readable() {
// TODO: fast hex encoding.
serializer.collect_str(&DisplayHex(*self))
} else {
let bytes = self.to_be_bytes();