@@ -2414,26 +2414,36 @@ impl ChannelMonitor {
2414
2414
}
2415
2415
}
2416
2416
2417
- // If this is our transaction (or our counterparty spent all the outputs
2418
- // before we could anyway), wait for ANTI_REORG_DELAY and clean the RBF
2419
- // tracking map.
2420
- if set_equality {
2421
- let new_event = OnchainEvent :: Claim { claim_request : ancestor_claimable_txid. 0 . clone ( ) } ;
2422
- match self . onchain_events_waiting_threshold_conf . entry ( height + ANTI_REORG_DELAY - 1 ) {
2423
- hash_map:: Entry :: Occupied ( mut entry) => {
2424
- if !entry. get ( ) . contains ( & new_event) {
2425
- entry. get_mut ( ) . push ( new_event) ;
2417
+ macro_rules! clean_claim_request_after_safety_delay {
2418
+ ( ) => {
2419
+ let new_event = OnchainEvent :: Claim { claim_request: ancestor_claimable_txid. 0 . clone( ) } ;
2420
+ match self . onchain_events_waiting_threshold_conf. entry( height + ANTI_REORG_DELAY - 1 ) {
2421
+ hash_map:: Entry :: Occupied ( mut entry) => {
2422
+ if !entry. get( ) . contains( & new_event) {
2423
+ entry. get_mut( ) . push( new_event) ;
2424
+ }
2425
+ } ,
2426
+ hash_map:: Entry :: Vacant ( entry) => {
2427
+ entry. insert( vec![ new_event] ) ;
2426
2428
}
2427
- } ,
2428
- hash_map:: Entry :: Vacant ( entry) => {
2429
- entry. insert ( vec ! [ new_event] ) ;
2430
2429
}
2431
2430
}
2431
+ }
2432
+
2433
+ // If this is our transaction (or our counterparty spent all the outputs
2434
+ // before we could anyway with same inputs order than us), wait for
2435
+ // ANTI_REORG_DELAY and clean the RBF tracking map.
2436
+ if set_equality {
2437
+ clean_claim_request_after_safety_delay ! ( ) ;
2432
2438
} else { // If false, generate new claim request with update outpoint set
2433
2439
for input in tx. input . iter ( ) {
2434
2440
if let Some ( input_material) = claim_material. per_input_material . remove ( & input. previous_output ) {
2435
2441
claimed_outputs_material. push ( ( input. previous_output , input_material) ) ;
2436
2442
}
2443
+ // If there are no outpoints left to claim in this request, drop it entirely after ANTI_REORG_DELAY.
2444
+ if claim_material. per_input_material . is_empty ( ) {
2445
+ clean_claim_request_after_safety_delay ! ( ) ;
2446
+ }
2437
2447
}
2438
2448
//TODO: recompute soonest_timelock to avoid wasting a bit on fees
2439
2449
bump_candidates. insert ( ancestor_claimable_txid. 0 . clone ( ) , claim_material. clone ( ) ) ;
0 commit comments