<p><strong>What data is in scriptSig</strong></p>

<p><code>scriptSig</code> in a typical <a href="https://bitcoin.org/en/developer-guide#transactions" rel="nofollow noreferrer">p2pkh scenario</a>, which is the vact majority of bitcoin transactions, only contains the public key of the <code>scriptPubKey</code> hash as well as the signature. This means there's no metadata other than the public key and the signature for authorizing the payment.</p>

<p>For non-p2pkh transactions, such as for example <a href="https://bitcoin.org/en/developer-guide#p2sh-scripts" rel="nofollow noreferrer">p2sh transactions</a>, more data is included in the <code>scriptSig</code>. For example in p2sh <a href="https://bitcoin.org/en/developer-guide#multisig" rel="nofollow noreferrer">multisig</a>, the multiple public keys capable of authorizing the multisig will be revealed. In even more complicated scripts, the <code>scriptSig</code> may reveal significant information, depending on what the <code>scriptPubKey</code> script is requesting. For example, there are snowflake transactions that require <code>scriptSig</code> to be <a href="https://en.bitcoin.it/wiki/Script#Transaction_puzzle" rel="nofollow noreferrer">solutions to certain puzzles</a>. However, these transactions are very rare.</p>

<p><strong>How transactions are validated</strong></p>

<p>There are multiple security models in validating a transaction. Transaction <em>validation</em> is a different notion from transaction <em>confirmation</em> which you are talking about. Transaction <em>validation</em> asks whether a transaction is valid – for example, it is of the right format, it follows Kirchhoff's Law (i.e. sum of outputs is less than sum of inputs), and the outputs it spends have not been double spent. Validating a transaction requires access to the <a href="https://bitcoin.org/en/glossary/unspent-transaction-output" rel="nofollow noreferrer">current UTXO</a>.</p>

<p>Transaction <em>confirmation</em> on the other hand validates that a transaction has been buried under a certain amount of proof-of-work, for example k = 6 blocks. Checking the confirmation status of a transaction does not require traversing the whole data in the blockchain. It only requires looking at the blockchain headers.  In the <a href="https://en.bitcoin.it/wiki/Thin_Client_Security" rel="nofollow noreferrer">SPV security model</a>, the transaction confirmation status is checked simply by checking that it was included in a block and buried under a certain amount of proof-of-work. This is done quickly without looking at the whole blockchain data (but just all of the blockchain headers) by providing a proof-of-inclusion which consists of <a href="https://bitcoin.org/en/developer-guide#simplified-payment-verification-spv" rel="nofollow noreferrer">Merkle tree path siblings</a>.</p>

CC BY-SA 3.0
2017-02-14T21:21:46.513Z
ok i understand how merkle tree works. but how does a node, that wants to check if a certain input for a transaction is still unspent, know in which block that transaction was if the only information provided is the hash of the transaction?
a.costa
CC BY-SA 3.0
2017-02-12T09:11:45.037Z
2017-02-12T09:11:45.037Z
dionyziz
<p>According to the informations that i found here: <a href="https://en.bitcoin.it/wiki/Transaction" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Transaction</a>
a bitcoin transaction contains,</p>

<p>FOR EVERY INPUT:</p>

<ul>
<li>The Hash of the incoming transaction</li>
<li>ScriptSig</li>
</ul>

<p>FOR EVERY OUTPUT:</p>

<ul>
<li>Value </li>
<li>ScriptPubKey</li>
</ul>

<p>Now my question is: what kind of informations are implicitly contained in the ScriptSig? I know that from ScriptPubKey the destination address can be calculated, but i don't see if any other information can be retrieved from the ScriptSig.</p>

<p>Furthermore, if only the hash of the incoming transaction is stored, how does a node look for the incoming transaction on the blockchain, when it needs to validate the new transaction? And how does it know in which block that transaction is included? 
If it doesn't know in which block that transaction is, does it have to skim through the whole blockchain just for finding it? </p>

CC BY-SA 3.0
2017-02-11T15:43:18.507Z
Your last paragraph is a separate question and should go in a separate post.  But it's already been addressed, e.g. at http://bitcoin.stackexchange.com/questions/13731/does-a-bitcoin-node-need-to-scan-through-the-whole-blockchain-in-order-to-be-100 (see also comments to answer). A full node has already indexed all transactions in the block chain by their hash (txid), so it can find any given transaction without rescanning the whole chain.
Nate Eldredge
CC BY-SA 3.0
2017-02-11T20:03:30.357Z
thank you @NateEldredge. is there a specification on how this indexing is made?
a.costa
CC BY-SA 3.0
2017-02-11T20:08:18.180Z
It's an implementation detail of the node client software.  For Bitcoin Core, you can see https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage#The_UTXO_set_.28chainstate_leveldb.29
Nate Eldredge
CC BY-SA 3.0
2017-02-11T20:23:52.813Z
so that means that when a full node indexes the blockchain it also calculate the hash of every transaction?
a.costa
CC BY-SA 3.0
2017-02-11T20:28:01.260Z
Yes, that's correct.
Nate Eldredge
<transactions><script>
What informations are contained in a transaction?
a.costa
# What informations are contained in a transaction?

(Asked by: username_0 on 2017-02-11)

According to the informations that i found here: <https://en.bitcoin.it/wiki/Transaction>
a bitcoin transaction contains,

FOR EVERY INPUT:

* The Hash of the incoming transaction
* ScriptSig

FOR EVERY OUTPUT:

* Value
* ScriptPubKey

Now my question is: what kind of informations are implicitly contained in the ScriptSig? I know that from ScriptPubKey the destination address can be calculated, but i don't see if any other information can be retrieved from the ScriptSig.

Furthermore, if only the hash of the incoming transaction is stored, how does a node look for the incoming transaction on the blockchain, when it needs to validate the new transaction? And how does it know in which block that transaction is included?
If it doesn't know in which block that transaction is, does it have to skim through the whole blockchain just for finding it?

**Tags:** transactions, script

> **Comments:**
> **username_1**: Your last paragraph is a separate question and should go in a separate post.  But it's already been addressed, e.g. at http://bitcoin.stackexchange.com/questions/13731/does-a-bitcoin-node-need-to-scan-through-the-whole-blockchain-in-order-to-be-100 (see also comments to answer). A full node has already indexed all transactions in the block chain by their hash (txid), so it can find any given transaction without rescanning the whole chain.  
> **username_0**: thank you @username_1. is there a specification on how this indexing is made?  
> **username_1**: It's an implementation detail of the node client software.  For Bitcoin Core, you can see https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage#The_UTXO_set_.28chainstate_leveldb.29  
> **username_0**: so that means that when a full node indexes the blockchain it also calculate the hash of every transaction?  
> **username_1**: Yes, that's correct.  

---

## 1 answers

### Answer by username_2 on 2017-02-12. Score: 1

**What data is in scriptSig**

`scriptSig` in a typical [p2pkh scenario](https://bitcoin.org/en/developer-guide#transactions), which is the vact majority of bitcoin transactions, only contains the public key of the `scriptPubKey` hash as well as the signature. This means there's no metadata other than the public key and the signature for authorizing the payment.

For non-p2pkh transactions, such as for example [p2sh transactions](https://bitcoin.org/en/developer-guide#p2sh-scripts), more data is included in the `scriptSig`. For example in p2sh [multisig](https://bitcoin.org/en/developer-guide#multisig), the multiple public keys capable of authorizing the multisig will be revealed. In even more complicated scripts, the `scriptSig` may reveal significant information, depending on what the `scriptPubKey` script is requesting. For example, there are snowflake transactions that require `scriptSig` to be [solutions to certain puzzles](https://en.bitcoin.it/wiki/Script#Transaction_puzzle). However, these transactions are very rare.

**How transactions are validated**

There are multiple security models in validating a transaction. Transaction *validation* is a different notion from transaction *confirmation* which you are talking about. Transaction *validation* asks whether a transaction is valid – for example, it is of the right format, it follows Kirchhoff's Law (i.e. sum of outputs is less than sum of inputs), and the outputs it spends have not been double spent. Validating a transaction requires access to the [current UTXO](https://bitcoin.org/en/glossary/unspent-transaction-output).

Transaction *confirmation* on the other hand validates that a transaction has been buried under a certain amount of proof-of-work, for example k = 6 blocks. Checking the confirmation status of a transaction does not require traversing the whole data in the blockchain. It only requires looking at the blockchain headers. In the [SPV security model](https://en.bitcoin.it/wiki/Thin_Client_Security), the transaction confirmation status is checked simply by checking that it was included in a block and buried under a certain amount of proof-of-work. This is done quickly without looking at the whole blockchain data (but just all of the blockchain headers) by providing a proof-of-inclusion which consists of [Merkle tree path siblings](https://bitcoin.org/en/developer-guide#simplified-payment-verification-spv).

> **Comments:**
> **username_0**: ok i understand how merkle tree works. but how does a node, that wants to check if a certain input for a transaction is still unspent, know in which block that transaction was if the only information provided is the hash of the transaction?  

---

