@@ -5469,7 +5469,7 @@ where
5469
5469
self.get_initial_counterparty_commitment_signature(funding, logger)
5470
5470
}
5471
5471
5472
- fn check_funding_meets_minimum_depth(&self, funding: &mut FundingScope, height: u32) -> bool {
5472
+ fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
5473
5473
let minimum_depth = funding.minimum_depth_override.or(self.minimum_depth);
5474
5474
5475
5475
if funding.funding_tx_confirmation_height == 0 && minimum_depth != Some(0) {
@@ -5478,10 +5478,6 @@ where
5478
5478
5479
5479
let funding_tx_confirmations =
5480
5480
height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
5481
- if funding_tx_confirmations <= 0 {
5482
- funding.funding_tx_confirmation_height = 0;
5483
- }
5484
-
5485
5481
if funding_tx_confirmations < minimum_depth.unwrap_or(0) as i64 {
5486
5482
return false;
5487
5483
}
@@ -8770,7 +8766,7 @@ where
8770
8766
// Called:
8771
8767
// * always when a new block/transactions are confirmed with the new height
8772
8768
// * when funding is signed with a height of 0
8773
- if !self.context.check_funding_meets_minimum_depth(&mut self.funding, height) {
8769
+ if !self.context.check_funding_meets_minimum_depth(&self.funding, height) {
8774
8770
return None;
8775
8771
}
8776
8772
@@ -8974,6 +8970,12 @@ where
8974
8970
8975
8971
self.context.update_time_counter = cmp::max(self.context.update_time_counter, highest_header_time);
8976
8972
8973
+ // Check if the funding transaction was unconfirmed
8974
+ let funding_tx_confirmations = self.funding.get_funding_tx_confirmations(height);
8975
+ if funding_tx_confirmations == 0 {
8976
+ self.funding.funding_tx_confirmation_height = 0;
8977
+ }
8978
+
8977
8979
if let Some(channel_ready) = self.check_get_channel_ready(height, logger) {
8978
8980
let announcement_sigs = if let Some((chain_hash, node_signer, user_config)) = chain_node_signer {
8979
8981
self.get_announcement_sigs(node_signer, chain_hash, user_config, height, logger)
@@ -8984,13 +8986,6 @@ where
8984
8986
8985
8987
if matches!(self.context.channel_state, ChannelState::ChannelReady(_)) ||
8986
8988
self.context.channel_state.is_our_channel_ready() {
8987
- let mut funding_tx_confirmations = height as i64 - self.funding.funding_tx_confirmation_height as i64 + 1;
8988
- if self.funding.funding_tx_confirmation_height == 0 {
8989
- // Note that check_get_channel_ready may reset funding_tx_confirmation_height to
8990
- // zero if it has been reorged out, however in either case, our state flags
8991
- // indicate we've already sent a channel_ready
8992
- funding_tx_confirmations = 0;
8993
- }
8994
8989
8995
8990
// If we've sent channel_ready (or have both sent and received channel_ready), and
8996
8991
// the funding transaction has become unconfirmed,
@@ -9034,6 +9029,7 @@ where
9034
9029
// larger. If we don't know that time has moved forward, we can just set it to the last
9035
9030
// time we saw and it will be ignored.
9036
9031
let best_time = self.context.update_time_counter;
9032
+
9037
9033
match self.do_best_block_updated(reorg_height, best_time, None::<(ChainHash, &&dyn NodeSigner, &UserConfig)>, logger) {
9038
9034
Ok((channel_ready, timed_out_htlcs, announcement_sigs)) => {
9039
9035
assert!(channel_ready.is_none(), "We can't generate a funding with 0 confirmations?");
0 commit comments