Author

Topic: Pay to public key hash (Read 465 times)

jr. member
Activity: 113
Merit: 5
November 11, 2017, 02:24:12 AM
#6

The scriptSig part is what the receiver uses to spend the money that they got from pay-to-public-key-hash. Because they're spending the money, at that point they'd be the new sender. The for this new transaction hashes to the receiver's from the old transaction when they first got the money.


Thank you very much. finally understand it.
legendary
Activity: 1386
Merit: 1053
Please do not PM me loan requests!
November 11, 2017, 12:23:28 AM
#5
next to bitcoin.org and the developpers section and  Andreas' book "Mastering Bitcoin", this helped me alot to understand the underlying details:
http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html



I read the link. I am still not clear. In
scriptPubKey: OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG
scriptSig:

The scriptSig contains the sender signature and sender public key, the scriptPubKey contains which is the hash of receiver public key.

Then, how can the hash of sender matches with the receiver  ?

The scriptSig part is what the receiver uses to spend the money that they got from pay-to-public-key-hash. Because they're spending the money, at that point they'd be the new sender. The for this new transaction hashes to the receiver's from the old transaction when they first got the money.

Here's an example P2PKH transaction. It pays 0.00063664 BTC to my address with the script OP_DUP OP_HASH160 0507135dd0ec75f539b304d8641bf00372989b27 OP_EQUALVERIFY OP_CHECKSIG. Then, in the next transaction, I spend that 0.00063664 BTC, and you can see in the input script (scriptSig) that there is both a signature and the public key that hashes to 0507135dd0ec75f539b304d8641bf00372989b27, which is the pubKeyHash in the script of the other transaction where I was the receiver.
jr. member
Activity: 113
Merit: 5
November 10, 2017, 09:26:34 PM
#4
next to bitcoin.org and the developpers section and  Andreas' book "Mastering Bitcoin", this helped me alot to understand the underlying details:
http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html



I read the link. I am still not clear. In
scriptPubKey: OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG
scriptSig:

The scriptSig contains the sender signature and sender public key, the scriptPubKey contains which is the hash of receiver public key.

Then, how can the hash of sender matches with the receiver   ?
sr. member
Activity: 257
Merit: 343
November 10, 2017, 04:41:04 PM
#3
next to bitcoin.org and the developpers section and  Andreas' book "Mastering Bitcoin", this helped me alot to understand the underlying details:
http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html

legendary
Activity: 3472
Merit: 4801
November 10, 2017, 10:59:10 AM
#2
In P2PKH, the public key

scriptPubKey: OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG
scriptSig:

is the public key of the sender? the hash is from the sender public key?

No.

The hash is of the receiver's public key.

the signature is of the sender?

Yes.  The sender generates the signature using their private key.

Notes:

The scriptPubKey is in the OUTPUT of the transaction and is used to encumber the bitcoin value with a requirement that can only be satisfied by the recipient when they later want to spend the output that they have received.

The scriptSig is in the INPUT of the transaction and is how the sender satisfies the requirements of the previously received outputs that they are spending in the new transaction.
jr. member
Activity: 113
Merit: 5
November 10, 2017, 10:35:59 AM
#1
In P2PKH, the public key

scriptPubKey: OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG
scriptSig:

is the public key of the sender? the hash is from the sender public key? the signature is of the sender?
Jump to: