Skip to content

Commit 0dfe611

Browse files
committed
If 2 claimable-outpoint-spending txn are in 1 block, clean up properly
This resolves an issue where we will never track 2 on-chain events which are waiting for ANTI_REORG_DELAY at the same height. This partially reverts and fixes "Move our_claim_txn_waiting_first_conf to pending_claim_requests".
1 parent 1ed0638 commit 0dfe611

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

lightning/src/ln/channelmonitor.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,10 +2417,15 @@ impl ChannelMonitor {
24172417
// before we could anyway), wait for ANTI_REORG_DELAY and clean the RBF
24182418
// tracking map.
24192419
if set_equality {
2420+
let new_event = OnchainEvent::Claim { claim_request: ancestor_claimable_txid.0.clone() };
24202421
match self.onchain_events_waiting_threshold_conf.entry(height + ANTI_REORG_DELAY - 1) {
2421-
hash_map::Entry::Occupied(_) => {},
2422+
hash_map::Entry::Occupied(mut entry) => {
2423+
if !entry.get().contains(&new_event) {
2424+
entry.get_mut().push(new_event);
2425+
}
2426+
},
24222427
hash_map::Entry::Vacant(entry) => {
2423-
entry.insert(vec![OnchainEvent::Claim { claim_request: ancestor_claimable_txid.0.clone()}]);
2428+
entry.insert(vec![new_event]);
24242429
}
24252430
}
24262431
} else { // If false, generate new claim request with update outpoint set
@@ -2439,10 +2444,15 @@ impl ChannelMonitor {
24392444
}
24402445
}
24412446
for (outpoint, input_material) in claimed_outputs_material.drain(..) {
2447+
let new_event = OnchainEvent::ContentiousOutpoint { outpoint, input_material };
24422448
match self.onchain_events_waiting_threshold_conf.entry(height + ANTI_REORG_DELAY - 1) {
2443-
hash_map::Entry::Occupied(_) => {},
2449+
hash_map::Entry::Occupied(mut entry) => {
2450+
if !entry.get().contains(&new_event) {
2451+
entry.get_mut().push(new_event);
2452+
}
2453+
},
24442454
hash_map::Entry::Vacant(entry) => {
2445-
entry.insert(vec![OnchainEvent::ContentiousOutpoint { outpoint, input_material }]);
2455+
entry.insert(vec![new_event]);
24462456
}
24472457
}
24482458
}

0 commit comments

Comments
 (0)