Skip to content
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

Add P2WPKH support #2

Open
Benjamin-Loison opened this issue Oct 13, 2022 · 0 comments
Open

Add P2WPKH support #2

Benjamin-Loison opened this issue Oct 13, 2022 · 0 comments
Labels
enhancement New feature or request epic A task that is going to take more than a day to complete. high priority Issue disabling the user to use a feature correctly.

Comments

@Benjamin-Loison
Copy link
Owner

Benjamin-Loison commented Oct 13, 2022

Current DFINITY work in progress P2WPKH support produces transactions that are discarded by Bitcoin nodes (to dos in the source are here: 1. and 2.).

Help was requested on StackOverflow and BitcoinTalk.org.

Should be able to redeem UTXOs received on addresses generated with get_p2sh_address, get_p2sh_address_for_pub_key and get_p2wpkh_address.
P2tr should also be discussed.

The problem is that the code appears to follow the specification but the transactions are not accepted. It looks like the signatures are wrong and, since P2WPKH uses ECDSA as well, this probably means that the wrong bytes are signed.

I would say that it is related to what we hash. I think our best luck first is to try using a hardcoded private key and pass a test of the BIP.

Once the signature itself will be correct, pay attention to fee as it's not counted the same way between P2PKH and P2WPKH.

I tried for a short while to figure out at which step the error is introduced (using some Python ECDSA libraries) but I didn't manage to get any reasonable information out of this exercise.
Do you know some cool tools to test each step? It would already be helpful just to know if the signature on the sighash is correct, i.e., the signature is encoded correctly and verification passes for the provided public key. In this case, it would be fairly clear that there is something wrong with the sighash.

I think the problem isn't the signature as far as I understand but the transaction itself. The GitHub user rust-bitcoin published the rust-bitcoin library, he also shared a rust-wallet supporting P2WPKH using the rust-bitcoin library. I would look at its code for P2WPKH.

@Benjamin-Loison Benjamin-Loison added enhancement New feature or request high priority Issue disabling the user to use a feature correctly. epic A task that is going to take more than a day to complete. labels Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request epic A task that is going to take more than a day to complete. high priority Issue disabling the user to use a feature correctly.
Projects
None yet
Development

No branches or pull requests

1 participant