From: benthecarman Date: Thu, 22 Feb 2024 18:05:37 +0000 (+0000) Subject: Add helper function to properly get invoice pubkey X-Git-Tag: v0.0.123-beta~56^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=53fc986378c4942694bdb1608a4bcd1c75903274;p=rust-lightning Add helper function to properly get invoice pubkey --- diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs index 610f739e5..457896633 100644 --- a/lightning-invoice/src/lib.rs +++ b/lightning-invoice/src/lib.rs @@ -1355,6 +1355,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 {