What is P2PKH?
P2PKH stands for “Pay-to-PublicKeyHash” and it is the most common form of transaction in bitcoin.
A Public Key Hash is synonymous to a bitcoin address. It is one format of a bitcoin address (the other being Pay-to-Script Hash).
At a basic level, P2PKH means to “pay to this bitcoin address”. It is an instruction on the blockchain to transfer bitcoin from the current owner to the new owner of a bitcoin address.
Behind every bitcoin transaction, there is some code working in the background, this code is the Bitcoin Scripting language.
Terms you need to know
1. PubkeyScript (also called scriptPubKey or locking script); and
2. SignatureScript (also called scriptSig or unlocking script).
A PubkeyScript is a list of recorded instructions that accompany output transactions, it governs how the next person can unlock received bitcoin and spend it. To do this, the recipient of sent bitcoin will generate a signature script which must satisfy the parameters of a PubkeyScript created by the last sender.
These parameters are
1. Public Key Hash (bitcoin address)
2. Digital Signature
An owner of a P2PKH address can only unlock the PubKey Script and spend sent funds, by providing a public key hash and a private key signature.
In a typical scenario, Bob will give a bitcoin address to Alice and Alice will send bitcoin to Bob. The output of Alice’s transaction will create a PubkeyScript. Alice’s job is done and the transaction is broadcasted onto the bitcoin network and bitcoin appears in Bob’s wallet.
For Bob to spend his newly received bitcoin, he must prove that he is the owner of the bitcoin address that Alice attached the BTC to. Bob does this by building a scriptSig with his signature and his public key.
The scriptPubKey places conditions on the transfer of bitcoin. In P2PKH the condition is “only the person who can prove they own the bitcoin address provided to Alice can pass the bitcoin to someone else”. And this person can only ever be Bob.
Thus, the scriptSig is data that is generated by the sender, Bob, to be able to satisfy the scriptPubKey (generated by Alice) to send his bitcoin to another person creating a scriptPubKey in the process attached to that recipient’s address.
Pay to Public Key Hash is an important concept that simply describes how ownership gets transferred on the blockchain. There are lots of other variants such as P2PK, P2SH, P2MS etc but they all work on the same basic concept.
Written by Martin Pang
Trade Support @Genesis Block
For any queries please contact [email protected]