@@ -4866,7 +4866,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4866
4866
self . onchain_events_awaiting_threshold_conf . retain ( |ref entry| entry. height <= height) ;
4867
4867
let conf_target = self . closure_conf_target ( ) ;
4868
4868
self . onchain_tx_handler . block_disconnected (
4869
- height + 1 , broadcaster, conf_target, & self . destination_script , fee_estimator, logger,
4869
+ height + 1 , & broadcaster, conf_target, & self . destination_script , fee_estimator, logger,
4870
4870
) ;
4871
4871
Vec :: new ( )
4872
4872
} else { Vec :: new ( ) }
@@ -5341,26 +5341,34 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5341
5341
self . onchain_events_awaiting_threshold_conf . retain ( |ref entry| entry. height < height) ;
5342
5342
5343
5343
// TODO: Replace with `take_if` once our MSRV is >= 1.80.
5344
+ let mut should_broadcast_commitment = false ;
5344
5345
if let Some ( ( _, conf_height) ) = self . alternative_funding_confirmed . as_ref ( ) {
5345
5346
if * conf_height == height {
5346
5347
self . alternative_funding_confirmed . take ( ) ;
5347
- if self . holder_tx_signed {
5348
+ if self . holder_tx_signed || self . funding_spend_seen {
5348
5349
// Cancel any previous claims that are no longer valid as they stemmed from a
5349
- // different funding transaction. We'll wait until we see a funding transaction
5350
- // confirm again before attempting to broadcast the new valid holder commitment.
5350
+ // different funding transaction.
5351
5351
let new_holder_commitment_txid =
5352
5352
self . funding . current_holder_commitment_tx . trust ( ) . txid ( ) ;
5353
5353
self . cancel_prev_commitment_claims ( & logger, & new_holder_commitment_txid) ;
5354
+
5355
+ should_broadcast_commitment = true ;
5354
5356
}
5355
5357
}
5356
5358
}
5357
5359
5358
5360
let bounded_fee_estimator = LowerBoundedFeeEstimator :: new ( fee_estimator) ;
5359
5361
let conf_target = self . closure_conf_target ( ) ;
5360
5362
self . onchain_tx_handler . block_disconnected (
5361
- height, broadcaster, conf_target, & self . destination_script , & bounded_fee_estimator, logger
5363
+ height, & broadcaster, conf_target, & self . destination_script , & bounded_fee_estimator, logger
5362
5364
) ;
5363
5365
5366
+ // Only attempt to broadcast the new commitment after the `block_disconnected` call above so that
5367
+ // it doesn't get removed from the set of pending claims.
5368
+ if should_broadcast_commitment {
5369
+ self . queue_latest_holder_commitment_txn_for_broadcast ( & broadcaster, & bounded_fee_estimator, logger) ;
5370
+ }
5371
+
5364
5372
self . best_block = BestBlock :: new ( header. prev_blockhash , height - 1 ) ;
5365
5373
}
5366
5374
@@ -5395,24 +5403,32 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5395
5403
debug_assert ! ( !self . onchain_events_awaiting_threshold_conf. iter( ) . any( |ref entry| entry. txid == * txid) ) ;
5396
5404
5397
5405
// TODO: Replace with `take_if` once our MSRV is >= 1.80.
5406
+ let mut should_broadcast_commitment = false ;
5398
5407
if let Some ( ( alternative_funding_txid, _) ) = self . alternative_funding_confirmed . as_ref ( ) {
5399
5408
if alternative_funding_txid == txid {
5400
5409
self . alternative_funding_confirmed . take ( ) ;
5401
- if self . holder_tx_signed {
5410
+ if self . holder_tx_signed || self . funding_spend_seen {
5402
5411
// Cancel any previous claims that are no longer valid as they stemmed from a
5403
- // different funding transaction. We'll wait until we see a funding transaction
5404
- // confirm again before attempting to broadcast the new valid holder commitment.
5412
+ // different funding transaction.
5405
5413
let new_holder_commitment_txid =
5406
5414
self . funding . current_holder_commitment_tx . trust ( ) . txid ( ) ;
5407
5415
self . cancel_prev_commitment_claims ( & logger, & new_holder_commitment_txid) ;
5416
+
5417
+ should_broadcast_commitment = true ;
5408
5418
}
5409
5419
}
5410
5420
}
5411
5421
5412
5422
let conf_target = self . closure_conf_target ( ) ;
5413
5423
self . onchain_tx_handler . transaction_unconfirmed (
5414
- txid, broadcaster, conf_target, & self . destination_script , fee_estimator, logger
5424
+ txid, & broadcaster, conf_target, & self . destination_script , fee_estimator, logger
5415
5425
) ;
5426
+
5427
+ // Only attempt to broadcast the new commitment after the `transaction_unconfirmed` call above so
5428
+ // that it doesn't get removed from the set of pending claims.
5429
+ if should_broadcast_commitment {
5430
+ self . queue_latest_holder_commitment_txn_for_broadcast ( & broadcaster, fee_estimator, logger) ;
5431
+ }
5416
5432
}
5417
5433
5418
5434
/// Filters a block's `txdata` for transactions spending watched outputs or for any child
0 commit comments