From 389abddcc789da672071aa9ae452664aeecce9ec Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Wed, 12 Jan 2022 18:11:55 +1100 Subject: [PATCH] Add method KeyPair::public_key Currently to get the `XOnlyPublicKey` from a `KeyPair` users must do `XOnlyPublicKey::from_keypair(&kp)`. While this does the job we can make the lib more ergonomic by providing a method directly on `KeyPair` that calls through to `XOnlyPublicKey::from_keypair`. Add method `KeyPair::public_key(&self)`. --- src/key.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/key.rs b/src/key.rs index 8c0f0a0..09a4e49 100644 --- a/src/key.rs +++ b/src/key.rs @@ -650,6 +650,12 @@ impl KeyPair { Ok(()) } } + + /// Gets the [XOnlyPublicKey] for this [KeyPair]. + #[inline] + pub fn public_key(&self) -> XOnlyPublicKey { + XOnlyPublicKey::from_keypair(self) + } } impl From for SecretKey {