From: Matt Corallo <649246+TheBlueMatt@users.noreply.github.com> Date: Tue, 15 Aug 2023 22:15:09 +0000 (+0000) Subject: Merge pull request #2428 from waterson/create-channel-after-accept X-Git-Tag: v0.0.117-alpha1~59 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=fe0f845582ae707ac523edc6e4b9cab64cb4306a;p=rust-lightning Merge pull request #2428 from waterson/create-channel-after-accept Wait to create a channel until after accepting. --- fe0f845582ae707ac523edc6e4b9cab64cb4306a diff --cc lightning/src/ln/channelmanager.rs index 94bbcf2ae,2cc0c1484..79c418545 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@@ -4488,11 -4518,24 +4522,26 @@@ wher true } }; - peer_state.outbound_v1_channel_by_id.retain(|chan_id, chan| process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context)); - peer_state.inbound_v1_channel_by_id.retain(|chan_id, chan| process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context)); + peer_state.outbound_v1_channel_by_id.retain(|chan_id, chan| process_unfunded_channel_tick( + chan_id, &mut chan.context, &mut chan.unfunded_context, pending_msg_events)); + peer_state.inbound_v1_channel_by_id.retain(|chan_id, chan| process_unfunded_channel_tick( + chan_id, &mut chan.context, &mut chan.unfunded_context, pending_msg_events)); + for (chan_id, req) in peer_state.inbound_channel_request_by_id.iter_mut() { + if { req.ticks_remaining -= 1 ; req.ticks_remaining } <= 0 { + log_error!(self.logger, "Force-closing unaccepted inbound channel {} for not accepting in a timely manner", log_bytes!(&chan_id[..])); + peer_state.pending_msg_events.push( + events::MessageSendEvent::HandleError { + node_id: counterparty_node_id, + action: msgs::ErrorAction::SendErrorMessage { + msg: msgs::ErrorMessage { channel_id: chan_id.clone(), data: "Channel force-closed".to_owned() } + }, + } + ); + } + } + peer_state.inbound_channel_request_by_id.retain(|_, req| req.ticks_remaining > 0); + if peer_state.ok_to_remove(true) { pending_peers_awaiting_removal.push(counterparty_node_id); }