btcsuite / btcd

An alternative full node bitcoin implementation written in Go (golang)
https://github.com/btcsuite/btcd/blob/master/README.md
ISC License
6.11k stars 2.32k forks source link

Sighash taproot keyspend bug fix #1941

Closed Roasbeef closed 1 year ago

Roasbeef commented 1 year ago

In this PR, we fix a bug in RawTxInTaprootSignature that would cause the function to not properly apply the sighash flag for non-default sighash signatures. The logic would end up applying 0x00 as a mask, which will always be 0x00 on the other end.

The RawTxInTapscriptSignature function was correct, though it had the ordering switched as it applies the sighash if the type doesn't equal default.

The second commit adds tests that fail w/o the first commit. Without the first commit, the test fails for the keyspend sigs as they're always 64 bytes, since the sighash wasn't added for non-default types.

coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 4002408802


Totals Coverage Status
Change from base Build 3968292573: 0.08%
Covered Lines: 26610
Relevant Lines: 48165

💛 - Coveralls