From: Matt Corallo Date: Tue, 15 Aug 2023 22:22:45 +0000 (+0000) Subject: Ensure we wipe pending un-accepted channel requests on err/discon. X-Git-Tag: v0.0.117-alpha1~56^2~2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=e0255c0fff4cabeb0fc3746b6681c524217cb7a1;p=rust-lightning Ensure we wipe pending un-accepted channel requests on err/discon. 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. --- diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 79c418545..a161ff58f 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -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()