@@ -2080,6 +2080,14 @@ macro_rules! convert_chan_phase_err {
20802080 ChannelPhase::UnfundedInboundV1(channel) => {
20812081 convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
20822082 },
2083+ #[cfg(dual_funding)]
2084+ ChannelPhase::UnfundedOutboundV2(channel) => {
2085+ convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
2086+ },
2087+ #[cfg(dual_funding)]
2088+ ChannelPhase::UnfundedInboundV2(channel) => {
2089+ convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
2090+ },
20832091 }
20842092 };
20852093}
@@ -2945,6 +2953,13 @@ where
29452953 // Unfunded channel has no update
29462954 (None, chan_phase.context().get_counterparty_node_id())
29472955 },
2956+ // TODO(dual_funding): Combine this match arm with above.
2957+ #[cfg(dual_funding)]
2958+ ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => {
2959+ self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, ClosureReason::HolderForceClosed));
2960+ // Unfunded channel has no update
2961+ (None, chan_phase.context().get_counterparty_node_id())
2962+ },
29482963 }
29492964 } else if peer_state.inbound_channel_request_by_id.remove(channel_id).is_some() {
29502965 log_error!(logger, "Force-closing channel {}", &channel_id);
@@ -5023,6 +5038,16 @@ where
50235038 process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
50245039 pending_msg_events, counterparty_node_id)
50255040 },
5041+ #[cfg(dual_funding)]
5042+ ChannelPhase::UnfundedInboundV2(chan) => {
5043+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
5044+ pending_msg_events, counterparty_node_id)
5045+ },
5046+ #[cfg(dual_funding)]
5047+ ChannelPhase::UnfundedOutboundV2(chan) => {
5048+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
5049+ pending_msg_events, counterparty_node_id)
5050+ },
50265051 }
50275052 });
50285053
@@ -6163,14 +6188,27 @@ where
61636188 num_unfunded_channels += 1;
61646189 }
61656190 },
6166- ChannelPhase::UnfundedInboundV1(chan) => {
6167- if chan.context.minimum_depth().unwrap_or(1) != 0 {
6191+ ChannelPhase::UnfundedInboundV1(_) => {
6192+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
6193+ num_unfunded_channels += 1;
6194+ }
6195+ },
6196+ // TODO(dual_funding): Combine this match arm with above.
6197+ #[cfg(dual_funding)]
6198+ ChannelPhase::UnfundedInboundV2(_) => {
6199+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
61686200 num_unfunded_channels += 1;
61696201 }
61706202 },
61716203 ChannelPhase::UnfundedOutboundV1(_) => {
61726204 // Outbound channels don't contribute to the unfunded count in the DoS context.
61736205 continue;
6206+ },
6207+ // TODO(dual_funding): Combine this match arm with above.
6208+ #[cfg(dual_funding)]
6209+ ChannelPhase::UnfundedOutboundV2(_) => {
6210+ // Outbound channels don't contribute to the unfunded count in the DoS context.
6211+ continue;
61746212 }
61756213 }
61766214 }
@@ -6583,6 +6621,14 @@ where
65836621 let mut chan = remove_channel_phase!(self, chan_phase_entry);
65846622 finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
65856623 },
6624+ // TODO(dual_funding): Combine this match arm with above.
6625+ #[cfg(dual_funding)]
6626+ ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
6627+ let context = phase.context_mut();
6628+ log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
6629+ let mut chan = remove_channel_phase!(self, chan_phase_entry);
6630+ finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
6631+ },
65866632 }
65876633 } else {
65886634 return Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}", counterparty_node_id), msg.channel_id))
@@ -8447,6 +8493,9 @@ where
84478493 match phase {
84488494 // Retain unfunded channels.
84498495 ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
8496+ // TODO(dual_funding): Combine this match arm with above.
8497+ #[cfg(dual_funding)]
8498+ ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
84508499 ChannelPhase::Funded(channel) => {
84518500 let res = f(channel);
84528501 if let Ok((channel_ready_opt, mut timed_out_pending_htlcs, announcement_sigs)) = res {
@@ -8914,6 +8963,14 @@ where
89148963 ChannelPhase::UnfundedInboundV1(chan) => {
89158964 &mut chan.context
89168965 },
8966+ #[cfg(dual_funding)]
8967+ ChannelPhase::UnfundedOutboundV2(chan) => {
8968+ &mut chan.context
8969+ },
8970+ #[cfg(dual_funding)]
8971+ ChannelPhase::UnfundedInboundV2(chan) => {
8972+ &mut chan.context
8973+ },
89178974 };
89188975 // Clean up for removal.
89198976 update_maps_on_chan_removal!(self, &context);
0 commit comments