bscript.compie - minimal encoding of -1 stack element

This commit is contained in:
Thomas Kerin 2016-12-15 11:50:58 +01:00 committed by Daniel Cousens
parent ff68116ee9
commit 8552867695
2 changed files with 14 additions and 1 deletions

View file

@ -39,7 +39,7 @@ function compile (chunks) {
// data chunk
if (Buffer.isBuffer(chunk)) {
// adhere to BIP62.3, minimal push policy
if (chunk.length === 1 && chunk[0] >= 1 && chunk[0] <= 16) {
if (chunk.length === 1 && (chunk[0] === 0x81 || chunk[0] >= 1 && chunk[0] <= 16)) {
return accum + 1
}
@ -64,6 +64,12 @@ function compile (chunks) {
return
}
if (chunk.length === 1 && chunk[0] === 0x81) {
buffer.writeUInt8(OPS.OP_1NEGATE, offset)
offset += 1
return
}
offset += bufferutils.writePushDataInt(buffer, chunk.length, offset)
chunk.copy(buffer, offset)