<p>The signature verification algorithm for P2WPKH and P2WSH is specified in <a href="https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki" rel="nofollow noreferrer">BIP143</a>, which also includes a reference C++ implementation.</p>
<p>P2WPKH inputs are scriptless so they can't have an OP_CODESEPERATOR.</p>

CC BY-SA 4.0
2024-04-11T23:41:20.860Z
2024-04-11T23:41:20.860Z
Vojtěch Strnad
<p>(Assume there's no OP_CODESEPERATOR)</p>
<p>For standard P2PKH, the signature digest is generated this way:</p>
<pre><code>NewTransaction

settle the TxOuts well
set all TxIn scripts to empty
insert the Previous Locking Script into the TxIn you are signing
append hash type code to the end of the transaction
SHA256 twice this transaction
Be a digest.
</code></pre>
<p>What does one do for signature verification of p2pwkh?
It would be helpful if you can provide with some docs related to algorithm or some basic code would also be appreciated</p>

<bitcoin-core><signature><verification><p2wpkh>
How does one verify signature in a P2WPKH transaction?
Archit Dabral
# How does one verify signature in a P2WPKH transaction?

(Asked by: username_0 on 2024-04-11)

(Assume there's no OP\_CODESEPERATOR)

For standard P2PKH, the signature digest is generated this way:

```
NewTransaction

settle the TxOuts well
set all TxIn scripts to empty
insert the Previous Locking Script into the TxIn you are signing
append hash type code to the end of the transaction
SHA256 twice this transaction
Be a digest.

```

What does one do for signature verification of p2pwkh?
It would be helpful if you can provide with some docs related to algorithm or some basic code would also be appreciated

**Tags:** bitcoin-core, signature, verification, p2wpkh


---

## 1 answers

### Answer by username_1 on 2024-04-11. Score: 0

The signature verification algorithm for P2WPKH and P2WSH is specified in [BIP143](https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki), which also includes a reference C++ implementation.

P2WPKH inputs are scriptless so they can't have an OP\_CODESEPERATOR.


---

