Skip to content

Commit 53fc986

Browse files
committed
Add helper function to properly get invoice pubkey
1 parent d70124c commit 53fc986

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lightning-invoice/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,15 @@ impl Bolt11Invoice {
13551355
self.signed_invoice.recover_payee_pub_key().expect("was checked by constructor").0
13561356
}
13571357

1358+
/// Recover the payee's public key if one was included in the invoice, otherwise return the
1359+
/// recovered public key from the signature
1360+
pub fn get_payee_pub_key(&self) -> PublicKey {
1361+
match self.payee_pub_key() {
1362+
Some(pk) => *pk,
1363+
None => self.recover_payee_pub_key()
1364+
}
1365+
}
1366+
13581367
/// Returns the Duration since the Unix epoch at which the invoice expires.
13591368
/// Returning None if overflow occurred.
13601369
pub fn expires_at(&self) -> Option<Duration> {

0 commit comments

Comments
 (0)