@@ -2070,6 +2070,14 @@ macro_rules! convert_chan_phase_err {
2070
2070
ChannelPhase::UnfundedInboundV1(channel) => {
2071
2071
convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
2072
2072
},
2073
+ #[cfg(dual_funding)]
2074
+ ChannelPhase::UnfundedOutboundV2(channel) => {
2075
+ convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
2076
+ },
2077
+ #[cfg(dual_funding)]
2078
+ ChannelPhase::UnfundedInboundV2(channel) => {
2079
+ convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
2080
+ },
2073
2081
}
2074
2082
};
2075
2083
}
@@ -2935,6 +2943,13 @@ where
2935
2943
// Unfunded channel has no update
2936
2944
(None, chan_phase.context().get_counterparty_node_id())
2937
2945
},
2946
+ // TODO(dual_funding): Combine this match arm with above.
2947
+ #[cfg(dual_funding)]
2948
+ ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => {
2949
+ self.finish_close_channel(chan_phase.context_mut().force_shutdown(false, ClosureReason::HolderForceClosed));
2950
+ // Unfunded channel has no update
2951
+ (None, chan_phase.context().get_counterparty_node_id())
2952
+ },
2938
2953
}
2939
2954
} else if peer_state.inbound_channel_request_by_id.remove(channel_id).is_some() {
2940
2955
log_error!(logger, "Force-closing channel {}", &channel_id);
@@ -5011,6 +5026,16 @@ where
5011
5026
process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
5012
5027
pending_msg_events, counterparty_node_id)
5013
5028
},
5029
+ #[cfg(dual_funding)]
5030
+ ChannelPhase::UnfundedInboundV2(chan) => {
5031
+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
5032
+ pending_msg_events, counterparty_node_id)
5033
+ },
5034
+ #[cfg(dual_funding)]
5035
+ ChannelPhase::UnfundedOutboundV2(chan) => {
5036
+ process_unfunded_channel_tick(chan_id, &mut chan.context, &mut chan.unfunded_context,
5037
+ pending_msg_events, counterparty_node_id)
5038
+ },
5014
5039
}
5015
5040
});
5016
5041
@@ -6152,14 +6177,27 @@ where
6152
6177
num_unfunded_channels += 1;
6153
6178
}
6154
6179
},
6155
- ChannelPhase::UnfundedInboundV1(chan) => {
6156
- if chan.context.minimum_depth().unwrap_or(1) != 0 {
6180
+ ChannelPhase::UnfundedInboundV1(_) => {
6181
+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
6182
+ num_unfunded_channels += 1;
6183
+ }
6184
+ },
6185
+ // TODO(dual_funding): Combine this match arm with above.
6186
+ #[cfg(dual_funding)]
6187
+ ChannelPhase::UnfundedInboundV2(_) => {
6188
+ if phase.context().minimum_depth().unwrap_or(1) != 0 {
6157
6189
num_unfunded_channels += 1;
6158
6190
}
6159
6191
},
6160
6192
ChannelPhase::UnfundedOutboundV1(_) => {
6161
6193
// Outbound channels don't contribute to the unfunded count in the DoS context.
6162
6194
continue;
6195
+ },
6196
+ // TODO(dual_funding): Combine this match arm with above.
6197
+ #[cfg(dual_funding)]
6198
+ ChannelPhase::UnfundedOutboundV2(_) => {
6199
+ // Outbound channels don't contribute to the unfunded count in the DoS context.
6200
+ continue;
6163
6201
}
6164
6202
}
6165
6203
}
@@ -6573,6 +6611,14 @@ where
6573
6611
let mut chan = remove_channel_phase!(self, chan_phase_entry);
6574
6612
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
6575
6613
},
6614
+ // TODO(dual_funding): Combine this match arm with above.
6615
+ #[cfg(dual_funding)]
6616
+ ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
6617
+ let context = phase.context_mut();
6618
+ log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
6619
+ let mut chan = remove_channel_phase!(self, chan_phase_entry);
6620
+ finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
6621
+ },
6576
6622
}
6577
6623
} else {
6578
6624
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))
@@ -8437,6 +8483,9 @@ where
8437
8483
match phase {
8438
8484
// Retain unfunded channels.
8439
8485
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => true,
8486
+ // TODO(dual_funding): Combine this match arm with above.
8487
+ #[cfg(dual_funding)]
8488
+ ChannelPhase::UnfundedOutboundV2(_) | ChannelPhase::UnfundedInboundV2(_) => true,
8440
8489
ChannelPhase::Funded(channel) => {
8441
8490
let res = f(channel);
8442
8491
if let Ok((channel_ready_opt, mut timed_out_pending_htlcs, announcement_sigs)) = res {
@@ -8904,6 +8953,14 @@ where
8904
8953
ChannelPhase::UnfundedInboundV1(chan) => {
8905
8954
&mut chan.context
8906
8955
},
8956
+ #[cfg(dual_funding)]
8957
+ ChannelPhase::UnfundedOutboundV2(chan) => {
8958
+ &mut chan.context
8959
+ },
8960
+ #[cfg(dual_funding)]
8961
+ ChannelPhase::UnfundedInboundV2(chan) => {
8962
+ &mut chan.context
8963
+ },
8907
8964
};
8908
8965
// Clean up for removal.
8909
8966
update_maps_on_chan_removal!(self, &context);
0 commit comments