diff --git a/src/util/schnorr.rs b/src/util/schnorr.rs index 834bf338..44dde217 100644 --- a/src/util/schnorr.rs +++ b/src/util/schnorr.rs @@ -21,6 +21,7 @@ pub use secp256k1::schnorrsig::{PublicKey, KeyPair}; use secp256k1::{Secp256k1, Verification}; use hashes::Hash; use util::taproot::{TapBranchHash, TapTweakHash}; +use core::fmt; /// Untweaked Schnorr public key pub type UntweakedPublicKey = PublicKey; @@ -29,6 +30,18 @@ pub type UntweakedPublicKey = PublicKey; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct TweakedPublicKey(PublicKey); +impl fmt::LowerHex for TweakedPublicKey { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::LowerHex::fmt(&self.0, f) + } +} + +impl fmt::Display for TweakedPublicKey { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&self.0, f) + } +} + /// A trait for tweaking Schnorr public keys pub trait TapTweak { /// Tweaks an untweaked public key given an untweaked key and optional script tree merkle root.