@@ -2744,19 +2744,32 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
27442744 // Treat the sweep as urgent as long as there is at least one HTLC which is pending on a
27452745 // valid commitment transaction.
27462746 if !self . current_holder_commitment_tx . htlc_outputs . is_empty ( ) {
2747- return ConfirmationTarget :: UrgentOnChainSweep ;
2747+ let minimum_expiry = self . current_holder_commitment_tx . htlc_outputs
2748+ . iter ( )
2749+ . map ( |o| o. 0 . cltv_expiry )
2750+ . min ( ) ;
2751+ return ConfirmationTarget :: UrgentOnChainSweep ( minimum_expiry) ;
27482752 }
27492753 if self . prev_holder_signed_commitment_tx . as_ref ( ) . map ( |t| !t. htlc_outputs . is_empty ( ) ) . unwrap_or ( false ) {
2750- return ConfirmationTarget :: UrgentOnChainSweep ;
2754+ let minimum_expiry = self . prev_holder_signed_commitment_tx . as_ref ( ) . map ( |t| t. htlc_outputs
2755+ . iter ( )
2756+ . map ( |o| o. 0 . cltv_expiry )
2757+ . min ( )
2758+ ) . flatten ( ) ;
2759+ return ConfirmationTarget :: UrgentOnChainSweep ( minimum_expiry) ;
27512760 }
27522761 if let Some ( txid) = self . current_counterparty_commitment_txid {
2753- if !self . counterparty_claimable_outpoints . get ( & txid) . unwrap ( ) . is_empty ( ) {
2754- return ConfirmationTarget :: UrgentOnChainSweep ;
2762+ let claimable_outpoints = self . counterparty_claimable_outpoints . get ( & txid) . unwrap ( ) ;
2763+ if !claimable_outpoints. is_empty ( ) {
2764+ let minimum_expiry = claimable_outpoints. iter ( ) . map ( |o|o. 0 . cltv_expiry ) . min ( ) ;
2765+ return ConfirmationTarget :: UrgentOnChainSweep ( minimum_expiry) ;
27552766 }
27562767 }
27572768 if let Some ( txid) = self . prev_counterparty_commitment_txid {
2758- if !self . counterparty_claimable_outpoints . get ( & txid) . unwrap ( ) . is_empty ( ) {
2759- return ConfirmationTarget :: UrgentOnChainSweep ;
2769+ let claimable_outpoints = self . counterparty_claimable_outpoints . get ( & txid) . unwrap ( ) ;
2770+ if !claimable_outpoints. is_empty ( ) {
2771+ let minimum_expiry = claimable_outpoints. iter ( ) . map ( |o|o. 0 . cltv_expiry ) . min ( ) ;
2772+ return ConfirmationTarget :: UrgentOnChainSweep ( minimum_expiry) ;
27602773 }
27612774 }
27622775 ConfirmationTarget :: OutputSpendingFee
0 commit comments