@@ -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
@@ -6164,14 +6189,27 @@ where
6164
6189
num_unfunded_channels += 1;
6165
6190
}
6166
6191
},
6167
- ChannelPhase::UnfundedInboundV1(chan) => {
6168
- if chan.context.minimum_depth().unwrap_or(1) != 0 {
6192
+ ChannelPhase::UnfundedInboundV1(_) => {
6193
+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
6194
+ num_unfunded_channels += 1;
6195
+ }
6196
+ },
6197
+ // TODO(dual_funding): Combine this match arm with above.
6198
+ #[cfg(dual_funding)]
6199
+ ChannelPhase::UnfundedInboundV2(_) => {
6200
+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
6169
6201
num_unfunded_channels += 1;
6170
6202
}
6171
6203
},
6172
6204
ChannelPhase::UnfundedOutboundV1(_) => {
6173
6205
// Outbound channels don't contribute to the unfunded count in the DoS context.
6174
6206
continue;
6207
+ },
6208
+ // TODO(dual_funding): Combine this match arm with above.
6209
+ #[cfg(dual_funding)]
6210
+ ChannelPhase::UnfundedOutboundV2(_) => {
6211
+ // Outbound channels don't contribute to the unfunded count in the DoS context.
6212
+ continue;
6175
6213
}
6176
6214
}
6177
6215
}
@@ -6584,6 +6622,14 @@ where
6584
6622
let mut chan = remove_channel_phase!(self, chan_phase_entry);
6585
6623
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
6586
6624
},
6625
+ // TODO(dual_funding): Combine this match arm with above.
6626
+ #[cfg(dual_funding)]
6627
+ ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
6628
+ let context = phase.context_mut();
6629
+ log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
6630
+ let mut chan = remove_channel_phase!(self, chan_phase_entry);
6631
+ finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
6632
+ },
6587
6633
}
6588
6634
} else {
6589
6635
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))
@@ -8448,6 +8494,9 @@ where
8448
8494
match phase {
8449
8495
// Retain unfunded channels.
8450
8496
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
8497
+ // TODO(dual_funding): Combine this match arm with above.
8498
+ #[cfg(dual_funding)]
8499
+ ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
8451
8500
ChannelPhase::Funded(channel) => {
8452
8501
let res = f(channel);
8453
8502
if let Ok((channel_ready_opt, mut timed_out_pending_htlcs, announcement_sigs)) = res {
@@ -8915,6 +8964,14 @@ where
8915
8964
ChannelPhase::UnfundedInboundV1(chan) => {
8916
8965
&mut chan.context
8917
8966
},
8967
+ #[cfg(dual_funding)]
8968
+ ChannelPhase::UnfundedOutboundV2(chan) => {
8969
+ &mut chan.context
8970
+ },
8971
+ #[cfg(dual_funding)]
8972
+ ChannelPhase::UnfundedInboundV2(chan) => {
8973
+ &mut chan.context
8974
+ },
8918
8975
};
8919
8976
// Clean up for removal.
8920
8977
update_maps_on_chan_removal!(self, &context);
0 commit comments