Skip to content

Commit 1200066

Browse files
committed
Add issuer_id to Bolt12Invoice and StaticInvoice
Useful for determining if the signing_pubkey is the issuer_id or from a blinded path.
1 parent e4c2876 commit 1200066

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

lightning/src/offers/invoice.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,16 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
705705
$contents.supported_quantity()
706706
}
707707

708+
/// A possibly transient id of the recipient.
709+
///
710+
/// From [`Offer::issuer_id`]; `None` if the invoice was created in response to a [`Refund`].
711+
///
712+
/// [`Offer`]: crate::offers::offer::Offer
713+
/// [`Offer::issuer_id`]: crate::offers::offer::Offer::issuer_id
714+
pub fn issuer_id(&$self) -> Option<PublicKey> {
715+
$contents.issuer_id()
716+
}
717+
708718
/// An unpredictable series of bytes from the payer.
709719
///
710720
/// From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
@@ -945,6 +955,15 @@ impl InvoiceContents {
945955
}
946956
}
947957

958+
fn issuer_id(&self) -> Option<PublicKey> {
959+
match self {
960+
InvoiceContents::ForOffer { invoice_request, .. } => {
961+
invoice_request.inner.offer.issuer_id()
962+
},
963+
InvoiceContents::ForRefund { .. } => None,
964+
}
965+
}
966+
948967
fn payer_metadata(&self) -> &[u8] {
949968
match self {
950969
InvoiceContents::ForOffer { invoice_request, .. } => invoice_request.metadata(),

lightning/src/offers/invoice_macros.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ macro_rules! invoice_accessors_common { ($self: ident, $contents: expr, $invoice
126126
}
127127

128128
/// The public key corresponding to the key used to sign the invoice.
129+
///
130+
/// If the invoices was created in response to an [`Offer`], then will be:
131+
/// - [`Offer::issuer_id`] if `Some`, otherwise
132+
/// - the final blinded node id from a [`BlindedPath`] in [`Offer::paths`] if `None`.
133+
///
134+
/// If the invoice was created in response to a [`Refund`], then may be transient id chosen by
135+
/// the recipient.
136+
///
137+
/// [`Offer`]: crate::offers::offer::Offer
138+
/// [`Offer::issuer_id`]: crate::offers::offer::Offer::issuer_id
139+
/// [`Offer::paths`]: crate::offers::offer::Offer::paths
140+
/// [`Refund`]: crate::offers::refund::Refund
129141
pub fn signing_pubkey(&$self) -> PublicKey {
130142
$contents.signing_pubkey()
131143
}

lightning/src/offers/static_invoice.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
238238
pub fn supported_quantity(&$self) -> Quantity {
239239
$contents.supported_quantity()
240240
}
241+
242+
/// A possibly transient id of the recipient, from [`Offer::issuer_id`].
243+
///
244+
/// [`Offer::issuer_id`]: crate::offers::offer::Offer::issuer_id
245+
pub fn issuer_id(&$self) -> Option<PublicKey> {
246+
$contents.issuer_id()
247+
}
241248
} }
242249

243250
impl UnsignedStaticInvoice {
@@ -405,6 +412,10 @@ impl InvoiceContents {
405412
self.offer.supported_quantity()
406413
}
407414

415+
fn issuer_id(&self) -> Option<PublicKey> {
416+
self.offer.issuer_id()
417+
}
418+
408419
fn payment_paths(&self) -> &[(BlindedPayInfo, BlindedPath)] {
409420
&self.payment_paths[..]
410421
}

0 commit comments

Comments
 (0)