@@ -5481,7 +5481,7 @@ where
5481
5481
self.get_initial_counterparty_commitment_signature(funding, logger)
5482
5482
}
5483
5483
5484
- fn check_funding_meets_minimum_depth(&self, funding: &mut FundingScope, height: u32) -> bool {
5484
+ fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
5485
5485
let minimum_depth = funding.minimum_depth_override.or(self.minimum_depth);
5486
5486
5487
5487
if funding.funding_tx_confirmation_height == 0 && minimum_depth != Some(0) {
@@ -5490,10 +5490,6 @@ where
5490
5490
5491
5491
let funding_tx_confirmations =
5492
5492
height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
5493
- if funding_tx_confirmations <= 0 {
5494
- funding.funding_tx_confirmation_height = 0;
5495
- }
5496
-
5497
5493
if funding_tx_confirmations < minimum_depth.unwrap_or(0) as i64 {
5498
5494
return false;
5499
5495
}
@@ -8814,7 +8810,7 @@ where
8814
8810
// Called:
8815
8811
// * always when a new block/transactions are confirmed with the new height
8816
8812
// * when funding is signed with a height of 0
8817
- if !self.context.check_funding_meets_minimum_depth(&mut self.funding, height) {
8813
+ if !self.context.check_funding_meets_minimum_depth(&self.funding, height) {
8818
8814
return None;
8819
8815
}
8820
8816
@@ -9022,6 +9018,12 @@ where
9022
9018
9023
9019
self.context.update_time_counter = cmp::max(self.context.update_time_counter, highest_header_time);
9024
9020
9021
+ // Check if the funding transaction was unconfirmed
9022
+ let funding_tx_confirmations = self.funding.get_funding_tx_confirmations(height);
9023
+ if funding_tx_confirmations == 0 {
9024
+ self.funding.funding_tx_confirmation_height = 0;
9025
+ }
9026
+
9025
9027
if let Some(channel_ready) = self.check_get_channel_ready(height, logger) {
9026
9028
let announcement_sigs = if let Some((chain_hash, node_signer, user_config)) = chain_node_signer {
9027
9029
self.get_announcement_sigs(node_signer, chain_hash, user_config, height, logger)
@@ -9032,13 +9034,6 @@ where
9032
9034
9033
9035
if matches!(self.context.channel_state, ChannelState::ChannelReady(_)) ||
9034
9036
self.context.channel_state.is_our_channel_ready() {
9035
- let mut funding_tx_confirmations = height as i64 - self.funding.funding_tx_confirmation_height as i64 + 1;
9036
- if self.funding.funding_tx_confirmation_height == 0 {
9037
- // Note that check_get_channel_ready may reset funding_tx_confirmation_height to
9038
- // zero if it has been reorged out, however in either case, our state flags
9039
- // indicate we've already sent a channel_ready
9040
- funding_tx_confirmations = 0;
9041
- }
9042
9037
9043
9038
// If we've sent channel_ready (or have both sent and received channel_ready), and
9044
9039
// the funding transaction has become unconfirmed,
@@ -9082,6 +9077,7 @@ where
9082
9077
// larger. If we don't know that time has moved forward, we can just set it to the last
9083
9078
// time we saw and it will be ignored.
9084
9079
let best_time = self.context.update_time_counter;
9080
+
9085
9081
match self.do_best_block_updated(reorg_height, best_time, None::<(ChainHash, &&dyn NodeSigner, &UserConfig)>, logger) {
9086
9082
Ok((channel_ready, timed_out_htlcs, announcement_sigs)) => {
9087
9083
assert!(channel_ready.is_none(), "We can't generate a funding with 0 confirmations?");
0 commit comments