Skip to content

Commit 4b30d14

Browse files
committed
Include payment hash when logging InvoiceError
By including the payment hash from the invoice in an onion message's reply path, it can be used when logging errors as additional context.
1 parent fd060fb commit 4b30d14

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

lightning/src/blinded_path/message.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::blinded_path::utils;
2121
use crate::io;
2222
use crate::io::Cursor;
2323
use crate::ln::channelmanager::PaymentId;
24-
use crate::ln::onion_utils;
24+
use crate::ln::{PaymentHash, onion_utils};
2525
use crate::offers::nonce::Nonce;
2626
use crate::onion_message::packet::ControlTlvs;
2727
use crate::sign::{NodeSigner, Recipient};
@@ -152,6 +152,18 @@ pub enum OffersContext {
152152
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
153153
nonce: Nonce,
154154
},
155+
/// Context used by a [`BlindedPath`] as a reply path for a [`Bolt12Invoice`].
156+
///
157+
/// This variant is intended to be received when handling an [`InvoiceError`].
158+
///
159+
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
160+
/// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError
161+
InboundPayment {
162+
/// The same payment hash as [`Bolt12Invoice::payment_hash`].
163+
///
164+
/// [`Bolt12Invoice::payment_hash`]: crate::offers::invoice::Bolt12Invoice::payment_hash
165+
payment_hash: PaymentHash,
166+
},
155167
}
156168

157169
impl_writeable_tlv_based_enum!(MessageContext,
@@ -168,6 +180,9 @@ impl_writeable_tlv_based_enum!(OffersContext,
168180
(0, payment_id, required),
169181
(1, nonce, required),
170182
},
183+
(3, InboundPayment) => {
184+
(0, payment_hash, required),
185+
},
171186
);
172187

173188
/// Construct blinded onion message hops for the given `intermediate_nodes` and `recipient_node_id`.

lightning/src/ln/channelmanager.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10880,8 +10880,14 @@ where
1088010880
}
1088110881
},
1088210882
OffersMessage::InvoiceError(invoice_error) => {
10883+
let payment_hash = match context {
10884+
OffersContext::InboundPayment { payment_hash } => Some(payment_hash),
10885+
_ => None,
10886+
};
10887+
let logger = WithContext::from(&self.logger, None, None, payment_hash);
10888+
log_trace!(logger, "Received invoice_error: {}", invoice_error);
10889+
1088310890
abandon_if_payment(context);
10884-
log_trace!(self.logger, "Received invoice_error: {}", invoice_error);
1088510891
ResponseInstruction::NoResponse
1088610892
},
1088710893
}

0 commit comments

Comments
 (0)