From b1daff1108a2e65884b98bbe898eee5f85d0f0c0 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Mon, 14 Nov 2016 16:03:06 +1100 Subject: [PATCH] script: use isPushOnly internally --- src/script.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/script.js b/src/script.js index 114f728..d8785f0 100644 --- a/src/script.js +++ b/src/script.js @@ -21,8 +21,12 @@ function isOPInt (value) { (value === OPS.OP_1NEGATE) } -function pushOnlyChunk (value) { - return types.oneOf(Buffer, isOPInt) +function isPushOnlyChunk (value) { + return types.Buffer(value) || isOPInt(value) +} + +function isPushOnly (value) { + return types.Array(value) && value.every(isPushOnlyChunk) } function compile (chunks) { @@ -143,7 +147,7 @@ function fromASM (asm) { function decompilePushOnly (script) { var chunks = decompile(script) - typeforce([pushOnlyChunk], chunks) + typeforce(isPushOnly, chunks) return chunks.map(function (op) { if (Buffer.isBuffer(op)) return op @@ -154,7 +158,7 @@ function decompilePushOnly (script) { } function compilePushOnly (chunks) { - typeforce([pushOnlyChunk], chunks) + typeforce(isPushOnly, chunks) return compile(chunks) }