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.
Fixes #65
I've found 2 distinct bugs in the implementation of the SigMsg function from BIP-341.
The first, when the sighash includes ANYONECANPAY the spec says the first chunk of data must be
outpoint (36): the COutPoint of this input (32-byte hash + 4-byte little-endian)
. However Embit was serializing the whole input using theTransactionInput.write_to()
method, which includes more fields than just the outpoint and results in 41 bytes of data instead of 36.Second, when SIGHASH_SINGLE is used the spec says to include
sha_single_output (32): the SHA256 of the corresponding output in CTxOut format
. In this case Embit was including the serialization of the output itself, not its SHA256 digest.With these two changes I'm able to spend non-SIGHASH_DEFAULT Taproot transactions made from PSBTs signed with Embit.
I'd like help adding the unit test that reproduces the issue, as for now I can't follow test_taproot.py. I was able to verify that the test suite is currently not covering these execution branches, though: