Fix debug assertion on opening a channel with a disconnected peer
authorMatt Corallo <git@bluematt.me>
Sun, 24 Dec 2023 06:10:38 +0000 (06:10 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 29 Dec 2023 06:24:18 +0000 (06:24 +0000)
If we try to open a channel with a peer that is disconnected (but
with which we have some other channels), we'll end up with an
unfunded channel which will lead to a panic when the peer
reconnects. Here we drop this debug assertion without bother to add
a new test, given this behavior will change in a PR very soon.

lightning/src/ln/channelmanager.rs

index b2b28cdf365cce7ed07eda808089525c039ad015..dae29dcef8250cf0ad51ba085029f746caa7d956 100644 (file)
@@ -8979,13 +8979,7 @@ where
                                let pending_msg_events = &mut peer_state.pending_msg_events;
 
                                peer_state.channel_by_id.iter_mut().filter_map(|(_, phase)|
-                                       if let ChannelPhase::Funded(chan) = phase { Some(chan) } else {
-                                               // Since unfunded channel maps are cleared upon disconnecting a peer, and they're not persisted
-                                               // (so won't be recovered after a crash), they shouldn't exist here and we would never need to
-                                               // worry about closing and removing them.
-                                               debug_assert!(false);
-                                               None
-                                       }
+                                       if let ChannelPhase::Funded(chan) = phase { Some(chan) } else { None }
                                ).for_each(|chan| {
                                        let logger = WithChannelContext::from(&self.logger, &chan.context);
                                        pending_msg_events.push(events::MessageSendEvent::SendChannelReestablish {