Clean up claimable_outpoints when pending_claim_requests is cleaned
authorMatt Corallo <git@bluematt.me>
Tue, 10 Dec 2019 03:51:36 +0000 (22:51 -0500)
committerAntoine Riard <ariard@student.42.fr>
Tue, 10 Dec 2019 22:42:58 +0000 (17:42 -0500)
When claimable_outpoints was introduced in "Move
our_claim_txn_waiting_first_conf to pending_claim_requests", removal
of elements from it (which are just pointers into
pending_claim_requests) was never added.

lightning/src/ln/channelmonitor.rs

index 72f11fe25f241406ae4d2a2bc12314ea01f293a8..4b2e0e65e11375b55d2eae068103a31e711f94fd 100644 (file)
@@ -2492,8 +2492,13 @@ impl ChannelMonitor {
                        for ev in events {
                                match ev {
                                        OnchainEvent::Claim { claim_request } => {
-                                               // We may remove a whole set of claim outpoints here, as these one may have been aggregated in a single tx and claimed so atomically
-                                               self.pending_claim_requests.remove(&claim_request);
+                                               // We may remove a whole set of claim outpoints here, as these one may have
+                                               // been aggregated in a single tx and claimed so atomically
+                                               if let Some(bump_material) = self.pending_claim_requests.remove(&claim_request) {
+                                                       for outpoint in bump_material.per_input_material.keys() {
+                                                               self.claimable_outpoints.remove(&outpoint);
+                                                       }
+                                               }
                                        },
                                        OnchainEvent::HTLCUpdate { htlc_update } => {
                                                log_trace!(self, "HTLC {} failure update has got enough confirmations to be passed upstream", log_bytes!((htlc_update.1).0));