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()

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

1 Answer 1


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<valtype> 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)
+    if (script.size() > 20000)
+        return false;
  • the second link has a typo and doesn't work.
    – bordalix
    Aug 17, 2022 at 5:41
  • @bordalix Thanks, fixed! Aug 17, 2022 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.