Scenario: A is sending 1 BTC to B.
scriptSig appears in the Input Script.
scriptSig = <sig> <pubKey>
- Here, public key is the Public Key of the sender, A. (this is the public key corresponding to his Bitcoin Address which has some unspent transaction).
What is the sig part of scriptSig?
scriptPubKey
scriptPubKey = OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
pubKeyHash = Hash of the Public Key of Recipient (in our case, B).
- The sender (A) only has the Bitcoin Address of the recipient (B), so how does he get the pubKeyHash from his Bitcoin Address?
Now, this is my understanding so far:
Input Script carries information about the "previous transaction" of the sender and points to the appropriate "output" part of "previous transaction" using an index. The output of the previous transaction is the total available balance for the sender (A) which can be claimed to send Bitcoins to the recipient (B).
This Input Script is also used to verify that the sender (A) is the actual owner of the Bitcoins held in the referenced output of previous transaction.
Output Script tells us, how many bitcoins the Sender wants to Transfer to the Recipient and it also mentions the Bitcoin Address of recipient.
Questions:
The public Key in scriptSig is different from the public Key in scriptPubKey?
How can the signed information of the Sender be verified by the recipient, if they don't share the same Public Key?
I have tried understanding the example given on wiki which shows how the script is executed in a stack based manner but could not understand it.
I have some more questions, but I think I will ask them in a different question instead of putting it altogether here.
Thanks.