From: Matt Corallo Date: Tue, 6 Jul 2021 23:51:11 +0000 (+0000) Subject: Log shutdown including which side of the channel initiated shutdown X-Git-Tag: v0.0.100~1^2~8 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=267053ff74a09763f6c12223a61fd01137e53624;p=rust-lightning Log shutdown including which side of the channel initiated shutdown --- diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index cd819fb14..e41d6d287 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -3816,6 +3816,16 @@ impl Channel { self.channel_state >= ChannelState::FundingSent as u32 } + /// Returns true if our peer has either initiated or agreed to shut down the channel. + pub fn received_shutdown(&self) -> bool { + (self.channel_state & ChannelState::RemoteShutdownSent as u32) != 0 + } + + /// Returns true if we either initiated or agreed to shut down the channel. + pub fn sent_shutdown(&self) -> bool { + (self.channel_state & ChannelState::LocalShutdownSent as u32) != 0 + } + /// Returns true if this channel is fully shut down. True here implies that no further actions /// may/will be taken on this channel, and thus this object should be freed. Any future changes /// will be handled appropriately by the chain monitor. diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 6c8673b4f..a50c072b4 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -3366,6 +3366,12 @@ impl ChannelMana return Err(MsgHandleErrInternal::send_err_msg_no_close("Got a message for a channel from the wrong node!".to_owned(), msg.channel_id)); } + if !chan_entry.get().received_shutdown() { + log_info!(self.logger, "Received a shutdown message from our couterparty for channel {}{}.", + log_bytes!(msg.channel_id), + if chan_entry.get().sent_shutdown() { " after we initiated shutdown" } else { "" }); + } + let (shutdown, closing_signed, monitor_update, htlcs) = try_chan_entry!(self, chan_entry.get_mut().shutdown(&self.fee_estimator, &self.keys_manager, &their_features, &msg), channel_state, chan_entry); dropped_htlcs = htlcs;