<p>Scripts are not <em>parsed</em>. From the protocol perspective they are byte arrays, and their contents is irrelevant for transaction deserialization.</p>

<p>Scripts are <em>executed</em> however, at the time they participate in spending. For outputs, that is when they are (attempted to be) spent. For non-coinbase inputs, that is immediately. Coinbases never participate in spending, so for almost(*) all purposes, they are just byte arrays.</p>

<p>(*) There are two partial exceptions to this. BIP34 requires the coinbase to start with a push of the block height. The 80000 vsigops limit also counts CHECKSIG operations in coinbases (treating them as scripts, but it stops counting at the first invalid opcode).</p>

CC BY-SA 4.0
2020-04-28T18:51:21.187Z
Awesome1 Thanks for the great explanation.
Oscar Serna
CC BY-SA 4.0
2020-04-28T18:42:31.077Z
2020-04-28T18:42:31.077Z
Pieter Wuille
<p>I am currently developing a blockchain parser in Python, and it has been crashing in the file blk00006.dat for the coinbase transaction with the hash <code>afbff1130b6fcbdceebbadfc48a842af1f03ee08a79e042b37fc467518b49a0f</code> in the block <code>0000000000000a46714e1b03e5e0693e9ecaa3ec1853f1cdf34e9ca52e13f1ff</code>. The reason it was crashing is because it has an <code>OP_PUSHDATA2</code> in the script signature with a value of 28265. However, there are only 21 bytes left to read according to the size of the script. </p>

<p>I fixed my code to avoid crashing in this script, but I am still curious about how this script_signature got accepted by the network. </p>

<script><network><coinbase-transaction><input-script>
Script_sig for coinbase transaction afbff1130b6fcbdceebbadfc48a842af1f03ee08a79e042b37fc467518b49a0f
Oscar Serna
# Script_sig for coinbase transaction afbff1130b6fcbdceebbadfc48a842af1f03ee08a79e042b37fc467518b49a0f

(Asked by: username_0 on 2020-04-28)

I am currently developing a blockchain parser in Python, and it has been crashing in the file blk00006.dat for the coinbase transaction with the hash `afbff1130b6fcbdceebbadfc48a842af1f03ee08a79e042b37fc467518b49a0f` in the block `0000000000000a46714e1b03e5e0693e9ecaa3ec1853f1cdf34e9ca52e13f1ff`. The reason it was crashing is because it has an `OP_PUSHDATA2` in the script signature with a value of 28265. However, there are only 21 bytes left to read according to the size of the script.

I fixed my code to avoid crashing in this script, but I am still curious about how this script\_signature got accepted by the network.

**Tags:** script, network, coinbase-transaction, input-script


---

## 1 answers

### Answer by username_1 on 2020-04-28. Score: 1 | Accepted answer

Scripts are not *parsed*. From the protocol perspective they are byte arrays, and their contents is irrelevant for transaction deserialization.

Scripts are *executed* however, at the time they participate in spending. For outputs, that is when they are (attempted to be) spent. For non-coinbase inputs, that is immediately. Coinbases never participate in spending, so for almost(\*) all purposes, they are just byte arrays.

(\*) There are two partial exceptions to this. BIP34 requires the coinbase to start with a push of the block height. The 80000 vsigops limit also counts CHECKSIG operations in coinbases (treating them as scripts, but it stops counting at the first invalid opcode).

> **Comments:**
> **username_0**: Awesome1 Thanks for the great explanation.  

---

