script: add and default to SIGHASH_ALL_WITH_RANGEPROOF for pre-taproot signing - #1584
Open
delta1 wants to merge 9 commits into
Open
script: add and default to SIGHASH_ALL_WITH_RANGEPROOF for pre-taproot signing #1584delta1 wants to merge 9 commits into
delta1 wants to merge 9 commits into
Conversation
… rangeproof bit for Taproot signing Add a named default constant SIGHASH_ALL_WITH_RANGEPROOF (SIGHASH_ALL | SIGHASH_RANGEPROOF) and a DefaultSighashType() helper that selects the default pre-Taproot sighash based on whether SIGHASH_RANGEPROOF is active for the target chain. Strip the 0x40 (SIGHASH_RANGEPROOF) bit when computing Schnorr signatures, since the BIP341-style sighash always commits to rangeproofs and rejects the bit. This keeps SIGHASH_ALL_WITH_RANGEPROOF a valid universal default for both pre-Taproot and Taproot signing.
…eck) Add a Chain interface method that reports whether SIGHASH_RANGEPROOF is active for signing at the current chain tip, mirroring the mempool standardness check (DeploymentActiveAfter for DEPLOYMENT_DYNA_FED). This is the live-tip gating source used by the wallet and wallet-backed RPC to decide the default pre-Taproot sighash.
Add a CChainParams helper that decides, from chain parameters alone (without a chain tip), whether SIGHASH_RANGEPROOF can be assumed active. This is true when dynafed is configured ALWAYS_ACTIVE, or on liquidv1 where dynafed is height-activated (not the ALWAYS_ACTIVE sentinel) but is long since active on the live chain. This is the chainstate-less gating source used by elements-tx. Add a unit test covering liquidv1 (active by chain type, nStartTime != ALWAYS_ACTIVE), liquidv1test (active via ALWAYS_ACTIVE override), and regtest (inactive).
Change the wallet's default pre-Taproot sighash to commit to output rangeproofs when dynafed is active at the current tip, closing the pre-Taproot rangeproof (witness) malleability gap. Route the default through DefaultSighashType(chain().isSighashRangeproofActive()) in CWallet::SignTransaction and in the signrawtransactionwithwallet / walletprocesspsbt RPCs when the caller does not supply a sighash. Explicit user-supplied sighash types are left untouched.
…d active Default the raw signing RPCs to commit to output rangeproofs when dynafed is active at the current tip. The SignTransaction util gains a sighash_rangeproof_active parameter and, when no sighash is supplied, resolves the default via DefaultSighashType. Wire this through signrawtransactionwithkey and descriptorprocesspsbt using DeploymentActiveAfter(DEPLOYMENT_DYNA_FED) for tip activation. Explicit user-supplied sighash types are left untouched.
elements-tx has no chainstate, so gate the default sighash on chain parameters via CChainParams::SighashRangeproofActiveByParams(): commit to rangeproofs by default on chains where dynafed is known active (including liquidv1), otherwise use the historical SIGHASH_ALL default so offline-built txs stay standard and valid. Normalize SIGHASH_DEFAULT to SIGHASH_ALL for the legacy tool path; explicit sighash=... still overrides.
Extend feature_sighash_rangeproof.py with a case asserting that the wallet's default sign path (no explicit sighash arg) produces signatures that commit to output rangeproofs once dynafed is active.
Document the new default pre-Taproot sighash (SIGHASH_ALL | SIGHASH_RANGEPROOF), its scope (wallet + raw RPC + bitcoin-tx), and the activation/chain-params gating.
apoelstra
approved these changes
Aug 19, 2026
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.
Pre-Taproot signatures using the historical SIGHASH_ALL default do not commit to output rangeproofs, leaving a witness malleability gap: an attacker can alter a transaction's rangeproofs without invalidating its signatures. This branch closes that gap by making signing default to SIGHASH_ALL | SIGHASH_RANGEPROOF on chains where dynafed is active, while leaving explicit user-supplied sighash types untouched and preserving the legacy default.
Scope: