Merge rust-bitcoin/rust-secp256k1#745: Improved `PublicKey` and `XOnlyPublicKey` `Debug` impl

ca32f7b403 improved PublicKey debug impl (Liam Aharon)

Pull request description:

  Closes #729

  Adjusts `Debug` impls to write serialized hex representation of the keys rather than the inner u8 bytes.

ACKs for top commit:
  apoelstra:
    ACK ca32f7b403 successfully ran local tests
  tcharding:
    ACK ca32f7b403

Tree-SHA512: e73c10733fe3b493492c16f6b2e68149339395b882c70d2d80b9b5e0d75ec671155b09a101ca019e44260413ecb82e93919f2caf0d2508b5baa641e839689909
This commit is contained in:
merge-script 2024-09-17 21:42:30 +00:00
commit 736adc92dd
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 10 additions and 2 deletions

View File

@ -144,7 +144,7 @@ impl str::FromStr for SecretKey {
/// ```
/// [`bincode`]: https://docs.rs/bincode
/// [`cbor`]: https://docs.rs/cbor
#[derive(Copy, Clone, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)]
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
#[repr(transparent)]
pub struct PublicKey(ffi::PublicKey);
impl_fast_comparisons!(PublicKey);
@ -163,6 +163,10 @@ impl fmt::Display for PublicKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(self, f) }
}
impl fmt::Debug for PublicKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(self, f) }
}
impl str::FromStr for PublicKey {
type Err = Error;
fn from_str(s: &str) -> Result<PublicKey, Error> {
@ -1138,7 +1142,7 @@ impl CPtr for Keypair {
/// ```
/// [`bincode`]: https://docs.rs/bincode
/// [`cbor`]: https://docs.rs/cbor
#[derive(Copy, Clone, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)]
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
pub struct XOnlyPublicKey(ffi::XOnlyPublicKey);
impl_fast_comparisons!(XOnlyPublicKey);
@ -1156,6 +1160,10 @@ impl fmt::Display for XOnlyPublicKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(self, f) }
}
impl fmt::Debug for XOnlyPublicKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(self, f) }
}
impl str::FromStr for XOnlyPublicKey {
type Err = Error;
fn from_str(s: &str) -> Result<XOnlyPublicKey, Error> {