Skip to content

Fix error in scriptPubKey field in BIP 143 example#652

Closed
Sword-Smith wants to merge 1 commit intobitcoin:masterfrom
Sword-Smith:patch-1
Closed

Fix error in scriptPubKey field in BIP 143 example#652
Sword-Smith wants to merge 1 commit intobitcoin:masterfrom
Sword-Smith:patch-1

Conversation

@Sword-Smith
Copy link
Copy Markdown

It seems that a scriptPubKey used when signing a transaction was wrong.

It seems that a scriptPubKey used when signing a transaction was wrong.
@luke-jr
Copy link
Copy Markdown
Member

luke-jr commented Feb 22, 2018

@jl2012 @sipa

@ysangkok
Copy link
Copy Markdown
Contributor

@Sword-Smith Do you have some code that you use to test this?

@Sword-Smith
Copy link
Copy Markdown
Author

@Sword-Smith Do you have some code that you use to test this?

I do not at the moment. But it is obvious, no? You are using BIP143 which is only used when spending segwit inputs. Agreed? So the scriptCode of the input I am spending must be of form P2WPKH or P2WSH in order for BIP143 to be used. Agreed?

The field in question is field 5:
5. scriptCode of the input (serialized as scripts inside CTxOuts)

So we are signing a scriptPubKey of something sent to a segwit address. That output must be of the form 0014 (P2WPKH) or 0020 (P2WSH).

Or am I missing something?

@sipa
Copy link
Copy Markdown
Member

sipa commented Jul 25, 2019

This is incorrect. The scriptCode is the script being executed. It is not the scriptPubKey. For P2SH it is the redeemscript, for P2WSH (P2SH or not) it is the witness script. For P2WPKH (P2SH or not) it is the equivalent P2PKH script.

@luke-jr luke-jr closed this Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants