Skip to content

Commit 19f49af

Browse files
committed
f - separate signing_pubkey macros
1 parent 1200066 commit 19f49af

File tree

3 files changed

+42
-17
lines changed

3 files changed

+42
-17
lines changed

lightning/src/offers/invoice.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,13 +762,37 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
762762
}
763763
} }
764764

765+
766+
macro_rules! invoice_accessors_signing_pubkey {
767+
($self: ident, $contents: expr, $invoice_type: ty) =>
768+
{
769+
/// The public key corresponding to the key used to sign the invoice.
770+
///
771+
/// If the invoices was created in response to an [`Offer`], then will be:
772+
/// - [`Offer::issuer_id`] if `Some`, otherwise
773+
/// - the final blinded node id from a [`BlindedPath`] in [`Offer::paths`] if `None`.
774+
///
775+
/// If the invoice was created in response to a [`Refund`], then may be a transient id chosen by
776+
/// the recipient.
777+
///
778+
/// [`Offer`]: crate::offers::offer::Offer
779+
/// [`Offer::issuer_id`]: crate::offers::offer::Offer::issuer_id
780+
/// [`Offer::paths`]: crate::offers::offer::Offer::paths
781+
/// [`Refund`]: crate::offers::refund::Refund
782+
pub fn signing_pubkey(&$self) -> PublicKey {
783+
$contents.signing_pubkey()
784+
}
785+
} }
786+
765787
impl UnsignedBolt12Invoice {
766788
invoice_accessors_common!(self, self.contents, Bolt12Invoice);
789+
invoice_accessors_signing_pubkey!(self, self.contents, Bolt12Invoice);
767790
invoice_accessors!(self, self.contents);
768791
}
769792

770793
impl Bolt12Invoice {
771794
invoice_accessors_common!(self, self.contents, Bolt12Invoice);
795+
invoice_accessors_signing_pubkey!(self, self.contents, Bolt12Invoice);
772796
invoice_accessors!(self, self.contents);
773797

774798
/// Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`].

lightning/src/offers/invoice_macros.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,6 @@ macro_rules! invoice_accessors_common { ($self: ident, $contents: expr, $invoice
124124
pub fn invoice_features(&$self) -> &Bolt12InvoiceFeatures {
125125
$contents.features()
126126
}
127-
128-
/// 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
141-
pub fn signing_pubkey(&$self) -> PublicKey {
142-
$contents.signing_pubkey()
143-
}
144127
} }
145128

146129
pub(super) use invoice_accessors_common;

lightning/src/offers/static_invoice.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,22 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => {
247247
}
248248
} }
249249

250+
macro_rules! invoice_accessors_signing_pubkey {
251+
($self: ident, $contents: expr, $invoice_type: ty) =>
252+
{
253+
/// The public key corresponding to the key used to sign the invoice.
254+
///
255+
/// This will be:
256+
/// - [`Offer::issuer_id`] if `Some`, otherwise
257+
/// - the final blinded node id from a [`BlindedPath`] in [`Offer::paths`] if `None`.
258+
///
259+
/// [`Offer::issuer_id`]: crate::offers::offer::Offer::issuer_id
260+
/// [`Offer::paths`]: crate::offers::offer::Offer::paths
261+
pub fn signing_pubkey(&$self) -> PublicKey {
262+
$contents.signing_pubkey()
263+
}
264+
} }
265+
250266
impl UnsignedStaticInvoice {
251267
fn new(offer_bytes: &Vec<u8>, contents: InvoiceContents) -> Self {
252268
let (_, invoice_tlv_stream) = contents.as_tlv_stream();
@@ -276,6 +292,7 @@ impl UnsignedStaticInvoice {
276292
}
277293

278294
invoice_accessors_common!(self, self.contents, StaticInvoice);
295+
invoice_accessors_signing_pubkey!(self, self.contents, StaticInvoice);
279296
invoice_accessors!(self, self.contents);
280297
}
281298

@@ -311,6 +328,7 @@ where
311328

312329
impl StaticInvoice {
313330
invoice_accessors_common!(self, self.contents, StaticInvoice);
331+
invoice_accessors_signing_pubkey!(self, self.contents, StaticInvoice);
314332
invoice_accessors!(self, self.contents);
315333

316334
/// Signature of the invoice verified using [`StaticInvoice::signing_pubkey`].

0 commit comments

Comments
 (0)