@@ -1138,15 +1138,15 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
11381138 }
11391139
11401140 if let Some ( height) = height {
1141- self . block_disconnected (
1142- height, broadcaster, conf_target, destination_script, fee_estimator, logger,
1141+ self . blocks_disconnected (
1142+ height - 1 , broadcaster, conf_target, destination_script, fee_estimator, logger,
11431143 ) ;
11441144 }
11451145 }
11461146
11471147 #[ rustfmt:: skip]
1148- pub ( super ) fn block_disconnected < B : Deref , F : Deref , L : Logger > (
1149- & mut self , height : u32 , broadcaster : B , conf_target : ConfirmationTarget ,
1148+ pub ( super ) fn blocks_disconnected < B : Deref , F : Deref , L : Logger > (
1149+ & mut self , new_best_height : u32 , broadcaster : B , conf_target : ConfirmationTarget ,
11501150 destination_script : & Script , fee_estimator : & LowerBoundedFeeEstimator < F > , logger : & L ,
11511151 )
11521152 where B :: Target : BroadcasterInterface ,
@@ -1156,21 +1156,21 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
11561156 let onchain_events_awaiting_threshold_conf =
11571157 self . onchain_events_awaiting_threshold_conf . drain ( ..) . collect :: < Vec < _ > > ( ) ;
11581158 for entry in onchain_events_awaiting_threshold_conf {
1159- if entry. height >= height {
1159+ if entry. height > new_best_height {
11601160 //- our claim tx on a commitment tx output
11611161 //- resurect outpoint back in its claimable set and regenerate tx
11621162 match entry. event {
11631163 OnchainEvent :: ContentiousOutpoint { package } => {
11641164 // We pass 0 to `package_locktime` to get the actual required locktime.
11651165 let package_locktime = package. package_locktime ( 0 ) ;
1166- if package_locktime >= height {
1166+ if package_locktime > new_best_height {
11671167 self . locktimed_packages . entry ( package_locktime) . or_default ( ) . push ( package) ;
11681168 continue ;
11691169 }
11701170
11711171 if let Some ( pending_claim) = self . claimable_outpoints . get ( package. outpoints ( ) [ 0 ] ) {
11721172 if let Some ( request) = self . pending_claim_requests . get_mut ( & pending_claim. 0 ) {
1173- assert ! ( request. merge_package( package, height ) . is_ok( ) ) ;
1173+ assert ! ( request. merge_package( package, new_best_height + 1 ) . is_ok( ) ) ;
11741174 // Using a HashMap guarantee us than if we have multiple outpoints getting
11751175 // resurrected only one bump claim tx is going to be broadcast
11761176 bump_candidates. insert ( pending_claim. clone ( ) , request. clone ( ) ) ;
@@ -1184,10 +1184,8 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
11841184 }
11851185 }
11861186 for ( ( _claim_id, _) , ref mut request) in bump_candidates. iter_mut ( ) {
1187- // `height` is the height being disconnected, so our `current_height` is 1 lower.
1188- let current_height = height - 1 ;
11891187 if let Some ( ( new_timer, new_feerate, bump_claim) ) = self . generate_claim (
1190- current_height , & request, & FeerateStrategy :: ForceBump , conf_target,
1188+ new_best_height , & request, & FeerateStrategy :: ForceBump , conf_target,
11911189 destination_script, fee_estimator, logger
11921190 ) {
11931191 request. set_timer ( new_timer) ;
@@ -1221,9 +1219,9 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
12211219 // right now if one of the outpoint get disconnected, just erase whole pending claim request.
12221220 let mut remove_request = Vec :: new ( ) ;
12231221 self . claimable_outpoints . retain ( |_, ref v|
1224- if v. 1 >= height {
1225- remove_request. push ( v. 0 . clone ( ) ) ;
1226- false
1222+ if v. 1 > new_best_height {
1223+ remove_request. push ( v. 0 . clone ( ) ) ;
1224+ false
12271225 } else { true } ) ;
12281226 for req in remove_request {
12291227 self . pending_claim_requests . remove ( & req) ;
0 commit comments