Browse Source

Merge pull request #360 from bitcoinjs/scriptfix

isScriptHashInput logic fix
hk-custom-address
Daniel Cousens 10 years ago
parent
commit
e0b1aa843e
  1. 1
      src/script.js
  2. 8
      src/scripts.js
  3. 4
      test/fixtures/scripts.json

1
src/script.js

@ -29,7 +29,6 @@ Script.fromASM = function(asm) {
Script.fromBuffer = function(buffer) {
var chunks = []
var i = 0
while (i < buffer.length) {

8
src/scripts.js

@ -70,7 +70,13 @@ function isScriptHashInput(script, allowIncomplete) {
if (!Buffer.isBuffer(lastChunk)) return false
var scriptSig = Script.fromChunks(script.chunks.slice(0, -1))
var scriptPubKey = Script.fromBuffer(lastChunk)
var scriptPubKey
try {
scriptPubKey = Script.fromBuffer(lastChunk)
} catch (e) {
return false
}
return classifyInput(scriptSig, allowIncomplete) === classifyOutput(scriptPubKey)
}

4
test/fixtures/scripts.json

@ -111,6 +111,10 @@
{
"description": "redeemScript not data",
"scriptSig": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501 OP_RESERVED"
},
{
"description": "signature forms invalid script",
"scriptSig": "OP_0 3045022100e12b17b3a4c80c401a1687487bd2bafee9e5f1f8f1ffc6180ce186672ad7b43a02205e316d1e5e71822f5ef301b694e578fa9c94af4f5f098c952c833f4691307f4e01"
}
],
"isPubKeyInput": [

Loading…
Cancel
Save