Merge pull request #1528 from cypherstack/fix/taproot-input-sequence
What changed, and why it matters
This commit fixes a bug in how Taproot (a modern Bitcoin-style transaction format) inputs were being built. Previously, the 'sequence number'—a field that controls things like time-locks and replacement rules—was being dropped for Taproot key-path spends and silently reset to a default value. That could break intended transaction behavior such as time-locked refunds or Replace-By-Fee (RBF), and in some wallet designs could even make a transaction spendable under different conditions than the user expected. The fix simply passes the intended sequence number through when creating the Taproot input.
Review whether any already-signed or broadcast Taproot transactions were affected by the dropped sequence, especially those relying on RBF or timelocks. Add regression tests covering sequence preservation for all DerivePathType branches, including bip86. Consider auditing other Taproot-specific code paths for similar omissions.
Security signals we found
Missing nSequence preservation for Taproot key-path inputs
Behavioral divergence between Taproot and other input types in the same switch
Potential for unintended transaction semantics (RBF, timelocks) due to default sequence value
Fix is a one-line parameter pass-through, indicating an omission rather than a design change
Evidence from the diff
In lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart, the Bip86/Taproot branch of an input-construction helper was calling coinlib.TaprootKeyInput(prevOut: prevOut) without passing the sequence parameter. Other derivation types in the same switch already passed sequence: sequence. The one-line change adds sequence: sequence to the TaprootKeyInput constructor. This ensures the nSequence field is preserved for Taproot key-path inputs, aligning behavior with other script types and honoring wallet-level sequence settings (e.g., RBF signaling, relative/absolute timelocks).
Changed components
lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dartTaproot (BIP86) key-path input constructioncoinlib.TaprootKeyInput usageInspect captured patch +1 / −1
### lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart
@@ -490,7 +490,7 @@ mixin ElectrumXInterface<T extends ElectrumXCurrencyInterface>
);
case DerivePathType.bip86:
- return coinlib.TaprootKeyInput(prevOut: prevOut);
+ return coinlib.TaprootKeyInput(prevOut: prevOut, sequence: sequence);
default:
throw UnsupportedError(Why this scored 57/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.