Change return value of `claim_funds` to ignore duplicate claims 2021-07-forward-event
authorMatt Corallo <git@bluematt.me>
Tue, 3 Aug 2021 16:49:31 +0000 (16:49 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 4 Aug 2021 21:48:21 +0000 (21:48 +0000)
While we should never reach `ClaimFundsFromHop::DuplicateClaim` in
most cases, if we do, it likely indicates the HTLC was timed out
some time ago and is no longer available to be claimed. Thus, it
does not make sense to imply that we `claimed_any_htlcs`.

lightning/src/ln/channelmanager.rs

index 888724c0f064a82f885203ef0f7a0d76b7f885e8..ad9a7e2955494cd53a95a63542a22d42539c7cc7 100644 (file)
@@ -2804,7 +2804,13 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
                                                        } else { errs.push((pk, err)); }
                                                },
                                                ClaimFundsFromHop::PrevHopForceClosed => unreachable!("We already checked for channel existence, we can't fail here!"),
-                                               _ => claimed_any_htlcs = true,
+                                               ClaimFundsFromHop::DuplicateClaim => {
+                                                       // While we should never get here in most cases, if we do, it likely
+                                                       // indicates that the HTLC was timed out some time ago and is no longer
+                                                       // available to be claimed. Thus, it does not make sense to set
+                                                       // `claimed_any_htlcs`.
+                                               },
+                                               ClaimFundsFromHop::Success(_) => claimed_any_htlcs = true,
                                        }
                                }
                        }