@@ -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
}
@@ -2934,6 +2942,13 @@ where
2934
2942
// Unfunded channel has no update
2935
2943
(None, chan_phase.context().get_counterparty_node_id())
2936
2944
},
2945
+ // TODO(dual_funding): Combine this match arm with above.
2946
+ #[cfg(dual_funding)]
2947
+ ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => {
2948
+ self.finish_close_channel(chan_phase.context_mut().force_shutdown(false));
2949
+ // Unfunded channel has no update
2950
+ (None, chan_phase.context().get_counterparty_node_id())
2951
+ },
2937
2952
}
2938
2953
} else if peer_state.inbound_channel_request_by_id.remove(channel_id).is_some() {
2939
2954
log_error!(logger, "Force-closing channel {}", &channel_id);
@@ -4957,6 +4972,16 @@ where
4957
4972
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
4958
4973
pending_msg_events, counterparty_node_id)
4959
4974
},
4975
+ #[cfg(dual_funding)]
4976
+ ChannelPhase::UnfundedInboundV2(chan) => {
4977
+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
4978
+ pending_msg_events, counterparty_node_id)
4979
+ },
4980
+ #[cfg(dual_funding)]
4981
+ ChannelPhase::UnfundedOutboundV2(chan) => {
4982
+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
4983
+ pending_msg_events, counterparty_node_id)
4984
+ },
4960
4985
}
4961
4986
});
4962
4987
@@ -6053,14 +6078,27 @@ where
6053
6078
num_unfunded_channels += 1;
6054
6079
}
6055
6080
},
6056
- ChannelPhase::UnfundedInboundV1(chan) => {
6057
- if chan.context.minimum_depth().unwrap_or(1) != 0 {
6081
+ ChannelPhase::UnfundedInboundV1(_) => {
6082
+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
6083
+ num_unfunded_channels += 1;
6084
+ }
6085
+ },
6086
+ // TODO(dual_funding): Combine this match arm with above.
6087
+ #[cfg(dual_funding)]
6088
+ ChannelPhase::UnfundedInboundV2(_) => {
6089
+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
6058
6090
num_unfunded_channels += 1;
6059
6091
}
6060
6092
},
6061
6093
ChannelPhase::UnfundedOutboundV1(_) => {
6062
6094
// Outbound channels don't contribute to the unfunded count in the DoS context.
6063
6095
continue;
6096
+ },
6097
+ // TODO(dual_funding): Combine this match arm with above.
6098
+ #[cfg(dual_funding)]
6099
+ ChannelPhase::UnfundedOutboundV2(_) => {
6100
+ // Outbound channels don't contribute to the unfunded count in the DoS context.
6101
+ continue;
6064
6102
}
6065
6103
}
6066
6104
}
@@ -6236,7 +6274,7 @@ where
6236
6274
},
6237
6275
}
6238
6276
},
6239
- Some(ChannelPhase::Funded(_)) | Some(ChannelPhase::UnfundedOutboundV1(_) ) => {
6277
+ Some(_ ) => {
6240
6278
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));
6241
6279
},
6242
6280
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))
@@ -6438,6 +6476,15 @@ where
6438
6476
let mut chan = remove_channel_phase!(self, chan_phase_entry);
6439
6477
finish_shutdown = Some(chan.context_mut().force_shutdown(false));
6440
6478
},
6479
+ // TODO(dual_funding): Combine this match arm with above.
6480
+ #[cfg(dual_funding)]
6481
+ ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
6482
+ let context = phase.context_mut();
6483
+ log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
6484
+ self.issue_channel_close_events(&context, ClosureReason::CounterpartyCoopClosedUnfundedChannel);
6485
+ let mut chan = remove_channel_phase!(self, chan_phase_entry);
6486
+ finish_shutdown = Some(chan.context_mut().force_shutdown(false));
6487
+ },
6441
6488
}
6442
6489
} else {
6443
6490
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))
@@ -8248,6 +8295,9 @@ where
8248
8295
match phase {
8249
8296
// Retain unfunded channels.
8250
8297
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
8298
+ // TODO(dual_funding): Combine this match arm with above.
8299
+ #[cfg(dual_funding)]
8300
+ ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
8251
8301
ChannelPhase::Funded(channel) => {
8252
8302
let res = f(channel);
8253
8303
if let Ok((channel_ready_opt, mut timed_out_pending_htlcs, announcement_sigs)) = res {
@@ -8715,6 +8765,14 @@ where
8715
8765
ChannelPhase::UnfundedInboundV1(chan) => {
8716
8766
&mut chan.context
8717
8767
},
8768
+ #[cfg(dual_funding)]
8769
+ ChannelPhase::UnfundedOutboundV2(chan) => {
8770
+ &mut chan.context
8771
+ },
8772
+ #[cfg(dual_funding)]
8773
+ ChannelPhase::UnfundedInboundV2(chan) => {
8774
+ &mut chan.context
8775
+ },
8718
8776
};
8719
8777
// Clean up for removal.
8720
8778
update_maps_on_chan_removal!(self, &context);
0 commit comments