karask / python-bitcoin-utils

Library to interact with the Bitcoin network. Ideal for low-level learning and experimenting.
MIT License
262 stars 99 forks source link

Fix taproot hash computation #104

Open ramonamela opened 5 days ago

ramonamela commented 5 days ago

When hashing two branches in the taproot tree, the one containing the script that is going to be executed should always go first (we cannot just concatenate the two branches in order). Then, the current implementation for the example [ [A, B], C ] works for A and B. The problem is that for a huge tree with an arbitrary amount of leaves, the implementation only works for the two most leftmost leaves. The tests were correct since they checked spending from the first leaves. They'd failed when spending from C.

karask commented 4 days ago

Hi @ramonamela , I will check this when I am back from holidays. Thanks for the contribution.