mirror of
https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line.git
synced 2025-06-30 11:16:23 +00:00
Update 7_3_Scripting_a_P2PKH.md
This commit is contained in:
parent
91ee9d6eb9
commit
b5b6d232c9
@ -35,6 +35,7 @@ Script: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
|
|||||||
Stack: [ <signature> <pubKey> ]
|
Stack: [ <signature> <pubKey> ]
|
||||||
|
|
||||||
Script: OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
|
Script: OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
|
||||||
|
Running: <pubKey> OP_DUP
|
||||||
Stack: [ <signature> <pubKey> <pubKey> ]
|
Stack: [ <signature> <pubKey> <pubKey> ]
|
||||||
```
|
```
|
||||||
Why the duplicate? Because that's what's required by the script!
|
Why the duplicate? Because that's what's required by the script!
|
||||||
@ -42,6 +43,7 @@ Why the duplicate? Because that's what's required by the script!
|
|||||||
Next, `OP_HASH160` pops the `<pubKey>` off the stack, hashes it, and puts the result back on the stack.
|
Next, `OP_HASH160` pops the `<pubKey>` off the stack, hashes it, and puts the result back on the stack.
|
||||||
```
|
```
|
||||||
Script: <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
|
Script: <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
|
||||||
|
Running: <pubKey> OP_HASH160
|
||||||
Stack: [ <signature> <pubKey> <pubKeyHash> ]
|
Stack: [ <signature> <pubKey> <pubKeyHash> ]
|
||||||
```
|
```
|
||||||
Then, you place the `<pubKeyHash>` that was in the locking script on the stack:
|
Then, you place the `<pubKeyHash>` that was in the locking script on the stack:
|
||||||
@ -54,11 +56,13 @@ Stack: [ <signature> <pubKey> <pubKeyHash> <pubKeyHash> ]
|
|||||||
Assuming the two `<pubKeyHash>es` are equal, you will have the following result:
|
Assuming the two `<pubKeyHash>es` are equal, you will have the following result:
|
||||||
```
|
```
|
||||||
Script: OP_CHECKSIG
|
Script: OP_CHECKSIG
|
||||||
|
Running: <pubKeyHash> <pubKeyHash> OP_EQUALVERIFY
|
||||||
Stack: [ <signature> <pubKey> ]
|
Stack: [ <signature> <pubKey> ]
|
||||||
```
|
```
|
||||||
At this point you've proven that the `<pubKey>` supplied in the `scriptSig` hashes to the Bitcoin address in question, so you know that the redeemer knew the public key. They just need to prove knowledge of the private key, which is done with `OP_CHECKSIG`, which confirms that the unlocking script's signature matches that public key.
|
At this point you've proven that the `<pubKey>` supplied in the `scriptSig` hashes to the Bitcoin address in question, so you know that the redeemer knew the public key. They just need to prove knowledge of the private key, which is done with `OP_CHECKSIG`, which confirms that the unlocking script's signature matches that public key.
|
||||||
```
|
```
|
||||||
Script:
|
Script:
|
||||||
|
Running: <signature> <pubKey> OP_CHECKSIG
|
||||||
Stack: [ True ]
|
Stack: [ True ]
|
||||||
```
|
```
|
||||||
The Script now ends and the transaction is allowed to respend the UTXO in question.
|
The Script now ends and the transaction is allowed to respend the UTXO in question.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user