From 96b0faf124c069181ae1440664200c2f766b7a18 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 20 Apr 2021 21:35:11 +0000 Subject: [PATCH] Log info about HTLC failures when we fail them back --- lightning/src/ln/channel.rs | 6 ++++-- lightning/src/ln/channelmanager.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 8db346a9e..639ac8449 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -1332,7 +1332,7 @@ impl Channel { /// /// Note that it is still possible to hit these assertions in case we find a preimage on-chain /// but then have a reorg which settles on an HTLC-failure on chain. - pub fn get_update_fail_htlc(&mut self, htlc_id_arg: u64, err_packet: msgs::OnionErrorPacket) -> Result, ChannelError> { + pub fn get_update_fail_htlc(&mut self, htlc_id_arg: u64, err_packet: msgs::OnionErrorPacket, logger: &L) -> Result, ChannelError> where L::Target: Logger { if (self.channel_state & (ChannelState::ChannelFunded as u32)) != (ChannelState::ChannelFunded as u32) { panic!("Was asked to fail an HTLC when channel was not in an operational state"); } @@ -1382,6 +1382,7 @@ impl Channel { _ => {} } } + log_trace!(logger, "Placing failure for HTLC ID {} in holding cell", htlc_id_arg); self.holding_cell_htlc_updates.push(HTLCUpdateAwaitingACK::FailHTLC { htlc_id: htlc_id_arg, err_packet, @@ -1389,6 +1390,7 @@ impl Channel { return Ok(None); } + log_trace!(logger, "Failing HTLC ID {} back with a update_fail_htlc message", htlc_id_arg); { let htlc = &mut self.pending_inbound_htlcs[pending_idx]; htlc.state = InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailRelay(err_packet.clone())); @@ -2382,7 +2384,7 @@ impl Channel { } }, &HTLCUpdateAwaitingACK::FailHTLC { htlc_id, ref err_packet } => { - match self.get_update_fail_htlc(htlc_id, err_packet.clone()) { + match self.get_update_fail_htlc(htlc_id, err_packet.clone(), logger) { Ok(update_fail_msg_option) => update_fail_htlcs.push(update_fail_msg_option.unwrap()), Err(e) => { if let ChannelError::Ignore(_) = e {} diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 9445f518c..9f9820c1d 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -2069,7 +2069,7 @@ impl ChannelMana }, HTLCForwardInfo::FailHTLC { htlc_id, err_packet } => { log_trace!(self.logger, "Failing HTLC back to channel with short id {} after delay", short_chan_id); - match chan.get_mut().get_update_fail_htlc(htlc_id, err_packet) { + match chan.get_mut().get_update_fail_htlc(htlc_id, err_packet, &self.logger) { Err(e) => { if let ChannelError::Ignore(msg) = e { log_trace!(self.logger, "Failed to fail backwards to short_id {}: {}", short_chan_id, msg); -- 2.39.5