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.
This commit is contained in:
Matt Corallo 2023-12-02 20:00:36 +00:00
parent 6b43153861
commit f57295f9d9
2 changed files with 14 additions and 1 deletions

View file

@ -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<Txid>,
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<SP: Deref> ChannelContext<SP> 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<SP: Deref> Channel<SP> 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<SP: Deref> Channel<SP> 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<SP: Deref> Channel<SP> 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)

View file

@ -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);