Merge pull request #942 from bitcoinjs/stackme
enforce decodeStack receives a stack array
This commit is contained in:
commit
42407e2c41
7 changed files with 14 additions and 8 deletions
|
@ -53,6 +53,7 @@ function encode (signatures, scriptPubKey) {
|
|||
}
|
||||
|
||||
function decodeStack (stack, allowIncomplete) {
|
||||
typeforce(typeforce.Array, stack)
|
||||
typeforce(check, stack, allowIncomplete)
|
||||
return stack.slice(1)
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ function encode (signature) {
|
|||
}
|
||||
|
||||
function decodeStack (stack) {
|
||||
typeforce(typeforce.Array, stack)
|
||||
typeforce(check, stack)
|
||||
return stack[0]
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ function encode (signature, pubKey) {
|
|||
}
|
||||
|
||||
function decodeStack (stack) {
|
||||
typeforce(typeforce.Array, stack)
|
||||
typeforce(check, stack)
|
||||
|
||||
return {
|
||||
|
|
|
@ -59,6 +59,7 @@ function encode (redeemScriptSig, redeemScript) {
|
|||
}
|
||||
|
||||
function decodeStack (stack) {
|
||||
typeforce(typeforce.Array, stack)
|
||||
typeforce(check, stack)
|
||||
|
||||
return {
|
||||
|
|
|
@ -29,6 +29,7 @@ function encodeStack (signature, pubKey) {
|
|||
}
|
||||
|
||||
function decodeStack (stack) {
|
||||
typeforce(typeforce.Array, stack)
|
||||
typeforce(check, stack)
|
||||
|
||||
return {
|
||||
|
|
|
@ -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]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -500,10 +500,10 @@ describe('TransactionBuilder', function () {
|
|||
'194a565cd6aa4cc38b8eaffa343402201c5b4b61d73fa38e49c1ee68cc0e6dfd2f5dae453dd86eb142e87a' +
|
||||
'0bafb1bc8401210283409659355b6d1cc3c32decd5d561abaac86c37a353b52895a5e6c196d6f44800000000'
|
||||
var txb = TransactionBuilder.fromTransaction(Transaction.fromHex(rawtx))
|
||||
txb.inputs[0].value = 81530
|
||||
txb.inputs[1].value = 81530
|
||||
txb.inputs[2].value = 88920
|
||||
txb.inputs[3].value = 88920
|
||||
txb.inputs[0].value = 241530
|
||||
txb.inputs[1].value = 241530
|
||||
txb.inputs[2].value = 248920
|
||||
txb.inputs[3].value = 248920
|
||||
|
||||
assert.throws(function () {
|
||||
txb.build()
|
||||
|
|
Loading…
Reference in a new issue