Skip to content

Commit e6ee194

Browse files
committed
Include OffersContext in Event::InvoiceReceived
When authenticating that an invoice is for a valid invoice request, the payer metadata is needed. Some of this data will be removed in the next commit and instead be included in the message context of the request's reply path. Add this data to Event::InvoiceReceived so that asynchronous invoice handling can verify properly.
1 parent 2c2f3fe commit e6ee194

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

lightning/src/blinded_path/message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub enum MessageContext {
106106
/// Contains data specific to an [`OffersMessage`].
107107
///
108108
/// [`OffersMessage`]: crate::onion_message::offers::OffersMessage
109-
#[derive(Clone, Debug)]
109+
#[derive(Clone, Debug, Eq, PartialEq)]
110110
pub enum OffersContext {
111111
/// Represents an unknown BOLT12 message context.
112112
///

lightning/src/events/mod.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub mod bump_transaction;
1818

1919
pub use bump_transaction::BumpTransactionEvent;
2020

21+
use crate::blinded_path::message::OffersContext;
2122
use crate::blinded_path::payment::{Bolt12OfferContext, Bolt12RefundContext, PaymentContext, PaymentContextRef};
2223
use crate::chain::transaction;
2324
use crate::ln::channelmanager::{InterceptId, PaymentId, RecipientOnionFields};
@@ -806,6 +807,10 @@ pub enum Event {
806807
payment_id: PaymentId,
807808
/// The invoice to pay.
808809
invoice: Bolt12Invoice,
810+
/// The context of the [`BlindedPath`] used to send the invoice.
811+
///
812+
/// [`BlindedPath`]: crate::blinded_path::BlindedPath
813+
context: OffersContext,
809814
/// A responder for replying with an [`InvoiceError`] if needed.
810815
///
811816
/// `None` if the invoice wasn't sent with a reply path.
@@ -1648,12 +1653,13 @@ impl Writeable for Event {
16481653
(0, peer_node_id, required),
16491654
});
16501655
},
1651-
&Event::InvoiceReceived { ref payment_id, ref invoice, ref responder } => {
1656+
&Event::InvoiceReceived { ref payment_id, ref invoice, ref context, ref responder } => {
16521657
41u8.write(writer)?;
16531658
write_tlv_fields!(writer, {
16541659
(0, payment_id, required),
16551660
(2, invoice, required),
1656-
(4, responder, option),
1661+
(4, context, required),
1662+
(6, responder, option),
16571663
});
16581664
},
16591665
&Event::FundingTxBroadcastSafe { ref channel_id, ref user_channel_id, ref funding_txo, ref counterparty_node_id, ref former_temporary_channel_id} => {
@@ -2107,11 +2113,13 @@ impl MaybeReadable for Event {
21072113
_init_and_read_len_prefixed_tlv_fields!(reader, {
21082114
(0, payment_id, required),
21092115
(2, invoice, required),
2110-
(4, responder, option),
2116+
(4, context, required),
2117+
(6, responder, option),
21112118
});
21122119
Ok(Some(Event::InvoiceReceived {
21132120
payment_id: payment_id.0.unwrap(),
21142121
invoice: invoice.0.unwrap(),
2122+
context: context.0.unwrap(),
21152123
responder,
21162124
}))
21172125
};

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10832,7 +10832,9 @@ where
1083210832
if invoice.invoice_features().requires_unknown_bits_from(&features) {
1083310833
Err(InvoiceError::from(Bolt12SemanticError::UnknownRequiredFeatures))
1083410834
} else if self.default_configuration.manually_handle_bolt12_invoices {
10835-
let event = Event::InvoiceReceived { payment_id, invoice, responder };
10835+
let event = Event::InvoiceReceived {
10836+
payment_id, invoice, context, responder,
10837+
};
1083610838
self.pending_events.lock().unwrap().push_back((event, None));
1083710839
return ResponseInstruction::NoResponse;
1083810840
} else {

lightning/src/offers/nonce.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::prelude::*;
2626
/// [`Offer::metadata`]: crate::offers::offer::Offer::metadata
2727
/// [`Offer::signing_pubkey`]: crate::offers::offer::Offer::signing_pubkey
2828
/// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
29-
#[derive(Clone, Copy, Debug, PartialEq)]
29+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
3030
pub struct Nonce(pub(crate) [u8; Self::LENGTH]);
3131

3232
impl Nonce {

0 commit comments

Comments
 (0)