|
@ -253,25 +253,28 @@ TransactionBuilder.prototype.sign = function(index, privKey, redeemScript, hashT |
|
|
hash = this.tx.hashForSignature(index, prevOutScript, hashType) |
|
|
hash = this.tx.hashForSignature(index, prevOutScript, hashType) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.prevOutScripts[index] = prevOutScript |
|
|
var input = this.signatures[index] |
|
|
this.prevOutTypes[index] = prevOutType |
|
|
if (!input) { |
|
|
|
|
|
input = { |
|
|
if (!(index in this.signatures)) { |
|
|
|
|
|
this.signatures[index] = { |
|
|
|
|
|
hashType: hashType, |
|
|
hashType: hashType, |
|
|
pubKeys: [], |
|
|
pubKeys: [], |
|
|
redeemScript: redeemScript, |
|
|
redeemScript: redeemScript, |
|
|
scriptType: scriptType, |
|
|
scriptType: scriptType, |
|
|
signatures: [] |
|
|
signatures: [] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.signatures[index] = input |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
assert.equal(scriptType, 'multisig', scriptType + ' doesn\'t support multiple signatures') |
|
|
assert.equal(scriptType, 'multisig', scriptType + ' doesn\'t support multiple signatures') |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var input = this.signatures[index] |
|
|
|
|
|
assert.equal(input.hashType, hashType, 'Inconsistent hashType') |
|
|
assert.equal(input.hashType, hashType, 'Inconsistent hashType') |
|
|
assert.deepEqual(input.redeemScript, redeemScript, 'Inconsistent redeemScript') |
|
|
assert.deepEqual(input.redeemScript, redeemScript, 'Inconsistent redeemScript') |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.prevOutScripts[index] = prevOutScript |
|
|
|
|
|
this.prevOutTypes[index] = prevOutType |
|
|
|
|
|
|
|
|
|
|
|
// TODO: order signatures for multisig, enforce m < n
|
|
|
var signature = privKey.sign(hash) |
|
|
var signature = privKey.sign(hash) |
|
|
input.pubKeys.push(privKey.pub) |
|
|
input.pubKeys.push(privKey.pub) |
|
|
input.signatures.push(signature) |
|
|
input.signatures.push(signature) |
|
|