(Assume there's no OP_CODESEPERATOR)

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


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

1 Answer 1


The signature verification algorithm for P2WPKH and P2WSH is specified in BIP143, which also includes a reference C++ implementation.

P2WPKH inputs are scriptless so they can't have an OP_CODESEPERATOR.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.