TransactionBuilder: fixMultisigOrder only works if a redeemScript exists

This commit is contained in:
Daniel Cousens 2016-10-12 12:13:27 +11:00 committed by Daniel Cousens
parent 1ff64d207e
commit 6056e7913e

View file

@ -213,17 +213,12 @@ function prepareInput (input, kpPubKey, redeemScript, hashType) {
} }
function fixMultisigOrder (input, transaction, vin) { function fixMultisigOrder (input, transaction, vin) {
var hashScriptType = input.redeemScriptType || input.prevOutType if (input.redeemScriptType !== 'multisig' || !input.redeemScript) return
if (hashScriptType !== 'multisig') return
var hashScript = input.redeemScript || input.prevOutScript
if (!hashScript) return
if (!input.pubKeys) return
if (input.pubKeys.length === input.signatures.length) return if (input.pubKeys.length === input.signatures.length) return
var unmatched = input.signatures.concat() var unmatched = input.signatures.concat()
var hashType = input.hashType || Transaction.SIGHASH_ALL var hashType = input.hashType || Transaction.SIGHASH_ALL
var hash = transaction.hashForSignature(vin, hashScript, hashType) var hash = transaction.hashForSignature(vin, input.redeemScript, hashType)
input.signatures = input.pubKeys.map(function (pubKey, y) { input.signatures = input.pubKeys.map(function (pubKey, y) {
var keyPair = ECPair.fromPublicKeyBuffer(pubKey) var keyPair = ECPair.fromPublicKeyBuffer(pubKey)