@@ -2080,6 +2080,14 @@ macro_rules! convert_chan_phase_err {
2080
2080
ChannelPhase::UnfundedInboundV1(channel) => {
2081
2081
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
2082
2082
},
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
+ },
2083
2091
}
2084
2092
};
2085
2093
}
@@ -2945,6 +2953,13 @@ where
2945
2953
// Unfunded channel has no update
2946
2954
(None, chan_phase.context().get_counterparty_node_id())
2947
2955
},
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
+ },
2948
2963
}
2949
2964
} else if peer_state.inbound_channel_request_by_id.remove(channel_id).is_some() {
2950
2965
log_error!(logger, "Force-closing channel {}", &channel_id);
@@ -5022,6 +5037,16 @@ where
5022
5037
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
5023
5038
pending_msg_events, counterparty_node_id)
5024
5039
},
5040
+ #[cfg(dual_funding)]
5041
+ ChannelPhase::UnfundedInboundV2(chan) => {
5042
+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
5043
+ pending_msg_events, counterparty_node_id)
5044
+ },
5045
+ #[cfg(dual_funding)]
5046
+ ChannelPhase::UnfundedOutboundV2(chan) => {
5047
+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
5048
+ pending_msg_events, counterparty_node_id)
5049
+ },
5025
5050
}
5026
5051
});
5027
5052
@@ -6161,14 +6186,27 @@ where
6161
6186
num_unfunded_channels += 1;
6162
6187
}
6163
6188
},
6164
- ChannelPhase::UnfundedInboundV1(chan) => {
6165
- if chan.context.minimum_depth().unwrap_or(1) != 0 {
6189
+ ChannelPhase::UnfundedInboundV1(_) => {
6190
+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
6191
+ num_unfunded_channels += 1;
6192
+ }
6193
+ },
6194
+ // TODO(dual_funding): Combine this match arm with above.
6195
+ #[cfg(dual_funding)]
6196
+ ChannelPhase::UnfundedInboundV2(_) => {
6197
+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
6166
6198
num_unfunded_channels += 1;
6167
6199
}
6168
6200
},
6169
6201
ChannelPhase::UnfundedOutboundV1(_) => {
6170
6202
// Outbound channels don't contribute to the unfunded count in the DoS context.
6171
6203
continue;
6204
+ },
6205
+ // TODO(dual_funding): Combine this match arm with above.
6206
+ #[cfg(dual_funding)]
6207
+ ChannelPhase::UnfundedOutboundV2(_) => {
6208
+ // Outbound channels don't contribute to the unfunded count in the DoS context.
6209
+ continue;
6172
6210
}
6173
6211
}
6174
6212
}
@@ -6581,6 +6619,14 @@ where
6581
6619
let mut chan = remove_channel_phase!(self, chan_phase_entry);
6582
6620
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
6583
6621
},
6622
+ // TODO(dual_funding): Combine this match arm with above.
6623
+ #[cfg(dual_funding)]
6624
+ ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
6625
+ let context = phase.context_mut();
6626
+ log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
6627
+ let mut chan = remove_channel_phase!(self, chan_phase_entry);
6628
+ finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
6629
+ },
6584
6630
}
6585
6631
} else {
6586
6632
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))
@@ -8445,6 +8491,9 @@ where
8445
8491
match phase {
8446
8492
// Retain unfunded channels.
8447
8493
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
8494
+ // TODO(dual_funding): Combine this match arm with above.
8495
+ #[cfg(dual_funding)]
8496
+ ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
8448
8497
ChannelPhase::Funded(channel) => {
8449
8498
let res = f(channel);
8450
8499
if let Ok((channel_ready_opt, mut timed_out_pending_htlcs, announcement_sigs)) = res {
@@ -8912,6 +8961,14 @@ where
8912
8961
ChannelPhase::UnfundedInboundV1(chan) => {
8913
8962
&mut chan.context
8914
8963
},
8964
+ #[cfg(dual_funding)]
8965
+ ChannelPhase::UnfundedOutboundV2(chan) => {
8966
+ &mut chan.context
8967
+ },
8968
+ #[cfg(dual_funding)]
8969
+ ChannelPhase::UnfundedInboundV2(chan) => {
8970
+ &mut chan.context
8971
+ },
8915
8972
};
8916
8973
// Clean up for removal.
8917
8974
update_maps_on_chan_removal!(self, &context);
0 commit comments