TxBuilder: hashtype only relevant to things we can sign
This commit is contained in:
parent
4ef2c19d71
commit
73bf8a42ea
1 changed files with 12 additions and 15 deletions
|
@ -268,26 +268,23 @@ TransactionBuilder.prototype.sign = function(index, privKey, redeemScript, hashT
|
||||||
hashType = hashType || Transaction.SIGHASH_ALL
|
hashType = hashType || Transaction.SIGHASH_ALL
|
||||||
|
|
||||||
var input = this.inputs[index]
|
var input = this.inputs[index]
|
||||||
|
var canSign = input.hashType &&
|
||||||
|
input.prevOutScript &&
|
||||||
|
input.prevOutType &&
|
||||||
|
input.pubKeys &&
|
||||||
|
input.scriptType &&
|
||||||
|
input.signatures
|
||||||
|
|
||||||
if (input.hashType !== undefined) {
|
// are we almost ready to sign?
|
||||||
assert.equal(input.hashType, hashType, 'Inconsistent hashType')
|
if (canSign) {
|
||||||
}
|
// if redeemScript was provided, enforce consistency
|
||||||
|
|
||||||
var initialized = input.hashType &&
|
|
||||||
input.prevOutScript &&
|
|
||||||
input.prevOutType &&
|
|
||||||
input.pubKeys &&
|
|
||||||
input.scriptType &&
|
|
||||||
input.signatures
|
|
||||||
|
|
||||||
// are we already initialized?
|
|
||||||
if (initialized) {
|
|
||||||
// redeemScript only needed to initialize, but if provided again, enforce consistency
|
|
||||||
if (redeemScript) {
|
if (redeemScript) {
|
||||||
assert.deepEqual(input.redeemScript, redeemScript, 'Inconsistent redeemScript')
|
assert.deepEqual(input.redeemScript, redeemScript, 'Inconsistent redeemScript')
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize it
|
assert.equal(input.hashType, hashType, 'Inconsistent hashType')
|
||||||
|
|
||||||
|
// no? prepare
|
||||||
} else {
|
} else {
|
||||||
if (redeemScript) {
|
if (redeemScript) {
|
||||||
// if we have a prevOutScript, enforce scriptHash equality to the redeemScript
|
// if we have a prevOutScript, enforce scriptHash equality to the redeemScript
|
||||||
|
|
Loading…
Add table
Reference in a new issue