9

I read about Input and output scripts on the wiki here:

https://en.bitcoin.it/wiki/Transactions

Let's say, I use my Bitcoin - QT Program, I go to "Send Coins" tab, enter a Bitcoin Address, BTC amount and then click Send.

Is the output script generated by my program?

For an output script, we need the Value, The destination Address and the scriptPubKey. My client program has all this data.

scriptPubKey refers to Public Key of? My public key or the person I intend to send the Bitcoins to?

So, now, once the output script is formed, is it broadcast over the Bitcoin Network?

Where does the Input Script come from?

the scriptSig in Input Script refers to the Public Key and Signature of whom?

When I am sending Bitcoins to a Bitcoin Address, the input Script is automatically generated by what?

Even though the wiki gives details about Input Script and output Script, I was unable to correlate it to a real time scenario where one person sends BTC to another.

3

Is the output script generated by my program?

Yes.

scriptPubKey refers to Public Key of?

Whoever you're sending the bitcoins to.

So, now, once the output script is formed, is it broadcast over the Bitcoin Network?

After it's signed, yes.

Where does the Input Script come from?

It is composed of two pieces - your public key, and a valid signature corresponding to that public key. So, you make it.

the scriptSig in Input Script refers to the Public Key and Signature of whom?

You.

When I am sending Bitcoins to a Bitcoin Address, the input Script is automatically generated by what?

Your client, after looking at your wallet.

Even though the wiki gives details about Input Script and output Script, I was unable to correlate it to a real time scenario where one person sends BTC to another.

There are two parts to a bitcoin transaction - the part where you prove that you own some bitcoins, and the part where you designate someone else to be able to prove they own some bitcoins.

So, the Public Key in scriptPubKey differs from the Public Key in scriptSig?

scriptPubKey is very poorly named, because when you're sending bitcoins to an address, you only know the 160-bit hash of the public key. A scriptPubKey looks like this:

OP_DUP OP_HASH160 06f1b670791f9256bffc898f474271c22f4bb949 OP_EQUALVERIFY OP_CHECKSIG

The 06f1b6... is how your client specifies who it's sending to. The parts around it are scripts that tell the bitcoin client how to validate the transaction.

Also, we only have the Bitcoin Address of the person we intend to send the Bitcoins to. How do we get the Public Key of the recipient?

We don't need to. We can tell the network the 160 bit hash, and the person you're sending to can show the public key to the network when they want to spend their bitcoins.

  • Thanks. So, the Public Key in scriptPubKey differs from the Public Key in scriptSig? Also, we only have the Bitcoin Address of the person we intend to send the Bitcoins to. How do we get the Public Key of the recipient? I know that Bitcoin Address is itself the 160-bit hash of the public portion of the recipient's Public/Private Key pair. But I am unable to correlate the two. – Neon Flash Mar 9 '13 at 6:06
  • @NeonFlash I have edited my answer. – Nick ODell Mar 9 '13 at 7:41
  • Thanks. I think I have understood now. So, the scriptPubKey which we are referring to in the Transaction Verification phase, is "NOT" the recipient's Bitcoin Address. It is the scriptPubKey stored in the "output script" of the previous transaction of the sender. The sender's scriptSig (sig + pubkey) will be verified against the scriptPubKey stored in the output script of previous transaction. Then, it can be claimed by the sender. The new output script generated by the sender, will assign the Bitcoins to recipient's address and provide a way for the recipient to claim them in future. Correct? – Neon Flash Mar 9 '13 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.