txbuilder: rename tx.outs.length to nOutputs
This commit is contained in:
parent
693e39c061
commit
881a23f9d5
1 changed files with 5 additions and 5 deletions
|
@ -227,13 +227,13 @@ TransactionBuilder.prototype.addInput = function (txHash, vout, sequence, prevOu
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionBuilder.prototype.addOutput = function (scriptPubKey, value) {
|
TransactionBuilder.prototype.addOutput = function (scriptPubKey, value) {
|
||||||
var tx = this.tx
|
var nOutputs = this.tx.outs.length
|
||||||
var valid = this.inputs.every(function (input, index) {
|
var valid = this.inputs.every(function (input, index) {
|
||||||
if (input.hashType === undefined) return true
|
if (input.hashType === undefined) return true
|
||||||
|
|
||||||
var hashType = input.hashType & 0x1f
|
var hashTypeMod = input.hashType & 0x1f
|
||||||
return hashType === Transaction.SIGHASH_NONE ||
|
return (hashTypeMod === Transaction.SIGHASH_NONE) ||
|
||||||
(hashType === Transaction.SIGHASH_SINGLE && index < tx.outs.length)
|
(hashTypeMod === Transaction.SIGHASH_SINGLE && index < nOutputs)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!valid) throw new Error('No, this would invalidate signatures')
|
if (!valid) throw new Error('No, this would invalidate signatures')
|
||||||
|
@ -243,7 +243,7 @@ TransactionBuilder.prototype.addOutput = function (scriptPubKey, value) {
|
||||||
scriptPubKey = baddress.toOutputScript(scriptPubKey, this.network)
|
scriptPubKey = baddress.toOutputScript(scriptPubKey, this.network)
|
||||||
}
|
}
|
||||||
|
|
||||||
return tx.addOutput(scriptPubKey, value)
|
return this.tx.addOutput(scriptPubKey, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionBuilder.prototype.build = function () {
|
TransactionBuilder.prototype.build = function () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue