enforce decodeStack receives a stack array

This commit is contained in:
Daniel Cousens 2017-11-30 15:34:30 +11:00
parent 1662a391e3
commit 8d688c39a6
6 changed files with 10 additions and 4 deletions

View file

@ -53,6 +53,7 @@ function encode (signatures, scriptPubKey) {
}
function decodeStack (stack, allowIncomplete) {
typeforce(typeforce.Array, stack)
typeforce(check, stack, allowIncomplete)
return stack.slice(1)
}

View file

@ -21,6 +21,7 @@ function encode (signature) {
}
function decodeStack (stack) {
typeforce(typeforce.Array, stack)
typeforce(check, stack)
return stack[0]
}

View file

@ -29,6 +29,7 @@ function encode (signature, pubKey) {
}
function decodeStack (stack) {
typeforce(typeforce.Array, stack)
typeforce(check, stack)
return {

View file

@ -59,6 +59,7 @@ function encode (redeemScriptSig, redeemScript) {
}
function decodeStack (stack) {
typeforce(typeforce.Array, stack)
typeforce(check, stack)
return {

View file

@ -29,6 +29,7 @@ function encodeStack (signature, pubKey) {
}
function decodeStack (stack) {
typeforce(typeforce.Array, stack)
typeforce(check, stack)
return {

View file

@ -48,11 +48,12 @@ function encodeStack (witnessData, witnessScript) {
return [].concat(witnessData, witnessScript)
}
function decodeStack (chunks) {
typeforce(check, chunks)
function decodeStack (stack) {
typeforce(typeforce.Array, stack)
typeforce(check, stack)
return {
witnessData: chunks.slice(0, -1),
witnessScript: chunks[chunks.length - 1]
witnessData: stack.slice(0, -1),
witnessScript: stack[stack.length - 1]
}
}