support SIGHASH_ANYONECANPAY in taproot sighash - #3
Open
fmoletta-muun wants to merge 3 commits into
Open
Conversation
Accept ALL | ANYONECANPAY (0x81, BIP341) in hashForTaprootSignature: skip the four all-input midstate hashes and commit to the signed input's outpoint, spent output and sequence instead. Write the full sighash type byte into the message (the masked byte was only correct for types without the flag) and fix the sign of the anyone-can-pay term in the buffer size formula. ANYONECANPAY alone (0x80) stays rejected: it is not a valid taproot sighash type. Golden values from btcd v0.24.2 with txscript.SigHashAll|txscript.SigHashAnyOneCanPay.
kovin-muun
reviewed
Jul 28, 2026
| * | ||
| * <p>Limitations: only SigHash.DEFAULT and SigHash.ALL without ANYONECANPAY are supported; SigHash.NONE, | ||
| * SigHash.SINGLE and the annex are not implemented. OP_CODESEPARATOR is not supported: the codesep_pos in the | ||
| * <p>Limitations: only SigHash.DEFAULT, SigHash.ALL and SigHash.ALL | SigHash.ANYONECANPAY are supported; |
There was a problem hiding this comment.
Why not just use the existing enum ANYONECANPAY_ALL?
This way you also don't need to loss the type Transaction.SigHash which was changed to byte in
Replace SigHash.ALL | SigHash.ANYONECANPAY with the existing ANYONECANPAY_ALL enum constant in javadoc, comments and tests. The test helper takes Transaction.SigHash again and converts with byteValue(), so call sites pass plain enum constants without casts. No behavior change.
kovin-muun
reviewed
Jul 28, 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.
Accept ALL | ANYONECANPAY (0x81, BIP341) in hashForTaprootSignature: skip the four all-input midstate hashes and commit to the signed input's outpoint, spent output and sequence instead. Write the full sighash type byte into the message (the masked byte was only correct for types without the flag) and fix the sign of the anyone-can-pay term in the buffer size formula. ANYONECANPAY alone (0x80) stays rejected: it is not a valid taproot sighash type. Golden values from btcd v0.24.2 with txscript.SigHashAll|txscript.SigHashAnyOneCanPay.