Tags: muun/bitcoinj
Tags
support SIGHASH_ANYONECANPAY in taproot sighash (#3) * support SIGHASH_ANYONECANPAY in taproot sighash 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. * use ANYONECANPAY_ALL instead of composing sighash flags 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. * take SigHash instead of raw byte in hashForTaprootSignature * add final to vars used in hashForTaprootSignature
support SIGHASH_DEFAULT in taproot sighash (#2) * support SIGHASH_DEFAULT in taproot sighash Add SigHash.DEFAULT (0x00, BIP341) and accept it in hashForTaprootSignature. It hashes like ALL but commits hash type 0x00, and the resulting Schnorr signature omits the sighash byte. Golden value for the script-path test generated from btcd v0.24.2 with txscript.SigHashDefault. * add comment regarding sighash unset vs default variants * extract shared taproot sighash test fixture The three testSigHashTaproot* tests duplicated ~70 lines of tx, prevouts and tapleaf setup, differing only in sighash type and golden value. Also drop the redundant tapleaf hash golden: a wrong leaf hash already fails the sighash assertion. * add key-path SIGHASH_DEFAULT sighash test SIGHASH_DEFAULT acceptance also applies to key-path spends, which only had SIGHASH_ALL coverage. Golden value from btcd v0.24.2.
support BIP342 script-path taproot sighash hashForTaprootSignature only handled key-path (BIP341) spends. Allow a non-null scriptCode, interpreted as the 32-byte tapleaf hash, to produce the script-path sighash: set spend_type to 0x02 and append the ext_flag=1 extension (tapleaf_hash || key_version || codesep_pos). Key-path behaviour is unchanged. Add testSigHashTaprootScriptPath, whose golden value is cross-checked against btcd's txscript.CalcTapscriptSignaturehash (the same oracle reproduces the existing key-path vector exactly). The script used to generate the test values is included as a comment.
PreviousNext