Skip to content

Commit 529975b

Browse files
author
Stephan February
committed
Fixed script-size bug
- Script-size limit of 10k bytes should only be done for P2SH scripts with STRICTENC flag.
1 parent 0c8dc23 commit 529975b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/org/twostack/bitcoin4j/script/Interpreter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,8 +1108,11 @@ public void correctlySpends( Script scriptSig, Script scriptPubKey, Transaction
11081108
} catch (ProtocolException | IOException e) {
11091109
throw new RuntimeException(e); // Should not happen unless we were given a totally broken transaction.
11101110
}
1111-
if (scriptSig.getProgram().length > 10000 || scriptPubKey.getProgram().length > 10000)
1112-
throw new ScriptException(ScriptError.SCRIPT_ERR_SCRIPT_SIZE, "Script larger than 10,000 bytes");
1111+
1112+
if (verifyFlags.contains(VerifyFlag.P2SH) && verifyFlags.contains(VerifyFlag.STRICTENC)) {
1113+
if (scriptSig.getProgram().length > 10000 || scriptPubKey.getProgram().length > 10000)
1114+
throw new ScriptException(ScriptError.SCRIPT_ERR_SCRIPT_SIZE, "Script larger than 10,000 bytes");
1115+
}
11131116

11141117
LinkedList<byte[]> stack = new LinkedList<byte[]>();
11151118
LinkedList<byte[]> p2shStack = null;

0 commit comments

Comments
 (0)