From 37352d1df57bb89eed2b0d3f35204b6aea4eab56 Mon Sep 17 00:00:00 2001 From: "Dr. Maxim Orlovsky" Date: Sun, 12 Dec 2021 16:23:57 +0200 Subject: [PATCH] Add Display and LowerHex to TweakedPublicKey --- src/util/schnorr.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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.