@@ -714,6 +714,16 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
714714 $contents. supported_quantity( )
715715 }
716716
717+ /// The public key used by the recipient to sign invoices.
718+ ///
719+ /// From [`Offer::issuer_signing_pubkey`] and may be `None`; also `None` if the invoice was
720+ /// created in response to a [`Refund`].
721+ ///
722+ /// [`Offer::issuer_signing_pubkey`]: crate::offers::offer::Offer::issuer_signing_pubkey
723+ pub fn issuer_signing_pubkey( & $self) -> Option <PublicKey > {
724+ $contents. issuer_signing_pubkey( )
725+ }
726+
717727 /// An unpredictable series of bytes from the payer.
718728 ///
719729 /// From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
@@ -761,13 +771,37 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
761771 }
762772} }
763773
774+
775+ macro_rules! invoice_accessors_signing_pubkey {
776+ ( $self: ident, $contents: expr, $invoice_type: ty) =>
777+ {
778+ /// A typically transient public key corresponding to the key used to sign the invoice.
779+ ///
780+ /// If the invoices was created in response to an [`Offer`], then this will be:
781+ /// - [`Offer::issuer_signing_pubkey`] if it's `Some`, otherwise
782+ /// - the final blinded node id from a [`BlindedMessagePath`] in [`Offer::paths`] if `None`.
783+ ///
784+ /// If the invoice was created in response to a [`Refund`], then it is a valid pubkey chosen by
785+ /// the recipient.
786+ ///
787+ /// [`Offer`]: crate::offers::offer::Offer
788+ /// [`Offer::issuer_signing_pubkey`]: crate::offers::offer::Offer::issuer_signing_pubkey
789+ /// [`Offer::paths`]: crate::offers::offer::Offer::paths
790+ /// [`Refund`]: crate::offers::refund::Refund
791+ pub fn signing_pubkey( & $self) -> PublicKey {
792+ $contents. signing_pubkey( )
793+ }
794+ } }
795+
764796impl UnsignedBolt12Invoice {
765797 invoice_accessors_common ! ( self , self . contents, Bolt12Invoice ) ;
798+ invoice_accessors_signing_pubkey ! ( self , self . contents, Bolt12Invoice ) ;
766799 invoice_accessors ! ( self , self . contents) ;
767800}
768801
769802impl Bolt12Invoice {
770803 invoice_accessors_common ! ( self , self . contents, Bolt12Invoice ) ;
804+ invoice_accessors_signing_pubkey ! ( self , self . contents, Bolt12Invoice ) ;
771805 invoice_accessors ! ( self , self . contents) ;
772806
773807 /// Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`].
@@ -954,6 +988,15 @@ impl InvoiceContents {
954988 }
955989 }
956990
991+ fn issuer_signing_pubkey ( & self ) -> Option < PublicKey > {
992+ match self {
993+ InvoiceContents :: ForOffer { invoice_request, .. } => {
994+ invoice_request. inner . offer . issuer_signing_pubkey ( )
995+ } ,
996+ InvoiceContents :: ForRefund { .. } => None ,
997+ }
998+ }
999+
9571000 fn payer_metadata ( & self ) -> & [ u8 ] {
9581001 match self {
9591002 InvoiceContents :: ForOffer { invoice_request, .. } => invoice_request. metadata ( ) ,
0 commit comments