scripthash.input.check / decode: allow situation where chunks length ==1, and don't attempt to classifyInput if witness
This commit is contained in:
parent
fdcd277ba9
commit
244c3d4f18
@ -5,7 +5,7 @@ var typeforce = require('typeforce')
|
||||
|
||||
function check (script, allowIncomplete) {
|
||||
var chunks = bscript.decompile(script)
|
||||
if (chunks.length < 2) return false
|
||||
if (chunks.length < 1) return false
|
||||
|
||||
var lastChunk = chunks[chunks.length - 1]
|
||||
if (!Buffer.isBuffer(lastChunk)) return false
|
||||
@ -13,11 +13,12 @@ function check (script, allowIncomplete) {
|
||||
var scriptSigChunks = chunks.slice(0, -1)
|
||||
var redeemScriptChunks = bscript.decompile(lastChunk)
|
||||
|
||||
// is redeemScript a valid script?
|
||||
if (redeemScriptChunks.length === 0) return false
|
||||
var outputType = bscript.classifyOutput(redeemScriptChunks)
|
||||
if (outputType === bscript.types.P2WSH || outputType === bscript.types.P2WPKH) {
|
||||
return true
|
||||
}
|
||||
|
||||
var inputType = bscript.classifyInput(scriptSigChunks, allowIncomplete)
|
||||
var outputType = bscript.classifyOutput(redeemScriptChunks)
|
||||
return inputType === outputType
|
||||
}
|
||||
check.toJSON = function () { return 'scriptHash input' }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user