@@ -714,6 +714,16 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
714
714
$contents. supported_quantity( )
715
715
}
716
716
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
+
717
727
/// An unpredictable series of bytes from the payer.
718
728
///
719
729
/// From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
@@ -761,13 +771,37 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
761
771
}
762
772
} }
763
773
774
+
775
+ macro_rules! invoice_accessors_signing_pubkey {
776
+ ( $self: ident, $contents: expr, $invoice_type: ty) =>
777
+ {
778
+ /// The 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 this may be a transient id
785
+ /// chosen by 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
+
764
796
impl UnsignedBolt12Invoice {
765
797
invoice_accessors_common ! ( self , self . contents, Bolt12Invoice ) ;
798
+ invoice_accessors_signing_pubkey ! ( self , self . contents, Bolt12Invoice ) ;
766
799
invoice_accessors ! ( self , self . contents) ;
767
800
}
768
801
769
802
impl Bolt12Invoice {
770
803
invoice_accessors_common ! ( self , self . contents, Bolt12Invoice ) ;
804
+ invoice_accessors_signing_pubkey ! ( self , self . contents, Bolt12Invoice ) ;
771
805
invoice_accessors ! ( self , self . contents) ;
772
806
773
807
/// Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`].
@@ -954,6 +988,15 @@ impl InvoiceContents {
954
988
}
955
989
}
956
990
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
+
957
1000
fn payer_metadata ( & self ) -> & [ u8 ] {
958
1001
match self {
959
1002
InvoiceContents :: ForOffer { invoice_request, .. } => invoice_request. metadata ( ) ,
0 commit comments