fix(afs): require zero locktime for the nSequence path - #87
Merged
evanlinjin merged 1 commit intoAug 21, 2026
Merged
Conversation
evanlinjin
force-pushed
the
fix/afs-sequence-branch-locktime
branch
from
August 20, 2026 08:09
5119b64 to
147a6e7
Compare
The nSequence path exists so the tx resembles an off-chain settlement spending a timelock path, and those carry nLockTime = 0. bitcoindevkit#65 dropped the `tx.lock_time = ZERO` that the path used to perform (correctly, since it regressed input CLTVs) but added no precondition in its place, so a tx whose locktime was already pinned — by an input's CLTV or by `min_locktime` — could come out with both a near-tip locktime and a confirmation-depth sequence. That matches neither an ordinary wallet spend nor a contract close: a third fingerprint, worse than either branch alone. Co-Authored-By: ValuedMammal <95981133+ValuedMammal@users.noreply.github.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
evanlinjin
force-pushed
the
fix/afs-sequence-branch-locktime
branch
from
August 20, 2026 08:12
147a6e7 to
e05146e
Compare
2 tasks
evanlinjin
added a commit
to evanlinjin/bdk-tx
that referenced
this pull request
Aug 20, 2026
…fee-sniping discourage_fee_sniping now consumes the template and returns a SealedTxTemplate exposing only reads + emission, so version/locktime/sequence/ordering can't be changed after AFS. TxTemplate wraps SealedTxTemplate and derefs to it for the shared read/emit surface. The concrete case this rules out: AFS may protect the transaction by setting an input's nSequence instead of the locktime, which it only does while lock_time is zero. A set_locktime afterwards would rebuild a tx carrying both a near-tip locktime and a confirmation-depth sequence — the fingerprint bitcoindevkit#87 exists to prevent. A compile_fail doctest pins that. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Description
Fixes #65 (comment) — point 2 of #73 (comment).
The nSequence path exists so the tx resembles an off-chain settlement spending a timelock path, and those carry
nLockTime = 0with a CSV-driven sequence.#65 removed the
tx.lock_time = LockTime::ZEROthat path used to perform — correctly, since it regressed input CLTVs — but added no precondition in its place. So a tx whose locktime is already pinned, by an input's CLTV or bymin_locktime, can come out with both a near-tip locktime and a confirmation-depth sequence. That matches neither an ordinary wallet spend nor a contract close: a third fingerprint, worse than either branch alone.The path is only coherent at
lock_time == 0, so make that a precondition:Changelog notice
Before submitting
🤖 Generated with Claude Code