]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Ensure we wipe pending un-accepted channel requests on err/discon.
authorMatt Corallo <git@bluematt.me>
Tue, 15 Aug 2023 22:22:45 +0000 (22:22 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 15 Aug 2023 22:22:45 +0000 (22:22 +0000)
If we have a pending inbound un-accepted channel but receive an
error message for it from our peer, or our peer disconnects, we
should remove the pending entry, ensuring any attempts to accept
it fail.

lightning/src/ln/channelmanager.rs

index 79c4185456bbc7d7be760595c926205bef85228a..a161ff58f04aea9bad238258ca6b74b7be1e305a 100644 (file)
@@ -7350,6 +7350,9 @@ where
                                        self.issue_channel_close_events(&chan.context, ClosureReason::DisconnectedPeer);
                                        false
                                });
+                               // Note that we don't bother generating any events for pre-accept channels -
+                               // they're not considered "channels" yet from the PoV of our events interface.
+                               peer_state.inbound_channel_request_by_id.clear();
                                pending_msg_events.retain(|msg| {
                                        match msg {
                                                // V1 Channel Establishment
@@ -7493,6 +7496,9 @@ where
                                if peer_state_mutex_opt.is_none() { return; }
                                let mut peer_state_lock = peer_state_mutex_opt.unwrap().lock().unwrap();
                                let peer_state = &mut *peer_state_lock;
+                               // Note that we don't bother generating any events for pre-accept channels -
+                               // they're not considered "channels" yet from the PoV of our events interface.
+                               peer_state.inbound_channel_request_by_id.clear();
                                peer_state.channel_by_id.keys().cloned()
                                        .chain(peer_state.outbound_v1_channel_by_id.keys().cloned())
                                        .chain(peer_state.inbound_v1_channel_by_id.keys().cloned()).collect()