Skip to content

Conversation

JAGADISHSUNILPEDNEKAR
Copy link
Contributor

Description

This PR introduces support for the signature hash annex in the signature hashing function, ensuring compatibility with transactions that include an annex field. The changes are minimal and scoped specifically to this functionality, avoiding any unnecessary modifications to unrelated components.

Key Changes

  • Added support for annex in the signature hash calculation as per BIP-341
  • Ensured proper handling of annex inclusion in sighash computation
  • Introduced relevant test cases to validate correctness
  • Updated documentation to reflect annex support and its impact on transaction signing

Relevance to PSBT Support

Implementing annex support in the signature hash function is a crucial step toward full Partially Signed Bitcoin Transaction (PSBT) support. This enhances PSBT compatibility with Taproot transactions by allowing correct sighash computation for inputs that include an annex, ensuring interoperability with modern Bitcoin wallets and signing tools.

Context

This PR keeps changes minimal while improving Bitcoin transaction handling in line with the latest standards, specifically addressing the requirements outlined in BIP-341 for signature hash computation.

Testing

  • Added comprehensive test cases covering various annex inclusion scenarios
  • Verified compatibility with existing transaction signing mechanisms
  • Ensured no regression in existing signature hash computations

Notes

Minimal code changes focused solely on implementing annex support in signature hash computation.

@JAGADISHSUNILPEDNEKAR
Copy link
Contributor Author

All the test cases are passing

Screenshot 2025-03-19 at 4 35 03 PM

@karask
Copy link
Owner

karask commented Apr 3, 2025

  • The code for the annex looks OK (haven't run it yet).
  • The documentation you provide is quite arbitrary. I use sphinx for the documentation which automatically creates basic docs from the doc strings included in the .py files. There is a TODO to start create documentation for the project by adding information to the .rst files created by Sphinx. For the purposes of annex just delete the doc and maybe improve the comments in the file to explain it better.
  • Most of the tests are integration tests. You need to create an actual taproot transaction that contains the annex and test that Bitcoin Core accepts it. Then create another tx and spend the previous one containing the annex. If that works you can use the tx hex from bitcoin core and create the same tx from inside a test that a creates tx hex equal to the tx hex that you got from core.

@JAGADISHSUNILPEDNEKAR
Copy link
Contributor Author

@karask will go through this again along with your feedback and give you a enhanced approach over this
Will also create a taproot transaction as mentioned above

@JAGADISHSUNILPEDNEKAR
Copy link
Contributor Author

Hey @karask
As you had suggested I have deleted the doc and also improved the comments in the file
also created an actual taproot transaction that contains the annex and test that Bitcoin Core accepts it also automatically skips if Bitcoin Core isn't available

there were some issues regarding this PR so I created a new PR #153 with the same implementation that you required
As of now I am closing this PR if any changes are required I would be happy to make them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants