<p>It was introduced in v0.3.7, dated July 31 2010, in commit <a href="https://github.com/bitcoin/bitcoin/commit/73aa262647ff9948eaf95e83236ec323347e95d0" rel="nofollow noreferrer">73aa262647</a>, titled &quot;fixed segfault in bignum.h, additional security limits, refactoring -- version 0.3.7&quot;:</p>
<pre><code>     vector&lt;valtype&gt; altstack;
-    if (pvStackRet)
-        pvStackRet-&gt;clear();
-    if (script.size() &gt; 20000)
+    if (script.size() &gt; 10000)
         return false;
+    int nOpCount = 0;
</code></pre>
<p>It apparently replaced an older 20000-byte limit (TIL!), which was introduced in v0.3.6, dated a day earlier, in commit <a href="https://github.com/bitcoin/bitcoin/commit/a75560d828464c3f1138f52cf247e956fc8f937d" rel="nofollow noreferrer">a75560d828</a>, titled &quot;reverted makefile.unix wx-config -- version 0.3.6&quot;:</p>
<pre><code>     if (pvStackRet)
         pvStackRet-&gt;clear();
+    if (script.size() &gt; 20000)
+        return false;
</code></pre>

CC BY-SA 4.0
2022-08-16T15:20:49.863Z
2022-08-17T12:16:29.830Z
2022-08-17T12:16:29.830Z
Pieter Wuille
<p>The file <code>src/script/script.h</code> defines a <code>MAX_SCRIPT_SIZE</code> of 10,000 B. Among other instances, the <code>MAX_SCRIPT_SIZE</code> is used in the <code>IsUnspendable()</code> check, which allows us to avoid adding outputs with excessively long <code>scriptPubKeys</code> to the UTXO set. It also causes input validation to fail if a <code>scriptSig</code> exceeds the permitted length.</p>
<p><a href="https://i.sstatic.net/AgRV6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/AgRV6.png" alt="A code snippet from the Bitcoin Core code base showing the use of MAX_SCRIPT_SIZE in IsUnspendable()" /></a></p>
<p>In the context of talking about this limit, I was asked and didn't know: &quot;When was the <code>MAX_SCRIPT_SIZE</code> introduced?&quot;</p>

<bitcoin-core-development><transaction-verification><consensus><history>
When was the 10,000 B limit for scripts introduced?
Murch
# When was the 10,000 B limit for scripts introduced?

(Asked by: username_0 on 2022-08-16)

The file `src/script/script.h` defines a `MAX_SCRIPT_SIZE` of 10,000 B. Among other instances, the `MAX_SCRIPT_SIZE` is used in the `IsUnspendable()` check, which allows us to avoid adding outputs with excessively long `scriptPubKeys` to the UTXO set. It also causes input validation to fail if a `scriptSig` exceeds the permitted length.

[![A code snippet from the Bitcoin Core code base showing the use of MAX_SCRIPT_SIZE in IsUnspendable()](https://i.sstatic.net/AgRV6.png)](https://i.sstatic.net/AgRV6.png)

In the context of talking about this limit, I was asked and didn't know: "When was the `MAX_SCRIPT_SIZE` introduced?"

**Tags:** bitcoin-core-development, transaction-verification, consensus, history


---

## 1 answers

### Answer by username_1 on 2022-08-16. Score: 5 | Accepted answer

It was introduced in v0.3.7, dated July 31 2010, in commit 73aa262647, titled "fixed segfault in bignum.h, additional security limits, refactoring -- version 0.3.7":
     vector altstack;
-    if (pvStackRet)
-        pvStackRet->clear();
-    if (script.size() > 20000)
+    if (script.size() > 10000)
         return false;
+    int nOpCount = 0;

It apparently replaced an older 20000-byte limit (TIL!), which was introduced in v0.3.6, dated a day earlier, in commit a75560d828, titled "reverted makefile.unix wx-config -- version 0.3.6":
     if (pvStackRet)
         pvStackRet->clear();
+    if (script.size() > 20000)
+        return false;


---

