fix: check node-tx timelock exhaustion when refund-tx is healthy in checkRenewLeaves - #131
Open
vwinee21 wants to merge 3 commits into
Open
Conversation
Replace fragile prefix matching with proper btcutil.DecodeAddress validation which includes checksum verification. Resolves TODO in IsBitcoinAddressForNetwork.
Pending coop exits with ConfirmationHeightIsNil() can accumulate indefinitely if the L1 transaction is never confirmed (e.g. evicted from mempool due to low fee or replaced via RBF). Add expiry logic that runs each block cycle and deletes pending coop exits older than KnobWatchChainCoopExitPendingExpiryDays (default: 14 days). The 14-day default matches Bitcoin Core's DEFAULT_MEMPOOL_EXPIRY so entries are cleaned up around the time Bitcoin Core would drop them. Expiry count is logged at Info level when non-zero for observability. The threshold is runtime-configurable via the knob system without a code deploy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #127
checkRenewLeavesgates the entire renewal classification on the refund-tx sequence. WhenrefundSequencedoes not need renewal, the node is immediately pushed tovalidNodes— without ever checking whethernodeSequencehas decayed to ≤TimeLockInterval.Result: a leaf whose node-tx timelock is exhausted but whose refund-tx timelock is still healthy is classified as
Validand selected for transfers. The SSP then attempts to construct the next CPFP refund andValidateSequencerejects with:The leaf is structurally unspendable but
checkRenewLeavesreturns0renewals on every preflight — no ceremony attempted, no warn logs, leaf stays stuck indefinitely.Fix
In the
elsebranch (refund-tx healthy), add an explicit check for node-tx exhaustion before classifying the node as valid:This mirrors the existing logic inside the
if (doesTxnNeedRenewed(refundSequence))branch and ensures node-tx exhaustion is caught regardless of refund-tx health.