Merge pull request #2428 from waterson/create-channel-after-accept
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Tue, 15 Aug 2023 22:15:09 +0000 (22:15 +0000)
committerGitHub <noreply@github.com>
Tue, 15 Aug 2023 22:15:09 +0000 (22:15 +0000)
Wait to create a channel until after accepting.

1  2 
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_tests.rs

Simple merge
index 94bbcf2ae678eb96693ec7a01c1ff4d0a2037bb4,2cc0c1484b67518cea600687e9a8882a42b7a120..79c4185456bbc7d7be760595c926205bef85228a
@@@ -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);
                                        }
Simple merge