scriptHash.input.check - should tolerate 1 field in scriptSig if it's P2WSH or P2WPKH

This commit is contained in:
Thomas Kerin 2017-01-03 20:09:58 +01:00 committed by Daniel Cousens
parent c5541c8f96
commit fff9319fa4
2 changed files with 6 additions and 3 deletions

View file

@ -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,7 +13,7 @@ function check (script, allowIncomplete) {
var scriptSigChunks = chunks.slice(0, -1)
var redeemScriptChunks = bscript.decompile(lastChunk)
// is redeemScript a valid script?
// is redeemScript a valid script?git
if (redeemScriptChunks.length === 0) return false
// is redeemScriptSig push only?
@ -21,6 +21,10 @@ function check (script, allowIncomplete) {
var inputType = bscript.classifyInput(scriptSigChunks, allowIncomplete)
var outputType = bscript.classifyOutput(redeemScriptChunks)
if (chunks.length === 1 && (outputType === bscript.types.P2WSH || outputType === bscript.types.P2WPKH)) {
return true
}
return inputType === outputType
}
check.toJSON = function () { return 'scriptHash input' }

View file

@ -346,7 +346,6 @@ describe('TransactionBuilder', function () {
it('does not throw if buildIncomplete', function () {
var txb
if (f.txHex) {
console.log(f.txHex)
txb = TransactionBuilder.fromTransaction(Transaction.fromHex(f.txHex))
} else {
txb = construct(f)