Browse Source

TxBuilder: hashtype only relevant to things we can sign

hk-custom-address
Daniel Cousens 10 years ago
parent
commit
73bf8a42ea
  1. 29
      src/transaction_builder.js

29
src/transaction_builder.js

@ -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 &&
if (input.hashType !== undefined) { input.prevOutScript &&
assert.equal(input.hashType, hashType, 'Inconsistent hashType') input.prevOutType &&
} input.pubKeys &&
input.scriptType &&
var initialized = input.hashType && input.signatures
input.prevOutScript &&
input.prevOutType && // are we almost ready to sign?
input.pubKeys && if (canSign) {
input.scriptType && // if redeemScript was provided, enforce consistency
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…
Cancel
Save