scriptHash return true for chunks.length=1 so long as its witness

This commit is contained in:
Thomas Kerin 2017-01-21 01:05:05 +01:00 committed by Daniel Cousens
parent 1edfd30425
commit 793939dc8c
6 changed files with 2 additions and 66 deletions

View file

@ -22,11 +22,8 @@ function check (script, allowIncomplete) {
var inputType = bscript.classifyInput(scriptSigChunks, allowIncomplete)
var outputType = bscript.classifyOutput(redeemScriptChunks)
if (chunks.length === 1) {
if (outputType === bscript.types.P2WSH || outputType === bscript.types.P2WPKH) {
return true
}
return outputType === bscript.types.P2WSH || outputType === bscript.types.P2WPKH
}
return inputType === outputType
}
check.toJSON = function () { return 'scriptHash input' }

View file

@ -384,7 +384,6 @@ Transaction.prototype.hashForWitnessV0 = function (inIndex, prevOutScript, value
writeSlice(hashOutputs)
writeUInt32(this.locktime)
writeUInt32(hashType)
return bcrypto.hash256(tbuffer)
}

View file

@ -302,7 +302,7 @@ function prepareInput (input, kpPubKey, redeemScript, witnessValue, witnessScrip
p2sh = true
signType = p2shType = expanded.scriptType
signScript = redeemScript
witness = signType === bscript.types.P2WPKH
} else if (witnessScript) {
witnessScriptHash = bcrypto.sha256(witnessScript)
checkP2WSHInput(input, witnessScriptHash)
@ -315,7 +315,6 @@ function prepareInput (input, kpPubKey, redeemScript, witnessValue, witnessScrip
witness = p2wsh = true
signType = witnessType = expanded.scriptType
signScript = witnessScript
} else if (input.prevOutType) {
// embedded scripts are not possible without a redeemScript
if (input.prevOutType === scriptTypes.P2SH ||
@ -657,14 +656,12 @@ TransactionBuilder.prototype.sign = function (vin, keyPair, redeemScript, hashTy
}
// ready to sign
var signatureHash
if (input.witness) {
signatureHash = this.tx.hashForWitnessV0(vin, input.signScript, witnessValue, hashType)
} else {
signatureHash = this.tx.hashForSignature(vin, input.signScript, hashType)
}
// enforce in order signing of public keys
var signed = input.pubKeys.some(function (pubKey, i) {
if (!kpPubKey.equals(pubKey)) return false