@@ -2055,6 +2055,14 @@ macro_rules! convert_chan_phase_err {
2055
2055
ChannelPhase::UnfundedInboundV1(channel) => {
2056
2056
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
2057
2057
},
2058
+ #[cfg(dual_funding)]
2059
+ ChannelPhase::UnfundedOutboundV2(channel) => {
2060
+ convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
2061
+ },
2062
+ #[cfg(dual_funding)]
2063
+ ChannelPhase::UnfundedInboundV2(channel) => {
2064
+ convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
2065
+ },
2058
2066
}
2059
2067
};
2060
2068
}
@@ -2923,6 +2931,13 @@ where
2923
2931
// Unfunded channel has no update
2924
2932
(None, chan_phase.context().get_counterparty_node_id())
2925
2933
},
2934
+ // TODO(dual_funding): Combine this match arm with above.
2935
+ #[cfg(dual_funding)]
2936
+ ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => {
2937
+ self.finish_close_channel(chan_phase.context_mut().force_shutdown(false));
2938
+ // Unfunded channel has no update
2939
+ (None, chan_phase.context().get_counterparty_node_id())
2940
+ },
2926
2941
}
2927
2942
} else if peer_state.inbound_channel_request_by_id.remove(channel_id).is_some() {
2928
2943
log_error!(logger, "Force-closing channel {}", &channel_id);
@@ -4946,6 +4961,16 @@ where
4946
4961
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
4947
4962
pending_msg_events, counterparty_node_id)
4948
4963
},
4964
+ #[cfg(dual_funding)]
4965
+ ChannelPhase::UnfundedInboundV2(chan) => {
4966
+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
4967
+ pending_msg_events, counterparty_node_id)
4968
+ },
4969
+ #[cfg(dual_funding)]
4970
+ ChannelPhase::UnfundedOutboundV2(chan) => {
4971
+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
4972
+ pending_msg_events, counterparty_node_id)
4973
+ },
4949
4974
}
4950
4975
});
4951
4976
@@ -6042,14 +6067,27 @@ where
6042
6067
num_unfunded_channels += 1;
6043
6068
}
6044
6069
},
6045
- ChannelPhase::UnfundedInboundV1(chan) => {
6046
- if chan.context.minimum_depth().unwrap_or(1) != 0 {
6070
+ ChannelPhase::UnfundedInboundV1(_) => {
6071
+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
6072
+ num_unfunded_channels += 1;
6073
+ }
6074
+ },
6075
+ // TODO(dual_funding): Combine this match arm with above.
6076
+ #[cfg(dual_funding)]
6077
+ ChannelPhase::UnfundedInboundV2(_) => {
6078
+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
6047
6079
num_unfunded_channels += 1;
6048
6080
}
6049
6081
},
6050
6082
ChannelPhase::UnfundedOutboundV1(_) => {
6051
6083
// Outbound channels don't contribute to the unfunded count in the DoS context.
6052
6084
continue;
6085
+ },
6086
+ // TODO(dual_funding): Combine this match arm with above.
6087
+ #[cfg(dual_funding)]
6088
+ ChannelPhase::UnfundedOutboundV2(_) => {
6089
+ // Outbound channels don't contribute to the unfunded count in the DoS context.
6090
+ continue;
6053
6091
}
6054
6092
}
6055
6093
}
@@ -6225,7 +6263,7 @@ where
6225
6263
},
6226
6264
}
6227
6265
},
6228
- Some(ChannelPhase::Funded(_)) | Some(ChannelPhase::UnfundedOutboundV1(_) ) => {
6266
+ Some(_ ) => {
6229
6267
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));
6230
6268
},
6231
6269
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))
@@ -6448,6 +6486,15 @@ where
6448
6486
let mut chan = remove_channel_phase!(self, chan_phase_entry);
6449
6487
finish_shutdown = Some(chan.context_mut().force_shutdown(false));
6450
6488
},
6489
+ // TODO(dual_funding): Combine this match arm with above.
6490
+ #[cfg(dual_funding)]
6491
+ ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
6492
+ let context = phase.context_mut();
6493
+ log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
6494
+ self.issue_channel_close_events(&context, ClosureReason::CounterpartyCoopClosedUnfundedChannel);
6495
+ let mut chan = remove_channel_phase!(self, chan_phase_entry);
6496
+ finish_shutdown = Some(chan.context_mut().force_shutdown(false));
6497
+ },
6451
6498
}
6452
6499
} else {
6453
6500
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))
@@ -8263,6 +8310,9 @@ where
8263
8310
match phase {
8264
8311
// Retain unfunded channels.
8265
8312
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
8313
+ // TODO(dual_funding): Combine this match arm with above.
8314
+ #[cfg(dual_funding)]
8315
+ ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
8266
8316
ChannelPhase::Funded(channel) => {
8267
8317
let res = f(channel);
8268
8318
if let Ok((channel_ready_opt, mut timed_out_pending_htlcs, announcement_sigs)) = res {
@@ -8730,6 +8780,14 @@ where
8730
8780
ChannelPhase::UnfundedInboundV1(chan) => {
8731
8781
&mut chan.context
8732
8782
},
8783
+ #[cfg(dual_funding)]
8784
+ ChannelPhase::UnfundedOutboundV2(chan) => {
8785
+ &mut chan.context
8786
+ },
8787
+ #[cfg(dual_funding)]
8788
+ ChannelPhase::UnfundedInboundV2(chan) => {
8789
+ &mut chan.context
8790
+ },
8733
8791
};
8734
8792
// Clean up for removal.
8735
8793
update_maps_on_chan_removal!(self, &context);
0 commit comments