@@ -2004,6 +2004,14 @@ macro_rules! convert_chan_phase_err {
2004
2004
ChannelPhase::UnfundedInboundV1(channel) => {
2005
2005
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
2006
2006
},
2007
+ #[cfg(dual_funding)]
2008
+ ChannelPhase::UnfundedOutboundV2(channel) => {
2009
+ convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
2010
+ },
2011
+ #[cfg(dual_funding)]
2012
+ ChannelPhase::UnfundedInboundV2(channel) => {
2013
+ convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
2014
+ },
2007
2015
}
2008
2016
};
2009
2017
}
@@ -2880,6 +2888,13 @@ where
2880
2888
// Unfunded channel has no update
2881
2889
(None, chan_phase.context().get_counterparty_node_id())
2882
2890
},
2891
+ // TODO(dual_funding): Combine this match arm with above.
2892
+ #[cfg(dual_funding)]
2893
+ ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => {
2894
+ self.finish_close_channel(chan_phase.context_mut().force_shutdown(false));
2895
+ // Unfunded channel has no update
2896
+ (None, chan_phase.context().get_counterparty_node_id())
2897
+ },
2883
2898
}
2884
2899
} else if peer_state.inbound_channel_request_by_id.remove(channel_id).is_some() {
2885
2900
log_error!(logger, "Force-closing channel {}", &channel_id);
@@ -4887,6 +4902,16 @@ where
4887
4902
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
4888
4903
pending_msg_events, counterparty_node_id)
4889
4904
},
4905
+ #[cfg(dual_funding)]
4906
+ ChannelPhase::UnfundedInboundV2(chan) => {
4907
+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
4908
+ pending_msg_events, counterparty_node_id)
4909
+ },
4910
+ #[cfg(dual_funding)]
4911
+ ChannelPhase::UnfundedOutboundV2(chan) => {
4912
+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
4913
+ pending_msg_events, counterparty_node_id)
4914
+ },
4890
4915
}
4891
4916
});
4892
4917
@@ -5981,14 +6006,27 @@ where
5981
6006
num_unfunded_channels += 1;
5982
6007
}
5983
6008
},
5984
- ChannelPhase::UnfundedInboundV1(chan) => {
5985
- if chan.context.minimum_depth().unwrap_or(1) != 0 {
6009
+ ChannelPhase::UnfundedInboundV1(_) => {
6010
+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
6011
+ num_unfunded_channels += 1;
6012
+ }
6013
+ },
6014
+ // TODO(dual_funding): Combine this match arm with above.
6015
+ #[cfg(dual_funding)]
6016
+ ChannelPhase::UnfundedInboundV2(_) => {
6017
+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
5986
6018
num_unfunded_channels += 1;
5987
6019
}
5988
6020
},
5989
6021
ChannelPhase::UnfundedOutboundV1(_) => {
5990
6022
// Outbound channels don't contribute to the unfunded count in the DoS context.
5991
6023
continue;
6024
+ },
6025
+ // TODO(dual_funding): Combine this match arm with above.
6026
+ #[cfg(dual_funding)]
6027
+ ChannelPhase::UnfundedOutboundV2(_) => {
6028
+ // Outbound channels don't contribute to the unfunded count in the DoS context.
6029
+ continue;
5992
6030
}
5993
6031
}
5994
6032
}
@@ -6164,7 +6202,7 @@ where
6164
6202
},
6165
6203
}
6166
6204
},
6167
- Some(ChannelPhase::Funded(_)) | Some(ChannelPhase::UnfundedOutboundV1(_) ) => {
6205
+ Some(_ ) => {
6168
6206
return Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got an unexpected funding_created message from peer with counterparty_node_id {}", counterparty_node_id), msg.temporary_channel_id));
6169
6207
},
6170
6208
None => 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.temporary_channel_id))
@@ -6366,6 +6404,15 @@ where
6366
6404
let mut chan = remove_channel_phase!(self, chan_phase_entry);
6367
6405
finish_shutdown = Some(chan.context_mut().force_shutdown(false));
6368
6406
},
6407
+ // TODO(dual_funding): Combine this match arm with above.
6408
+ #[cfg(dual_funding)]
6409
+ ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
6410
+ let context = phase.context_mut();
6411
+ log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
6412
+ self.issue_channel_close_events(&context, ClosureReason::CounterpartyCoopClosedUnfundedChannel);
6413
+ let mut chan = remove_channel_phase!(self, chan_phase_entry);
6414
+ finish_shutdown = Some(chan.context_mut().force_shutdown(false));
6415
+ },
6369
6416
}
6370
6417
} else {
6371
6418
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))
@@ -8174,6 +8221,9 @@ where
8174
8221
match phase {
8175
8222
// Retain unfunded channels.
8176
8223
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
8224
+ // TODO(dual_funding): Combine this match arm with above.
8225
+ #[cfg(dual_funding)]
8226
+ ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
8177
8227
ChannelPhase::Funded(channel) => {
8178
8228
let res = f(channel);
8179
8229
if let Ok((channel_ready_opt, mut timed_out_pending_htlcs, announcement_sigs)) = res {
@@ -8641,6 +8691,14 @@ where
8641
8691
ChannelPhase::UnfundedInboundV1(chan) => {
8642
8692
&mut chan.context
8643
8693
},
8694
+ #[cfg(dual_funding)]
8695
+ ChannelPhase::UnfundedOutboundV2(chan) => {
8696
+ &mut chan.context
8697
+ },
8698
+ #[cfg(dual_funding)]
8699
+ ChannelPhase::UnfundedInboundV2(chan) => {
8700
+ &mut chan.context
8701
+ },
8644
8702
};
8645
8703
// Clean up for removal.
8646
8704
update_maps_on_chan_removal!(self, &context);
0 commit comments