-
Notifications
You must be signed in to change notification settings - Fork 145
Add support for P2WSH P2WPKH transaction #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hi @QuincySx and thank you for the contribution! I was actually in the middle of implementing segwit support but only worked/tested the SIGHASH_ALL type. Yours seems to be more complete so I will be happy to include it. However, I need to have the appropriate tests implemented. I typically create a tx (e.g. p2wpkh) with bitcoin core and get the raw transaction and then create a test that creates the same transaction using python-bitcoin-utils and compare them. I would create a test_p2wpkh_txs.py that will test single and multi-input segwit transactions using different SIGHASHs (check test_p2pkh_txs.py). Accordingly, for p2wsh. Another minor point is that I try to be consistent throughout the codebase with regard to syntax, naming and documentation. This is intended as an educational library so more inline comments are encouraged. For example, get_transaction_segwit_digest() would need some inline comments to explain the different cases (I have a TODO to improve the doc in the current get_transaction_digest() as well). I also see that you added an "amount" parameter in TxInput. Why would that be needed? I see that is not used anywhere though. Again, I really appreciate your time and effort on this. But I want to include as tested code as possible before I merge to master. Next time I devote time on this I might work on the above. Until then, if you have time to commit the above changes then it would be great! Cheers! |
|
|
I have written a test code for various transfers, but the signature type is just SIGHASH_ALL . |
|
I was referring to unit tests like those in |
|
Regarding |
|
Hi. |
|
I'll add another example of mixing tomorrow, merging. |
Add .gitignore file
|
In addition to the comments basically can also |
|
Hi @QuincySx and thanks for the update! I just saw that you also have Let me know when you are done updating/adding to the PR and I can then do final testing and cleanup (if needed) before I merge. I also saw some comments in Chinese... could you please translate to English? Cheers |
|
From the point of view, witnesses should belong to the transaction, I think the witnesses are more reasonable in TxInput. |
|
As you say, from a user/dev perspective it might by more intuitive to have them in the TxInput. Strictly speaking though, when witnesses are serialized they are not part of the inputs... they are serialized as part of the Transaction (after the outputs). I am not insisting on this though. Let me know when you are done with the changes and I can test things further. Thanks |
|
Thanks! For some reason the tx-related tests are failing. I will check it out later. |
|
Sorry, there was a parameter change in the test. |
|
Hi. |
|
The test that passes is the non-segwit one (def test_signed_send_to_p2wpkh). The Transaction.copy() is correct. I quickly double checked by using a library's copy method. e.g. in class Transaction:
...
I got the exact same issues using deepcopy above. Were the tests working before you moved the witnesses to Transaction class? I will try to look at it further next week. |
|
It is normal to test the test before moving the witness to the transaction class. |
|
Creating a transaction specifies that witnesses = [] is no problem. |
|
Can you revert to a version that the tests were working as expected (e.g. when As it is now, I would have to rework all the logic. |
|
There is no problem now, you can run the test case directly. |
Add support for P2SH P2WPKH transaction
Did not complete the isolation testimony tx_id generation