Skip to content

Commit f57295f

Browse files
committed
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.
1 parent 6b43153 commit f57295f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lightning/src/ln/channel.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,8 @@ pub(crate) struct ShutdownResult {
599599
/// An unbroadcasted batch funding transaction id. The closure of this channel should be
600600
/// propagated to the remainder of the batch.
601601
pub(crate) unbroadcasted_batch_funding_txid: Option<Txid>,
602+
pub(crate) channel_id: ChannelId,
603+
pub(crate) counterparty_node_id: PublicKey,
602604
}
603605

604606
/// If the majority of the channels funds are to the fundee and the initiator holds only just
@@ -2164,6 +2166,8 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
21642166
monitor_update,
21652167
dropped_outbound_htlcs,
21662168
unbroadcasted_batch_funding_txid,
2169+
channel_id: self.channel_id,
2170+
counterparty_node_id: self.counterparty_node_id,
21672171
}
21682172
}
21692173

@@ -4707,6 +4711,8 @@ impl<SP: Deref> Channel<SP> where
47074711
monitor_update: None,
47084712
dropped_outbound_htlcs: Vec::new(),
47094713
unbroadcasted_batch_funding_txid: self.context.unbroadcasted_batch_funding_txid(),
4714+
channel_id: self.context.channel_id,
4715+
counterparty_node_id: self.context.counterparty_node_id,
47104716
};
47114717
let tx = self.build_signed_closing_transaction(&mut closing_tx, &msg.signature, &sig);
47124718
self.context.channel_state = ChannelState::ShutdownComplete as u32;
@@ -4735,6 +4741,8 @@ impl<SP: Deref> Channel<SP> where
47354741
monitor_update: None,
47364742
dropped_outbound_htlcs: Vec::new(),
47374743
unbroadcasted_batch_funding_txid: self.context.unbroadcasted_batch_funding_txid(),
4744+
channel_id: self.context.channel_id,
4745+
counterparty_node_id: self.context.counterparty_node_id,
47384746
};
47394747
self.context.channel_state = ChannelState::ShutdownComplete as u32;
47404748
self.context.update_time_counter += 1;
@@ -5913,6 +5921,8 @@ impl<SP: Deref> Channel<SP> where
59135921
monitor_update: None,
59145922
dropped_outbound_htlcs: Vec::new(),
59155923
unbroadcasted_batch_funding_txid: self.context.unbroadcasted_batch_funding_txid(),
5924+
channel_id: self.context.channel_id,
5925+
counterparty_node_id: self.context.counterparty_node_id,
59165926
};
59175927
self.context.channel_state = ChannelState::ShutdownComplete as u32;
59185928
Some(shutdown_result)

lightning/src/ln/channelmanager.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2808,7 +2808,10 @@ where
28082808
debug_assert_ne!(peer.held_by_thread(), LockHeldState::HeldByThread);
28092809
}
28102810

2811-
log_debug!(self.logger, "Finishing closure of channel with {} HTLCs to fail", shutdown_res.dropped_outbound_htlcs.len());
2811+
let logger = WithContext::from(
2812+
&self.logger, Some(shutdown_res.counterparty_node_id), Some(shutdown_res.channel_id),
2813+
);
2814+
log_debug!(logger, "Finishing closure of channel with {} HTLCs to fail", shutdown_res.dropped_outbound_htlcs.len());
28122815
for htlc_source in shutdown_res.dropped_outbound_htlcs.drain(..) {
28132816
let (source, payment_hash, counterparty_node_id, channel_id) = htlc_source;
28142817
let reason = HTLCFailReason::from_failure_code(0x4000 | 8);

0 commit comments

Comments
 (0)