[v0.1.x-branch] Backport #1066: txconfirm: release abandoned fee input on CPFP reselect - #1135
Open
github-actions[bot] wants to merge 1 commit into
Open
[v0.1.x-branch] Backport #1066: txconfirm: release abandoned fee input on CPFP reselect#1135github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
When the precise per-input vsize recompute grows the package fee enough to push the selected fee input's change below the dust limit, broadcastWithCPFP reselects a larger fee input. It had already reserved and wallet-leased the original input, and never released it: the abandoned UTXO stayed locked for the parent's whole lifetime (or until the lease expired) even though the CPFP child only spends the reselected input, needlessly starving other fee selections (#664). Release the abandoned input's reservation and wallet lease when the reselect lands on a different outpoint. The release is skipped for a fee input carried over from a prior committed bump: TRUC package RBF needs the replacement child to double-spend the previous child's fee input, so that input must stay reserved. feeOutpointReserved records the carried- over state before the (idempotent) re-reservation so the two cases are told apart. (cherry picked from commit 8664040)
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.
Backport of #1066
Closes #664.
Problem
In
broadcastWithCPFP, when the precise per-input vsize recompute growsthe package fee enough to push the originally selected fee input's change
below the dust limit, the broadcaster reselects a larger fee input — but
it had already
reserveFeeInput'd (and wallet-LeaseOutput'd) theoriginal before the reselect and never released it. The abandoned UTXO
stays reserved and wallet-leased for the parent's whole lifetime (or until
DefaultFeeInputLeaseExpiry), even though the CPFP child only ever spendsthe reselected input. It's a spurious UTXO lock (not fund loss) that
starves other fee selections.
Fix
Release the abandoned input's reservation + wallet lease
(
releaseFeeOutpoint) when the reselect lands on a different outpoint.The caveat that makes this non-trivial:
selectFeeInputcanlegitimately return a carried-over reservation on a fee bump — TRUC
package RBF requires the replacement child to double-spend the previous
child's fee input, so that input must stay reserved. The release therefore
skips a carried-over input:
feeOutpointReservedrecords whether the inputwas already reserved before the (idempotent) re-reservation, so a
freshly-selected-and-abandoned input is released while a carried-over one
is left intact.
Testing
TestCPFPReselectReleasesAbandonedFeeInputdrives the exact reselect path(a P2PKH fee input heavier than the OP_TRUE change proxy grows the fee and
forces a reselect off the small UTXO) and asserts the abandoned input is
dropped from the in-memory reservation set and its wallet lease is
released, while the reselected input stays reserved. It fails on
mainandpasses with the fix. Full
txconfirmsuite +lint-changed-localgreen.🤖 Generated with Claude Code