From: Matt Corallo Date: Sat, 2 Dec 2023 20:00:36 +0000 (+0000) Subject: Include counterparty node id and channel id in shutdown log X-Git-Tag: v0.0.119~32^2~5 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=f57295f9d9b6c07cdedfc7cb4f83878eebfb28b6;p=rust-lightning Include counterparty node id and channel id in shutdown log This avoids an important shutdown log being about a channel but not having the channel metadata. --- diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index bd00d671e..7943a6ce4 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -599,6 +599,8 @@ pub(crate) struct ShutdownResult { /// An unbroadcasted batch funding transaction id. The closure of this channel should be /// propagated to the remainder of the batch. pub(crate) unbroadcasted_batch_funding_txid: Option, + pub(crate) channel_id: ChannelId, + pub(crate) counterparty_node_id: PublicKey, } /// If the majority of the channels funds are to the fundee and the initiator holds only just @@ -2164,6 +2166,8 @@ impl ChannelContext where SP::Target: SignerProvider { monitor_update, dropped_outbound_htlcs, unbroadcasted_batch_funding_txid, + channel_id: self.channel_id, + counterparty_node_id: self.counterparty_node_id, } } @@ -4707,6 +4711,8 @@ impl Channel where monitor_update: None, dropped_outbound_htlcs: Vec::new(), unbroadcasted_batch_funding_txid: self.context.unbroadcasted_batch_funding_txid(), + channel_id: self.context.channel_id, + counterparty_node_id: self.context.counterparty_node_id, }; let tx = self.build_signed_closing_transaction(&mut closing_tx, &msg.signature, &sig); self.context.channel_state = ChannelState::ShutdownComplete as u32; @@ -4735,6 +4741,8 @@ impl Channel where monitor_update: None, dropped_outbound_htlcs: Vec::new(), unbroadcasted_batch_funding_txid: self.context.unbroadcasted_batch_funding_txid(), + channel_id: self.context.channel_id, + counterparty_node_id: self.context.counterparty_node_id, }; self.context.channel_state = ChannelState::ShutdownComplete as u32; self.context.update_time_counter += 1; @@ -5913,6 +5921,8 @@ impl Channel where monitor_update: None, dropped_outbound_htlcs: Vec::new(), unbroadcasted_batch_funding_txid: self.context.unbroadcasted_batch_funding_txid(), + channel_id: self.context.channel_id, + counterparty_node_id: self.context.counterparty_node_id, }; self.context.channel_state = ChannelState::ShutdownComplete as u32; Some(shutdown_result) diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 73f1391d5..ac790a57e 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -2808,7 +2808,10 @@ where debug_assert_ne!(peer.held_by_thread(), LockHeldState::HeldByThread); } - log_debug!(self.logger, "Finishing closure of channel with {} HTLCs to fail", shutdown_res.dropped_outbound_htlcs.len()); + let logger = WithContext::from( + &self.logger, Some(shutdown_res.counterparty_node_id), Some(shutdown_res.channel_id), + ); + log_debug!(logger, "Finishing closure of channel with {} HTLCs to fail", shutdown_res.dropped_outbound_htlcs.len()); for htlc_source in shutdown_res.dropped_outbound_htlcs.drain(..) { let (source, payment_hash, counterparty_node_id, channel_id) = htlc_source; let reason = HTLCFailReason::from_failure_code(0x4000 | 8);