]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Rename claim cleaning match bool for accuracy
authorMatt Corallo <git@bluematt.me>
Thu, 5 Sep 2024 21:06:16 +0000 (21:06 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 16 Oct 2024 21:04:48 +0000 (21:04 +0000)
We don't actually care if a confirmed transaction claimed other
outputs, only that it claimed a superset of the outputs in the
pending claim we're looking at. Thus, the variable to detect that
is renamed `is_claim_subset_of_tx` instead of `are_sets_equal`.

lightning/src/chain/onchaintx.rs

index 7ac8f9a63f6009ce624e4b400b243ebf7d225cf7..e1f3ebf049bf2f376fe59bb11a4db9e297fe4454 100644 (file)
@@ -885,15 +885,16 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
                                if let Some((claim_id, _)) = self.claimable_outpoints.get(&inp.previous_output) {
                                        // If outpoint has claim request pending on it...
                                        if let Some(request) = self.pending_claim_requests.get_mut(claim_id) {
-                                               //... we need to verify equality between transaction outpoints and claim request
-                                               // outpoints to know if transaction is the original claim or a bumped one issued
-                                               // by us.
-                                               let mut are_sets_equal = true;
+                                               //... we need to check if the pending claim was for a subset of the outputs
+                                               // spent by the confirmed transaction. If so, we can drop the pending claim
+                                               // after ANTI_REORG_DELAY blocks, otherwise we need to split it and retry
+                                               // claiming the remaining outputs.
+                                               let mut is_claim_subset_of_tx = true;
                                                let mut tx_inputs = tx.input.iter().map(|input| &input.previous_output).collect::<Vec<_>>();
                                                tx_inputs.sort_unstable();
                                                for request_input in request.outpoints() {
                                                        if tx_inputs.binary_search(&request_input).is_err() {
-                                                               are_sets_equal = false;
+                                                               is_claim_subset_of_tx = false;
                                                                break;
                                                        }
                                                }
@@ -915,7 +916,7 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
                                                // If this is our transaction (or our counterparty spent all the outputs
                                                // before we could anyway with same inputs order than us), wait for
                                                // ANTI_REORG_DELAY and clean the RBF tracking map.
-                                               if are_sets_equal {
+                                               if is_claim_subset_of_tx {
                                                        clean_claim_request_after_safety_delay!();
                                                } else { // If false, generate new claim request with update outpoint set
                                                        let mut at_least_one_drop = false;