scriptHash.input.check - should tolerate 1 field in scriptSig if it's P2WSH or P2WPKH
This commit is contained in:
parent
c5541c8f96
commit
fff9319fa4
2 changed files with 6 additions and 3 deletions
|
@ -5,7 +5,7 @@ var typeforce = require('typeforce')
|
||||||
|
|
||||||
function check (script, allowIncomplete) {
|
function check (script, allowIncomplete) {
|
||||||
var chunks = bscript.decompile(script)
|
var chunks = bscript.decompile(script)
|
||||||
if (chunks.length < 2) return false
|
if (chunks.length < 1) return false
|
||||||
|
|
||||||
var lastChunk = chunks[chunks.length - 1]
|
var lastChunk = chunks[chunks.length - 1]
|
||||||
if (!Buffer.isBuffer(lastChunk)) return false
|
if (!Buffer.isBuffer(lastChunk)) return false
|
||||||
|
@ -13,7 +13,7 @@ function check (script, allowIncomplete) {
|
||||||
var scriptSigChunks = chunks.slice(0, -1)
|
var scriptSigChunks = chunks.slice(0, -1)
|
||||||
var redeemScriptChunks = bscript.decompile(lastChunk)
|
var redeemScriptChunks = bscript.decompile(lastChunk)
|
||||||
|
|
||||||
// is redeemScript a valid script?
|
// is redeemScript a valid script?git
|
||||||
if (redeemScriptChunks.length === 0) return false
|
if (redeemScriptChunks.length === 0) return false
|
||||||
|
|
||||||
// is redeemScriptSig push only?
|
// is redeemScriptSig push only?
|
||||||
|
@ -21,6 +21,10 @@ function check (script, allowIncomplete) {
|
||||||
|
|
||||||
var inputType = bscript.classifyInput(scriptSigChunks, allowIncomplete)
|
var inputType = bscript.classifyInput(scriptSigChunks, allowIncomplete)
|
||||||
var outputType = bscript.classifyOutput(redeemScriptChunks)
|
var outputType = bscript.classifyOutput(redeemScriptChunks)
|
||||||
|
if (chunks.length === 1 && (outputType === bscript.types.P2WSH || outputType === bscript.types.P2WPKH)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
return inputType === outputType
|
return inputType === outputType
|
||||||
}
|
}
|
||||||
check.toJSON = function () { return 'scriptHash input' }
|
check.toJSON = function () { return 'scriptHash input' }
|
||||||
|
|
|
@ -346,7 +346,6 @@ describe('TransactionBuilder', function () {
|
||||||
it('does not throw if buildIncomplete', function () {
|
it('does not throw if buildIncomplete', function () {
|
||||||
var txb
|
var txb
|
||||||
if (f.txHex) {
|
if (f.txHex) {
|
||||||
console.log(f.txHex)
|
|
||||||
txb = TransactionBuilder.fromTransaction(Transaction.fromHex(f.txHex))
|
txb = TransactionBuilder.fromTransaction(Transaction.fromHex(f.txHex))
|
||||||
} else {
|
} else {
|
||||||
txb = construct(f)
|
txb = construct(f)
|
||||||
|
|
Loading…
Add table
Reference in a new issue