Skip to content

Commit 36e434d

Browse files
authored
Merge pull request #2909 from benthecarman/inv-pk-helper
Add helper function to properly get invoice pubkey
2 parents c4a2f1b + 53fc986 commit 36e434d

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
@@ -1348,6 +1348,15 @@ impl Bolt11Invoice {
13481348
self.signed_invoice.recover_payee_pub_key().expect("was checked by constructor").0
13491349
}
13501350

1351+
/// Recover the payee's public key if one was included in the invoice, otherwise return the
1352+
/// recovered public key from the signature
1353+
pub fn get_payee_pub_key(&self) -> PublicKey {
1354+
match self.payee_pub_key() {
1355+
Some(pk) => *pk,
1356+
None => self.recover_payee_pub_key()
1357+
}
1358+
}
1359+
13511360
/// Returns the Duration since the Unix epoch at which the invoice expires.
13521361
/// Returning None if overflow occurred.
13531362
pub fn expires_at(&self) -> Option<Duration> {

0 commit comments

Comments
 (0)