The current Bitcoin client filters out any pushes beyond a certain size.

static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes
if (vchPushValue.size() > MAX_SCRIPT_ELEMENT_SIZE)
    return set_error(serror, SCRIPT_ERR_PUSH_SIZE);

What's the point of doing this? Does it prevent an attack?

How difficult would it be to change this? Would increasing this constant require a soft/hard fork?

1 Answer 1


This limit is long standing and unexplained, but it didn't always have that particular name. It was dubbed MAX_SCRIPT_ELEMENT_SIZE in this commit, where previously it was just a magic number in script.cpp. The restriction is found throughout the entire history from master until 0.3.22, but is missing from the 0.1.3 source. You could speculate that it was intended to be an anti-DoS restriction, but these releases retained OP_CAT which would have allowed for nearly infinite sized stack elements regardless of the sizes of data pushes.

The 520 byte push size severely stunts Pay to Script Hash, as the entire script is pushed onto the stack it must respect the push limit. For a P2SH multisignature script this sets the upper limit to n-of-15, any larger and it would be unspendable due to 520 byte consensus rule.

Increasing this limit would be a hard forking change.

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.