Level 3 · Advanced
Script: step through a P2PKH spend
Step through a P2PKH spend in a Script stack machine and see how Bitcoin checks a signature. A free, hands-on lab.
In short
A P2PKH output locks coins to the hash of a public key, and spending it needs that public key plus a valid signature. Bitcoin Script checks them step by step on a stack: copy the key, hash it, compare it with the stored hash, then verify the signature.
Script is a small stack language. A legacy payment is unlocked by running the spender's scriptSig, then the coin's scriptPubKey. If true is left on top, the spend is valid.
Step 0 of 7Press step to run the script.
Learn Bitcoin with real people.
Find meetups and Bitcoiners in your city, and ask the questions you'd never post online. Free to download on iPhone and Android.