From: Jeffrey Czyz Date: Wed, 3 Jul 2024 16:02:08 +0000 (-0500) Subject: Include payment hash when logging InvoiceError X-Git-Tag: v0.0.124-beta~30^2~3 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=2fc0c1b85cb031fb2d2af93e34ad618b15275463;p=rust-lightning 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. --- diff --git a/lightning/src/blinded_path/message.rs b/lightning/src/blinded_path/message.rs index 15bf1a949..2ff799d0e 100644 --- a/lightning/src/blinded_path/message.rs +++ b/lightning/src/blinded_path/message.rs @@ -21,7 +21,7 @@ use crate::blinded_path::utils; use crate::io; use crate::io::Cursor; use crate::ln::channelmanager::PaymentId; -use crate::ln::onion_utils; +use crate::ln::{PaymentHash, onion_utils}; use crate::offers::nonce::Nonce; use crate::onion_message::packet::ControlTlvs; use crate::sign::{NodeSigner, Recipient}; @@ -152,6 +152,18 @@ pub enum OffersContext { /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest nonce: Nonce, }, + /// Context used by a [`BlindedPath`] as a reply path for a [`Bolt12Invoice`]. + /// + /// This variant is intended to be received when handling an [`InvoiceError`]. + /// + /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + /// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + InboundPayment { + /// The same payment hash as [`Bolt12Invoice::payment_hash`]. + /// + /// [`Bolt12Invoice::payment_hash`]: crate::offers::invoice::Bolt12Invoice::payment_hash + payment_hash: PaymentHash, + }, } impl_writeable_tlv_based_enum!(MessageContext, @@ -168,6 +180,9 @@ impl_writeable_tlv_based_enum!(OffersContext, (0, payment_id, required), (1, nonce, required), }, + (3, InboundPayment) => { + (0, payment_hash, required), + }, ); /// Construct blinded onion message hops for the given `intermediate_nodes` and `recipient_node_id`. diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 10c010e89..16c06e8de 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -10879,8 +10879,14 @@ where } }, OffersMessage::InvoiceError(invoice_error) => { + let payment_hash = match context { + OffersContext::InboundPayment { payment_hash } => Some(payment_hash), + _ => None, + }; + let logger = WithContext::from(&self.logger, None, None, payment_hash); + log_trace!(logger, "Received invoice_error: {}", invoice_error); + abandon_if_payment(context); - log_trace!(self.logger, "Received invoice_error: {}", invoice_error); ResponseInstruction::NoResponse }, }