@@ -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);
@@ -5023,6 +5038,16 @@ where
5023
5038
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
5024
5039
pending_msg_events, counterparty_node_id)
5025
5040
},
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
+ },
5026
5051
}
5027
5052
});
5028
5053
@@ -6163,14 +6188,27 @@ where
6163
6188
num_unfunded_channels += 1;
6164
6189
}
6165
6190
},
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 {
6168
6200
num_unfunded_channels += 1;
6169
6201
}
6170
6202
},
6171
6203
ChannelPhase::UnfundedOutboundV1(_) => {
6172
6204
// Outbound channels don't contribute to the unfunded count in the DoS context.
6173
6205
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;
6174
6212
}
6175
6213
}
6176
6214
}
@@ -6583,6 +6621,14 @@ where
6583
6621
let mut chan = remove_channel_phase!(self, chan_phase_entry);
6584
6622
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
6585
6623
},
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
+ },
6586
6632
}
6587
6633
} else {
6588
6634
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
8447
8493
match phase {
8448
8494
// Retain unfunded channels.
8449
8495
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,
8450
8499
ChannelPhase::Funded(channel) => {
8451
8500
let res = f(channel);
8452
8501
if let Ok((channel_ready_opt, mut timed_out_pending_htlcs, announcement_sigs)) = res {
@@ -8914,6 +8963,14 @@ where
8914
8963
ChannelPhase::UnfundedInboundV1(chan) => {
8915
8964
&mut chan.context
8916
8965
},
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
+ },
8917
8974
};
8918
8975
// Clean up for removal.
8919
8976
update_maps_on_chan_removal!(self, &context);
0 commit comments