@@ -368,8 +368,7 @@ pub(super) struct Channel<Signer: Sign> {
368
368
/// could miss the funding_tx_confirmed_in block as well, but it serves as a useful fallback.
369
369
funding_tx_confirmed_in : Option < BlockHash > ,
370
370
short_channel_id : Option < u64 > ,
371
- /// Used to deduplicate block_connected callbacks, also used to verify consistency during
372
- /// ChannelManager deserialization (hence pub(super))
371
+ /// Used to verify consistency during ChannelManager deserialization (hence pub(super)).
373
372
pub ( super ) last_block_connected : BlockHash ,
374
373
funding_tx_confirmations : u64 ,
375
374
@@ -3517,12 +3516,12 @@ impl<Signer: Sign> Channel<Signer> {
3517
3516
_ => true
3518
3517
}
3519
3518
} ) ;
3520
- let non_shutdown_state = self . channel_state & ( !MULTI_STATE_FLAGS ) ;
3521
- if header. block_hash ( ) != self . last_block_connected {
3522
- if self . funding_tx_confirmations > 0 {
3523
- self . funding_tx_confirmations += 1 ;
3524
- }
3519
+
3520
+ if self . funding_tx_confirmations > 0 {
3521
+ self . funding_tx_confirmations += 1 ;
3525
3522
}
3523
+
3524
+ let non_shutdown_state = self . channel_state & ( !MULTI_STATE_FLAGS ) ;
3526
3525
if non_shutdown_state & !( ChannelState :: TheirFundingLocked as u32 ) == ChannelState :: FundingSent as u32 {
3527
3526
for & ( index_in_block, tx) in txdata. iter ( ) {
3528
3527
let funding_txo = self . get_funding_txo ( ) . unwrap ( ) ;
@@ -3568,46 +3567,45 @@ impl<Signer: Sign> Channel<Signer> {
3568
3567
}
3569
3568
}
3570
3569
}
3571
- if header. block_hash ( ) != self . last_block_connected {
3572
- self . last_block_connected = header. block_hash ( ) ;
3573
- self . update_time_counter = cmp:: max ( self . update_time_counter , header. time ) ;
3574
- if self . funding_tx_confirmations > 0 {
3575
- if self . funding_tx_confirmations == self . minimum_depth as u64 {
3576
- let need_commitment_update = if non_shutdown_state == ChannelState :: FundingSent as u32 {
3577
- self . channel_state |= ChannelState :: OurFundingLocked as u32 ;
3578
- true
3579
- } else if non_shutdown_state == ( ChannelState :: FundingSent as u32 | ChannelState :: TheirFundingLocked as u32 ) {
3580
- self . channel_state = ChannelState :: ChannelFunded as u32 | ( self . channel_state & MULTI_STATE_FLAGS ) ;
3581
- self . update_time_counter += 1 ;
3582
- true
3583
- } else if non_shutdown_state == ( ChannelState :: FundingSent as u32 | ChannelState :: OurFundingLocked as u32 ) {
3584
- // We got a reorg but not enough to trigger a force close, just update
3585
- // funding_tx_confirmed_in and return.
3586
- false
3587
- } else if self . channel_state < ChannelState :: ChannelFunded as u32 {
3588
- panic ! ( "Started confirming a channel in a state pre-FundingSent?: {}" , self . channel_state) ;
3570
+
3571
+ self . last_block_connected = header. block_hash ( ) ;
3572
+ self . update_time_counter = cmp:: max ( self . update_time_counter , header. time ) ;
3573
+ if self . funding_tx_confirmations > 0 {
3574
+ if self . funding_tx_confirmations == self . minimum_depth as u64 {
3575
+ let need_commitment_update = if non_shutdown_state == ChannelState :: FundingSent as u32 {
3576
+ self . channel_state |= ChannelState :: OurFundingLocked as u32 ;
3577
+ true
3578
+ } else if non_shutdown_state == ( ChannelState :: FundingSent as u32 | ChannelState :: TheirFundingLocked as u32 ) {
3579
+ self . channel_state = ChannelState :: ChannelFunded as u32 | ( self . channel_state & MULTI_STATE_FLAGS ) ;
3580
+ self . update_time_counter += 1 ;
3581
+ true
3582
+ } else if non_shutdown_state == ( ChannelState :: FundingSent as u32 | ChannelState :: OurFundingLocked as u32 ) {
3583
+ // We got a reorg but not enough to trigger a force close, just update
3584
+ // funding_tx_confirmed_in and return.
3585
+ false
3586
+ } else if self . channel_state < ChannelState :: ChannelFunded as u32 {
3587
+ panic ! ( "Started confirming a channel in a state pre-FundingSent?: {}" , self . channel_state) ;
3588
+ } else {
3589
+ // We got a reorg but not enough to trigger a force close, just update
3590
+ // funding_tx_confirmed_in and return.
3591
+ false
3592
+ } ;
3593
+ self . funding_tx_confirmed_in = Some ( self . last_block_connected ) ;
3594
+
3595
+ //TODO: Note that this must be a duplicate of the previous commitment point they sent us,
3596
+ //as otherwise we will have a commitment transaction that they can't revoke (well, kinda,
3597
+ //they can by sending two revoke_and_acks back-to-back, but not really). This appears to be
3598
+ //a protocol oversight, but I assume I'm just missing something.
3599
+ if need_commitment_update {
3600
+ if self . channel_state & ( ChannelState :: MonitorUpdateFailed as u32 ) == 0 {
3601
+ let next_per_commitment_point = self . holder_signer . get_per_commitment_point ( self . cur_holder_commitment_transaction_number , & self . secp_ctx ) ;
3602
+ return Ok ( ( Some ( msgs:: FundingLocked {
3603
+ channel_id : self . channel_id ,
3604
+ next_per_commitment_point,
3605
+ } ) , timed_out_htlcs) ) ;
3589
3606
} else {
3590
- // We got a reorg but not enough to trigger a force close, just update
3591
- // funding_tx_confirmed_in and return.
3592
- false
3593
- } ;
3594
- self . funding_tx_confirmed_in = Some ( self . last_block_connected ) ;
3595
-
3596
- //TODO: Note that this must be a duplicate of the previous commitment point they sent us,
3597
- //as otherwise we will have a commitment transaction that they can't revoke (well, kinda,
3598
- //they can by sending two revoke_and_acks back-to-back, but not really). This appears to be
3599
- //a protocol oversight, but I assume I'm just missing something.
3600
- if need_commitment_update {
3601
- if self . channel_state & ( ChannelState :: MonitorUpdateFailed as u32 ) == 0 {
3602
- let next_per_commitment_point = self . holder_signer . get_per_commitment_point ( self . cur_holder_commitment_transaction_number , & self . secp_ctx ) ;
3603
- return Ok ( ( Some ( msgs:: FundingLocked {
3604
- channel_id : self . channel_id ,
3605
- next_per_commitment_point,
3606
- } ) , timed_out_htlcs) ) ;
3607
- } else {
3608
- self . monitor_pending_funding_locked = true ;
3609
- return Ok ( ( None , timed_out_htlcs) ) ;
3610
- }
3607
+ self . monitor_pending_funding_locked = true ;
3608
+ return Ok ( ( None , timed_out_htlcs) ) ;
3611
3609
}
3612
3610
}
3613
3611
}
0 commit comments