Skip to content

Commit 389abdd

Browse files
committed
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)`.
1 parent a9cf678 commit 389abdd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/key.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,12 @@ impl KeyPair {
650650
Ok(())
651651
}
652652
}
653+
654+
/// Gets the [XOnlyPublicKey] for this [KeyPair].
655+
#[inline]
656+
pub fn public_key(&self) -> XOnlyPublicKey {
657+
XOnlyPublicKey::from_keypair(self)
658+
}
653659
}
654660

655661
impl From<KeyPair> for SecretKey {

0 commit comments

Comments
 (0)