@@ -2070,6 +2070,14 @@ macro_rules! convert_chan_phase_err {
20702070 ChannelPhase::UnfundedInboundV1(channel) => {
20712071 convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
20722072 },
2073+ #[cfg(dual_funding)]
2074+ ChannelPhase::UnfundedOutboundV2(channel) => {
2075+ convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
2076+ },
2077+ #[cfg(dual_funding)]
2078+ ChannelPhase::UnfundedInboundV2(channel) => {
2079+ convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
2080+ },
20732081 }
20742082 };
20752083}
@@ -2935,6 +2943,13 @@ where
29352943 // Unfunded channel has no update
29362944 (None, chan_phase.context().get_counterparty_node_id())
29372945 },
2946+ // TODO(dual_funding): Combine this match arm with above.
2947+ #[cfg(dual_funding)]
2948+ ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => {
2949+ self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, ClosureReason::HolderForceClosed));
2950+ // Unfunded channel has no update
2951+ (None, chan_phase.context().get_counterparty_node_id())
2952+ },
29382953 }
29392954 } else if peer_state.inbound_channel_request_by_id.remove(channel_id).is_some() {
29402955 log_error!(logger, "Force-closing channel {}", &channel_id);
@@ -5011,6 +5026,16 @@ where
50115026 process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
50125027 pending_msg_events, counterparty_node_id)
50135028 },
5029+ #[cfg(dual_funding)]
5030+ ChannelPhase::UnfundedInboundV2(chan) => {
5031+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
5032+ pending_msg_events, counterparty_node_id)
5033+ },
5034+ #[cfg(dual_funding)]
5035+ ChannelPhase::UnfundedOutboundV2(chan) => {
5036+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
5037+ pending_msg_events, counterparty_node_id)
5038+ },
50145039 }
50155040 });
50165041
@@ -6152,14 +6177,27 @@ where
61526177 num_unfunded_channels += 1;
61536178 }
61546179 },
6155- ChannelPhase::UnfundedInboundV1(chan) => {
6156- if chan.context.minimum_depth().unwrap_or(1) != 0 {
6180+ ChannelPhase::UnfundedInboundV1(_) => {
6181+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
6182+ num_unfunded_channels += 1;
6183+ }
6184+ },
6185+ // TODO(dual_funding): Combine this match arm with above.
6186+ #[cfg(dual_funding)]
6187+ ChannelPhase::UnfundedInboundV2(_) => {
6188+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
61576189 num_unfunded_channels += 1;
61586190 }
61596191 },
61606192 ChannelPhase::UnfundedOutboundV1(_) => {
61616193 // Outbound channels don't contribute to the unfunded count in the DoS context.
61626194 continue;
6195+ },
6196+ // TODO(dual_funding): Combine this match arm with above.
6197+ #[cfg(dual_funding)]
6198+ ChannelPhase::UnfundedOutboundV2(_) => {
6199+ // Outbound channels don't contribute to the unfunded count in the DoS context.
6200+ continue;
61636201 }
61646202 }
61656203 }
@@ -6573,6 +6611,14 @@ where
65736611 let mut chan = remove_channel_phase!(self, chan_phase_entry);
65746612 finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
65756613 },
6614+ // TODO(dual_funding): Combine this match arm with above.
6615+ #[cfg(dual_funding)]
6616+ ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
6617+ let context = phase.context_mut();
6618+ log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
6619+ let mut chan = remove_channel_phase!(self, chan_phase_entry);
6620+ finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
6621+ },
65766622 }
65776623 } else {
65786624 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))
@@ -8437,6 +8483,9 @@ where
84378483 match phase {
84388484 // Retain unfunded channels.
84398485 ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
8486+ // TODO(dual_funding): Combine this match arm with above.
8487+ #[cfg(dual_funding)]
8488+ ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
84408489 ChannelPhase::Funded(channel) => {
84418490 let res = f(channel);
84428491 if let Ok((channel_ready_opt, mut timed_out_pending_htlcs, announcement_sigs)) = res {
@@ -8904,6 +8953,14 @@ where
89048953 ChannelPhase::UnfundedInboundV1(chan) => {
89058954 &mut chan.context
89068955 },
8956+ #[cfg(dual_funding)]
8957+ ChannelPhase::UnfundedOutboundV2(chan) => {
8958+ &mut chan.context
8959+ },
8960+ #[cfg(dual_funding)]
8961+ ChannelPhase::UnfundedInboundV2(chan) => {
8962+ &mut chan.context
8963+ },
89078964 };
89088965 // Clean up for removal.
89098966 update_maps_on_chan_removal!(self, &context);
0 commit comments