]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Use current height when generating claims on block_disconnected
authorWilmer Paulino <wilmer@wilmerpaulino.com>
Fri, 21 Apr 2023 22:54:03 +0000 (15:54 -0700)
committerWilmer Paulino <wilmer@wilmerpaulino.com>
Sat, 22 Apr 2023 18:16:28 +0000 (11:16 -0700)
The `height` argument passed to `OnchainTxHandler::block_disconnected`
represents the height being disconnected, and not the current height.
Due to the incorrect assumption, we'd generate a claim with a locktime
in the future.

Ultimately, we shouldn't be generating claims within
`block_disconnected`. Rather, we should retry the claim at a later block
height, since the bitcoin blockchain does not ever roll back without
connecting a new block. Addressing this is left for future work.

lightning/src/chain/onchaintx.rs

index 04776fbb0899038e1aef56ff2cf12361d7649c2c..9141efc0b3d2c054fe886f05c3789c9817e48301 100644 (file)
@@ -1036,8 +1036,10 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
                        }
                }
                for ((_package_id, _), ref mut request) in bump_candidates.iter_mut() {
+                       // `height` is the height being disconnected, so our `current_height` is 1 lower.
+                       let current_height = height - 1;
                        if let Some((new_timer, new_feerate, bump_claim)) = self.generate_claim(
-                               height, &request, true /* force_feerate_bump */, fee_estimator, &&*logger
+                               current_height, &request, true /* force_feerate_bump */, fee_estimator, &&*logger
                        ) {
                                request.set_timer(new_timer);
                                request.set_feerate(new_feerate);