Understanding P2WPKH #333
-
I was trying to understand the P2WPKH addresses, but I don't understand how are they valid for non-segwit nodes? My understanding of a valid bitcoin script is that the stack should be empty once the concatenation of the unlocking and locking script is run. This is the locking script for P2WPKH
This page describes that
But in this case, the stack would not be empty. So how is this a valid script? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I can answer the second question, but can't answer the first one (I have the same question actually). So, the witness program is the next byte-push following the version opcode in the scriptPubkey. The meaning of the witness program is specific to the used witness version (first int-push in scriptPubkey). For witness version v0 (P2WKPH, P2WSH) it means that the following push (20 or 32 bytes correspondingly) is the hash of the public key (P2WPKH) or a witness script (P2WSH). It must be provided as a part of the witness data of the spending transaction input, and for a public key it must be a compressed public key, and for a witness script it must be a script source as a first witness stack element (i.e. this is "like in P2SH", except that the script is now part of the witness and not sigScript and thus lacks byte-push command in front of it. Also it is disallowed to have checksigs/checkmultisigs for uncompressed keys, unlike P2SH). |
Beta Was this translation helpful? Give feedback.
I can answer the second question, but can't answer the first one (I have the same question actually).
So, the witness program is the next byte-push following the version opcode in the scriptPubkey. The meaning of the witness program is specific to the used witness version (first int-push in scriptPubkey).
For witness version v0 (P2WKPH, P2WSH) it means that the following push (20 or 32 bytes correspondingly) is the hash of the public key (P2WPKH) or a witness script (P2WSH). It must be provided as a part of the witness data of the spending transaction input, and for a public key it must be a compressed public key, and for a witness script it must be a script source as a first witness stac…