diff --git a/src/templates/scripthash/input.js b/src/templates/scripthash/input.js index ce2bef7..04e3874 100644 --- a/src/templates/scripthash/input.js +++ b/src/templates/scripthash/input.js @@ -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' } diff --git a/test/transaction_builder.js b/test/transaction_builder.js index a877c0d..120876a 100644 --- a/test/transaction_builder.js +++ b/test/transaction_builder.js @@ -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)