<p>It appears that anything between <strong>0x01 - 0x4b</strong> in the scriptPubKey signifies the number of bytes to be pushed on to the stack.</p>

CC BY-SA 3.0
2016-04-26T19:40:30.197Z
Right. That's the most common type of push data opcode. However, there's also OP_PUSHDATA1, OP_PUSHDATA2, and (currently useless) OP_PUSHDATA4.
Nick ODell
CC BY-SA 3.0
2016-04-26T19:37:11.303Z
2016-04-26T19:37:11.303Z
inersha
<p>Trying to parse scriptPubKeys and get the individual opcodes. My question is: How would you identify the "bytes to push" values?</p>

<p>Here's an example of the typical scriptPubKey:</p>

<pre><code>  76       A9             14
OP_DUP OP_HASH160    Bytes to push

89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG
</code></pre>

<p><a href="https://en.bitcoin.it/wiki/Script#Scripts" rel="nofollow">bitcoin.it/wiki</a></p>

<p>Does "bytes to push" only occur after specific opcodes? Or is it that anything that doesn't correspond to an opcode is interpreted as indicating the upcoming number of bytes to push on to the stack?</p>

<p><em>Note: Basically any tips/advice on parsing the locking script would be handy.</em></p>

<script>
How is "bytes to push" distinguishable in the scriptPubKey?
inersha
# How is "bytes to push" distinguishable in the scriptPubKey?

(Asked by: username_0 on 2016-04-26)

Trying to parse scriptPubKeys and get the individual opcodes. My question is: How would you identify the "bytes to push" values?
Here's an example of the typical scriptPubKey:
  76       A9             14
OP_DUP OP_HASH160    Bytes to push

89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG

bitcoin.it/wiki
Does "bytes to push" only occur after specific opcodes? Or is it that anything that doesn't correspond to an opcode is interpreted as indicating the upcoming number of bytes to push on to the stack?
Note: Basically any tips/advice on parsing the locking script would be handy.

**Tags:** script


---

## 1 answers

### Answer by username_0 on 2016-04-26. Score: 3

It appears that anything between **0x01 - 0x4b** in the scriptPubKey signifies the number of bytes to be pushed on to the stack.

> **Comments:**
> **username_1**: Right. That's the most common type of push data opcode. However, there's also OP_PUSHDATA1, OP_PUSHDATA2, and (currently useless) OP_PUSHDATA4.  

---

