<blockquote>
  <p>Is the output script generated by my program?</p>
</blockquote>

<p>Yes.</p>

<blockquote>
  <p>scriptPubKey refers to Public Key of? </p>
</blockquote>

<p>Whoever you're sending the bitcoins to. </p>

<blockquote>
  <p>So, now, once the output script is formed, is it broadcast over the Bitcoin Network?</p>
</blockquote>

<p>After it's signed, yes.</p>

<blockquote>
  <p>Where does the Input Script come from?</p>
</blockquote>

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

<blockquote>
  <p>the scriptSig in Input Script refers to the Public Key and Signature of whom?</p>
</blockquote>

<p>You.</p>

<blockquote>
  <p>When I am sending Bitcoins to a Bitcoin Address, the input Script is automatically generated by what?</p>
</blockquote>

<p>Your client, after looking at your wallet.</p>

<blockquote>
  <p>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.</p>
</blockquote>

<p>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.</p>

<blockquote>
  <p>So, the Public Key in scriptPubKey differs from the Public Key in scriptSig?</p>
</blockquote>

<p>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:</p>

<pre><code>OP_DUP OP_HASH160 06f1b670791f9256bffc898f474271c22f4bb949 OP_EQUALVERIFY OP_CHECKSIG
</code></pre>

<p>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.</p>

<blockquote>
  <p>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?</p>
</blockquote>

<p>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. </p>

CC BY-SA 3.0
2013-03-09T06:06:50.483Z
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
CC BY-SA 3.0
2013-03-09T07:41:49.457Z
@NeonFlash I have edited my answer.
Nick ODell
CC BY-SA 3.0
2013-03-09T10:07:22.353Z
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
CC BY-SA 3.0
2013-03-09T03:16:25.597Z
2013-03-09T07:41:07.633Z
2013-03-09T07:41:07.633Z
Nick ODell
<p>I read about Input and output scripts on the wiki here:</p>

<p><a href="https://en.bitcoin.it/wiki/Transactions">https://en.bitcoin.it/wiki/Transactions</a></p>

<p>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.</p>

<p>Is the output script generated by my program?</p>

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

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

<p>So, now, once the output script is formed, is it broadcast over the Bitcoin Network?</p>

<p>Where does the Input Script come from?</p>

<p>the scriptSig in Input Script refers to the Public Key and Signature of whom?</p>

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

<p>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.</p>

<script>
How is the Output script formed?
Neon Flash
# How is the Output script formed?

(Asked by: username_0 on 2013-03-08)

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.

**Tags:** script


---

## 1 answers

### Answer by username_1 on 2013-03-09. Score: 5 | Accepted answer

> 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.

> **Comments:**
> **username_0**: 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.  
> **username_1**: @username_0 I have edited my answer.  
> **username_0**: 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?  

---

