<p>In what documentation? I believe you are talking about how <code>rust-bitcoin</code> refers to the OPs <code>&gt; OP_FALSE</code> and <code>&lt; OP_PUSHDATA1</code> and will answer as such.</p>
<p>There are multiple OP codes pushing bytes to the stack, defined as integers.</p>
<h3>Special case: pushing small integers</h3>
<p>There are dedicating OP codes for pushing integers from <code>-1</code> to <code>16</code> (named <a href="https://github.com/bitcoin/bitcoin/blob/e31af1065e8a4a9dbb294e980047a135d4233962/src/script/script.h#L68-L91" rel="nofollow noreferrer"><code>OP_1NEGATE</code>, <code>OP_0</code> and <code>OP_1</code> to <code>OP_16</code> and valued <code>0x4f</code>, <code>Ox00</code> and <code>0x51</code> to <code>0x60</code></a>).</p>
<p>They are used for instance for (smallish) multisigs as it saves you 1 byte per number pushed compared to using a &quot;real&quot; push opcode.</p>
<h3>&quot;<code>PUSHBYTES</code>&quot;: pushing small byte arrays</h3>
<p>The (not named in the reference implementation) <a href="https://github.com/bitcoin/bitcoin/blob/master/src/script/script.h#L68-L70" rel="nofollow noreferrer">OP codes valued from <code>0x01</code> to <code>0x4b</code></a> allow to <a href="https://github.com/bitcoin/bitcoin/blob/e31af1065e8a4a9dbb294e980047a135d4233962/src/script/script.cpp#L296-L303" rel="nofollow noreferrer">push from 1 (<code>0x01</code>) to 75 (<code>0x4b</code>) bytes to the stack</a>.</p>
<p>They are commonly used to push pubkeys and signatures.</p>
<h3><code>PUSHDATA</code>: pushing byte arrays</h3>
<p>The <a href="https://github.com/bitcoin/bitcoin/blob/e31af1065e8a4a9dbb294e980047a135d4233962/src/script/script.h#L70-L72" rel="nofollow noreferrer"><code>PUSHDATA1</code>, <code>PUSHDATA2</code> and <code>PUSHDATA4</code> (<code>0x4c</code>, <code>0x4d</code> and <code>0x4e</code>)</a> operands are used to push a byte array to the stack which size is defined as a <a href="https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer" rel="nofollow noreferrer">variable-length integer</a> .</p>
<h3>Further: too many encodings!</h3>
<p>This flexibility of encoding introduced malleability in the <code>scriptSig</code>, which was not protected by the signature (which it carries).<br />
<a href="https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki#Push_operators" rel="nofollow noreferrer">BIP62</a> proposed to restrict this encoding to avoid possible malleation.</p>

CC BY-SA 4.0
2021-01-24T19:18:29.887Z
2022-06-27T18:24:24.213Z
2022-06-27T18:24:24.213Z
Antoine Poinsot
<p>In some documentation about Script we sometimes have to use <code>OP_PUSHBYTESx</code> or <code>OP_PUSHDATAx</code> to indicate that some number of bytes will be an element to read.<br />
They seem to do the same thing so is there a reason they have different names ?</p>

CC BY-SA 4.0
2021-01-24T18:53:29.643Z
In what documentation ? I believe you are talking about how `rust-bitcoin` refers to the OPs `> OP_FALSE` and `< OP_PUSHDATA1`
Antoine Poinsot
CC BY-SA 4.0
2021-01-24T18:57:45.167Z
When you click on "Display Script" on this page https://tbtc.bitaps.com/3dd3d1ec850769aac2359efd642ebe292e60502fc17dc33d7be1bc3cc6678621/mvEg6eZ3sUApodedYQrkpEPMMALsr1K1k1 and https://en.bitcoin.it/wiki/Script
Saxtheowl
CC BY-SA 4.0
2021-01-24T18:58:27.587Z
Ok; it's what rust-bitcoin does too. Writing an answer.
Antoine Poinsot
<script><development><opcodes>
Is there a difference between OP_PUSHBYTES and OP_PUSHDATA
Saxtheowl
# Is there a difference between OP_PUSHBYTES and OP_PUSHDATA

(Asked by: username_0 on 2021-01-24)

In some documentation about Script we sometimes have to use `OP_PUSHBYTESx` or `OP_PUSHDATAx` to indicate that some number of bytes will be an element to read.  
They seem to do the same thing so is there a reason they have different names ?

**Tags:** script, development, opcodes

> **Comments:**
> **username_1**: In what documentation ? I believe you are talking about how `rust-bitcoin` refers to the OPs `> OP_FALSE` and `< OP_PUSHDATA1`  
> **username_0**: When you click on "Display Script" on this page https://tbtc.bitaps.com/3dd3d1ec850769aac2359efd642ebe292e60502fc17dc33d7be1bc3cc6678621/mvEg6eZ3sUApodedYQrkpEPMMALsr1K1k1 and https://en.bitcoin.it/wiki/Script  
> **username_1**: Ok; it's what rust-bitcoin does too. Writing an answer.  

---

## 1 answers

### Answer by username_1 on 2021-01-24. Score: 4 | Accepted answer

In what documentation? I believe you are talking about how `rust-bitcoin` refers to the OPs `> OP_FALSE` and `< OP_PUSHDATA1` and will answer as such.

There are multiple OP codes pushing bytes to the stack, defined as integers.

### Special case: pushing small integers

There are dedicating OP codes for pushing integers from `-1` to `16` (named [`OP_1NEGATE`, `OP_0` and `OP_1` to `OP_16` and valued `0x4f`, `Ox00` and `0x51` to `0x60`](https://github.com/bitcoin/bitcoin/blob/e31af1065e8a4a9dbb294e980047a135d4233962/src/script/script.h#L68-L91)).

They are used for instance for (smallish) multisigs as it saves you 1 byte per number pushed compared to using a "real" push opcode.

### "`PUSHBYTES`": pushing small byte arrays

The (not named in the reference implementation) [OP codes valued from `0x01` to `0x4b`](https://github.com/bitcoin/bitcoin/blob/master/src/script/script.h#L68-L70) allow to [push from 1 (`0x01`) to 75 (`0x4b`) bytes to the stack](https://github.com/bitcoin/bitcoin/blob/e31af1065e8a4a9dbb294e980047a135d4233962/src/script/script.cpp#L296-L303).

They are commonly used to push pubkeys and signatures.

### `PUSHDATA`: pushing byte arrays

The [`PUSHDATA1`, `PUSHDATA2` and `PUSHDATA4` (`0x4c`, `0x4d` and `0x4e`)](https://github.com/bitcoin/bitcoin/blob/e31af1065e8a4a9dbb294e980047a135d4233962/src/script/script.h#L70-L72) operands are used to push a byte array to the stack which size is defined as a [variable-length integer](https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer) .

### Further: too many encodings!

This flexibility of encoding introduced malleability in the `scriptSig`, which was not protected by the signature (which it carries).  
[BIP62](https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki#Push_operators) proposed to restrict this encoding to avoid possible malleation.


---

