Transaction: add comment to explain -1 on add*
This commit is contained in:
parent
70be0d2117
commit
b66e53d1e7
1 changed files with 3 additions and 3 deletions
|
@ -53,6 +53,7 @@ Transaction.prototype.addInput = function(tx, index, sequence) {
|
||||||
assert.equal(hash.length, 32, 'Expected hash length of 32, got ' + hash.length)
|
assert.equal(hash.length, 32, 'Expected hash length of 32, got ' + hash.length)
|
||||||
assert.equal(typeof index, 'number', 'Expected number index, got ' + index)
|
assert.equal(typeof index, 'number', 'Expected number index, got ' + index)
|
||||||
|
|
||||||
|
// Add the input and return the input's index
|
||||||
return (this.ins.push({
|
return (this.ins.push({
|
||||||
hash: hash,
|
hash: hash,
|
||||||
index: index,
|
index: index,
|
||||||
|
@ -78,14 +79,13 @@ Transaction.prototype.addOutput = function(scriptPubKey, value) {
|
||||||
|
|
||||||
// Attempt to get a valid script if it's an Address object
|
// Attempt to get a valid script if it's an Address object
|
||||||
if (scriptPubKey instanceof Address) {
|
if (scriptPubKey instanceof Address) {
|
||||||
var address = scriptPubKey
|
scriptPubKey = scriptPubKey.toOutputScript()
|
||||||
|
|
||||||
scriptPubKey = address.toOutputScript()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(scriptPubKey instanceof Script, 'Expected Address or Script, got ' + scriptPubKey)
|
assert(scriptPubKey instanceof Script, 'Expected Address or Script, got ' + scriptPubKey)
|
||||||
assert.equal(typeof value, 'number', 'Expected number value, got ' + value)
|
assert.equal(typeof value, 'number', 'Expected number value, got ' + value)
|
||||||
|
|
||||||
|
// Add the output and return the output's index
|
||||||
return (this.outs.push({
|
return (this.outs.push({
|
||||||
script: scriptPubKey,
|
script: scriptPubKey,
|
||||||
value: value
|
value: value
|
||||||
|
|
Loading…
Add table
Reference in a new issue