Log shutdown including which side of the channel initiated shutdown
authorMatt Corallo <git@bluematt.me>
Tue, 6 Jul 2021 23:51:11 +0000 (23:51 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 13 Aug 2021 23:07:53 +0000 (23:07 +0000)
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs

index cd819fb14ddf046e50440c8b0b3e801bf346e023..e41d6d287b914d060149d047408ca5b7c1e2b191 100644 (file)
@@ -3816,6 +3816,16 @@ impl<Signer: Sign> Channel<Signer> {
                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.
index 6c8673b4ff25ee9356fa1f1c15d4d32b07b9de15..a50c072b4cbd07b8740a3c9a69af54c01f44f3b1 100644 (file)
@@ -3366,6 +3366,12 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> 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;