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)`.
This commit is contained in:
Tobin Harding 2022-01-12 18:11:55 +11:00
parent a9cf6785cc
commit 389abddcc7
1 changed files with 6 additions and 0 deletions

View File

@ -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<KeyPair> for SecretKey {