Do not Send FundingLocked messages while disconnected
[rust-lightning] / lightning / src / ln / channel.rs
index 9415a142b1c8b5231c78663231fcc61ec55bb6e3..0e0b8e5643abe76e03e6675f62296ba6708e60c3 100644 (file)
@@ -4291,11 +4291,13 @@ impl<Signer: Sign> Channel<Signer> {
 
                if need_commitment_update {
                        if self.channel_state & (ChannelState::MonitorUpdateFailed as u32) == 0 {
-                               let next_per_commitment_point = self.holder_signer.get_per_commitment_point(self.cur_holder_commitment_transaction_number, &self.secp_ctx);
-                               return Some(msgs::FundingLocked {
-                                       channel_id: self.channel_id,
-                                       next_per_commitment_point,
-                               });
+                               if self.channel_state & (ChannelState::PeerDisconnected as u32) == 0 {
+                                       let next_per_commitment_point = self.holder_signer.get_per_commitment_point(self.cur_holder_commitment_transaction_number, &self.secp_ctx);
+                                       return Some(msgs::FundingLocked {
+                                               channel_id: self.channel_id,
+                                               next_per_commitment_point,
+                                       });
+                               }
                        } else {
                                self.monitor_pending_funding_locked = true;
                        }