Skip to content

Commit 475719d

Browse files
TheBlueMattAntoine Riard
authored andcommitted
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 9eb8780 commit 475719d

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
@@ -2418,10 +2418,15 @@ impl ChannelMonitor {
24182418
// before we could anyway), wait for ANTI_REORG_DELAY and clean the RBF
24192419
// tracking map.
24202420
if set_equality {
2421+
let new_event = OnchainEvent::Claim { claim_request: ancestor_claimable_txid.0.clone() };
24212422
match self.onchain_events_waiting_threshold_conf.entry(height + ANTI_REORG_DELAY - 1) {
2422-
hash_map::Entry::Occupied(_) => {},
2423+
hash_map::Entry::Occupied(mut entry) => {
2424+
if !entry.get().contains(&new_event) {
2425+
entry.get_mut().push(new_event);
2426+
}
2427+
},
24232428
hash_map::Entry::Vacant(entry) => {
2424-
entry.insert(vec![OnchainEvent::Claim { claim_request: ancestor_claimable_txid.0.clone()}]);
2429+
entry.insert(vec![new_event]);
24252430
}
24262431
}
24272432
} else { // If false, generate new claim request with update outpoint set
@@ -2440,10 +2445,15 @@ impl ChannelMonitor {
24402445
}
24412446
}
24422447
for (outpoint, input_material) in claimed_outputs_material.drain(..) {
2448+
let new_event = OnchainEvent::ContentiousOutpoint { outpoint, input_material };
24432449
match self.onchain_events_waiting_threshold_conf.entry(height + ANTI_REORG_DELAY - 1) {
2444-
hash_map::Entry::Occupied(_) => {},
2450+
hash_map::Entry::Occupied(mut entry) => {
2451+
if !entry.get().contains(&new_event) {
2452+
entry.get_mut().push(new_event);
2453+
}
2454+
},
24452455
hash_map::Entry::Vacant(entry) => {
2446-
entry.insert(vec![OnchainEvent::ContentiousOutpoint { outpoint, input_material }]);
2456+
entry.insert(vec![new_event]);
24472457
}
24482458
}
24492459
}

0 commit comments

Comments
 (0)