3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-13 10:45:51 +00:00
dexX7 a3d378bae6
Ensure "OP_0" and "false" have the same represenstation on stack
During the script execution via `executeScript()` certain operations
add boolean values to the stack.

Boolean values, which are added to the stack as result, are represented
as follows in Bitcoin Core:

- `true`: as vector with one element: `[1]`
- `false`: as empty vector with zero elements: `[]`

See:

- 48efbdbe98/src/script/interpreter.cpp (L244)
- 48efbdbe98/src/script/interpreter.cpp (L246)

However, in BitcoinJ the representation of `false` differs in some
cases, where it is represented as Byte array with one element, which
is zero: `[0]`

See:

- `OP_EQUAL`: 5dcf643975/core/src/main/java/org/bitcoinj/script/Script.java (L1025)
- `OP_CHECKSIG`: 5dcf643975/core/src/main/java/org/bitcoinj/script/Script.java (L1304)
- `OP_CHECKMULTISIG`: 5dcf643975/core/src/main/java/org/bitcoinj/script/Script.java (L1381)

At minimum this has an impact on the behavior of `OP_EQUAL` and
`OP_EQUALVERIFY`, when comparing something with `OP_FALSE`/`OP_0`.

This commit attemps to fix the issue, to mirror the verification
behavior of Bitcoin Core, by adding empty Byte arrays to the stack,
instead of Byte arrays with `0`.
2015-09-30 00:30:29 +02:00
..