Let’s break down how Bitcoin transactions work using two simple terms:
- scriptPubKey = locks BTC to someone’s address
- scriptSig = unlocks BTC with proof of ownership
We'll use Alice and Bob to explain it.
🧾 Step-by-Step: Alice Sends 1 BTC to Bob
1. Alice’s Wallet Finds Her UTXO
- A UTXO is a coin Alice received earlier.
- It’s locked using Alice’s public key hash (her address), inside the
scriptPubKey
.
2. Alice Creates a Transaction
- She creates a new transaction using that UTXO as input.
- Her wallet adds a
scriptSig
:- Digital signature (made with her private key)
- Public key
This proves she owns the UTXO.
3. Alice Locks Output to Bob
- She adds an output to the transaction with a new
scriptPubKey
:- It contains Bob’s public key hash (Bob’s address)
- Only Bob can unlock this later
4. The Network Verifies the Transaction
- Full nodes check:
- Does Alice’s public key match the original hash?
- Is the signature valid?
- ✅ If yes, the transaction is confirmed.
🔄 Summary Table
Part | Who Creates It | Purpose |
---|---|---|
scriptSig |
Alice (sender) | Unlocks her UTXO using private key |
scriptPubKey |
Alice (sender) | Locks BTC to Bob’s address |
🧠 Diagram
[ Alice's Wallet ]
│
Finds UTXO with Alice's pubkey hash
│
Creates scriptSig (signature + pubkey)
│
Creates scriptPubKey → locks to Bob's address
│
Sends Transaction ───► [ Blockchain Node ]
│
Verifies scriptSig unlocks scriptPubKey
│
If valid → ✔ Transaction confirmed
This is the core of how Bitcoin ensures secure ownership and transfer of value — no third party needed.