Merge rust-bitcoin/rust-bitcoin#3278: Show compressed public key in Debug for CompressedPublicKey
9db6234ea9
Show compressed public key in Debug for CompressedPublicKey (Jiri Jakes) Pull request description: Currently `CompressedPublicKey` debug produces output of form: ``` CompressedPublicKey(PublicKey(2f8b18dc0adcb73d75f7934d9523ea7347083e41c48115398cb37e295a0a6ffe86e0bf8b1ef65888c880c8d8813a30e69e466380cbe2daec18f3ed1e7a553ff2)) ``` Although it shows real internal structure together with inner uncompressed public key, it is not too helpful for the purpose of debugging _compressed_ public key. After this patch, `Debug` output will be equal to `Display` (it, in fact, delegates rendering to `Display`), prepended by the name of the struct: ``` CompressedPublicKey(02fe6f0a5a297eb38c391581c4413e084773ea23954d93f7753db7dc0adc188b2f) ``` ACKs for top commit: Kixunil: ACK9db6234ea9
unless other maintainers agree to drop the struct name. apoelstra: ACK9db6234ea9
successfully ran local tests; we should keep the struct name since it is canonical for Debug output Tree-SHA512: e2626678a4144357d3ff4ddd888459ae1283ea50bc7c8ef86deb9902d7d543de79109ac42883e5538f7e2f6a29426224bb43eb44a34f366821e47a9aca563753
This commit is contained in:
commit
d1e7116321
|
@ -271,7 +271,7 @@ impl From<&PublicKey> for PubkeyHash {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An always-compressed Bitcoin ECDSA public key.
|
/// An always-compressed Bitcoin ECDSA public key.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct CompressedPublicKey(pub secp256k1::PublicKey);
|
pub struct CompressedPublicKey(pub secp256k1::PublicKey);
|
||||||
|
|
||||||
impl CompressedPublicKey {
|
impl CompressedPublicKey {
|
||||||
|
@ -350,6 +350,12 @@ impl fmt::Display for CompressedPublicKey {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for CompressedPublicKey {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
f.write_fmt(format_args!("CompressedPublicKey({})", self))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FromStr for CompressedPublicKey {
|
impl FromStr for CompressedPublicKey {
|
||||||
type Err = ParseCompressedPublicKeyError;
|
type Err = ParseCompressedPublicKeyError;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue