Skip to content

Commit

Permalink
Merge pull request #2909 from benthecarman/inv-pk-helper
Browse files Browse the repository at this point in the history
Add helper function to properly get invoice pubkey
  • Loading branch information
TheBlueMatt authored Feb 22, 2024
2 parents c4a2f1b + 53fc986 commit 36e434d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lightning-invoice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,15 @@ impl Bolt11Invoice {
self.signed_invoice.recover_payee_pub_key().expect("was checked by constructor").0
}

/// Recover the payee's public key if one was included in the invoice, otherwise return the
/// recovered public key from the signature
pub fn get_payee_pub_key(&self) -> PublicKey {
match self.payee_pub_key() {
Some(pk) => *pk,
None => self.recover_payee_pub_key()
}
}

/// Returns the Duration since the Unix epoch at which the invoice expires.
/// Returning None if overflow occurred.
pub fn expires_at(&self) -> Option<Duration> {
Expand Down

0 comments on commit 36e434d

Please sign in to comment.