@@ -1127,15 +1127,15 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
11271127 }
11281128
11291129 if let Some ( height) = height {
1130- self . block_disconnected (
1131- height, broadcaster, conf_target, destination_script, fee_estimator, logger,
1130+ self . blocks_disconnected (
1131+ height - 1 , broadcaster, conf_target, destination_script, fee_estimator, logger,
11321132 ) ;
11331133 }
11341134 }
11351135
11361136 #[ rustfmt:: skip]
1137- pub ( super ) fn block_disconnected < B : Deref , F : Deref , L : Logger > (
1138- & mut self , height : u32 , broadcaster : B , conf_target : ConfirmationTarget ,
1137+ pub ( super ) fn blocks_disconnected < B : Deref , F : Deref , L : Logger > (
1138+ & mut self , new_best_height : u32 , broadcaster : B , conf_target : ConfirmationTarget ,
11391139 destination_script : & Script , fee_estimator : & LowerBoundedFeeEstimator < F > , logger : & L ,
11401140 )
11411141 where B :: Target : BroadcasterInterface ,
@@ -1145,21 +1145,21 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
11451145 let onchain_events_awaiting_threshold_conf =
11461146 self . onchain_events_awaiting_threshold_conf . drain ( ..) . collect :: < Vec < _ > > ( ) ;
11471147 for entry in onchain_events_awaiting_threshold_conf {
1148- if entry. height >= height {
1148+ if entry. height > new_best_height {
11491149 //- our claim tx on a commitment tx output
11501150 //- resurect outpoint back in its claimable set and regenerate tx
11511151 match entry. event {
11521152 OnchainEvent :: ContentiousOutpoint { package } => {
11531153 // We pass 0 to `package_locktime` to get the actual required locktime.
11541154 let package_locktime = package. package_locktime ( 0 ) ;
1155- if package_locktime >= height {
1155+ if package_locktime > new_best_height {
11561156 self . locktimed_packages . entry ( package_locktime) . or_default ( ) . push ( package) ;
11571157 continue ;
11581158 }
11591159
11601160 if let Some ( pending_claim) = self . claimable_outpoints . get ( package. outpoints ( ) [ 0 ] ) {
11611161 if let Some ( request) = self . pending_claim_requests . get_mut ( & pending_claim. 0 ) {
1162- assert ! ( request. merge_package( package, height ) . is_ok( ) ) ;
1162+ assert ! ( request. merge_package( package, new_best_height + 1 ) . is_ok( ) ) ;
11631163 // Using a HashMap guarantee us than if we have multiple outpoints getting
11641164 // resurrected only one bump claim tx is going to be broadcast
11651165 bump_candidates. insert ( pending_claim. clone ( ) , request. clone ( ) ) ;
@@ -1173,10 +1173,8 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
11731173 }
11741174 }
11751175 for ( ( _claim_id, _) , ref mut request) in bump_candidates. iter_mut ( ) {
1176- // `height` is the height being disconnected, so our `current_height` is 1 lower.
1177- let current_height = height - 1 ;
11781176 if let Some ( ( new_timer, new_feerate, bump_claim) ) = self . generate_claim (
1179- current_height , & request, & FeerateStrategy :: ForceBump , conf_target,
1177+ new_best_height , & request, & FeerateStrategy :: ForceBump , conf_target,
11801178 destination_script, fee_estimator, logger
11811179 ) {
11821180 request. set_timer ( new_timer) ;
@@ -1210,9 +1208,9 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
12101208 // right now if one of the outpoint get disconnected, just erase whole pending claim request.
12111209 let mut remove_request = Vec :: new ( ) ;
12121210 self . claimable_outpoints . retain ( |_, ref v|
1213- if v. 1 >= height {
1214- remove_request. push ( v. 0 . clone ( ) ) ;
1215- false
1211+ if v. 1 > new_best_height {
1212+ remove_request. push ( v. 0 . clone ( ) ) ;
1213+ false
12161214 } else { true } ) ;
12171215 for req in remove_request {
12181216 self . pending_claim_requests . remove ( & req) ;
0 commit comments