script: use isPushOnly internally
This commit is contained in:
parent
8df1b45699
commit
b1daff1108
1 changed files with 8 additions and 4 deletions
|
@ -21,8 +21,12 @@ function isOPInt (value) {
|
||||||
(value === OPS.OP_1NEGATE)
|
(value === OPS.OP_1NEGATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
function pushOnlyChunk (value) {
|
function isPushOnlyChunk (value) {
|
||||||
return types.oneOf(Buffer, isOPInt)
|
return types.Buffer(value) || isOPInt(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPushOnly (value) {
|
||||||
|
return types.Array(value) && value.every(isPushOnlyChunk)
|
||||||
}
|
}
|
||||||
|
|
||||||
function compile (chunks) {
|
function compile (chunks) {
|
||||||
|
@ -143,7 +147,7 @@ function fromASM (asm) {
|
||||||
|
|
||||||
function decompilePushOnly (script) {
|
function decompilePushOnly (script) {
|
||||||
var chunks = decompile(script)
|
var chunks = decompile(script)
|
||||||
typeforce([pushOnlyChunk], chunks)
|
typeforce(isPushOnly, chunks)
|
||||||
|
|
||||||
return chunks.map(function (op) {
|
return chunks.map(function (op) {
|
||||||
if (Buffer.isBuffer(op)) return op
|
if (Buffer.isBuffer(op)) return op
|
||||||
|
@ -154,7 +158,7 @@ function decompilePushOnly (script) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function compilePushOnly (chunks) {
|
function compilePushOnly (chunks) {
|
||||||
typeforce([pushOnlyChunk], chunks)
|
typeforce(isPushOnly, chunks)
|
||||||
return compile(chunks)
|
return compile(chunks)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue