Transaction: extract DEFAULT_SEQUENCE constant
Also fixes the bug when the sequence number is 0 and `TransactionIn.defaultSequence` is used; resulting in an undefined sequence number as it is undefined.
This commit is contained in:
parent
12a2dc3cc2
commit
db814439a3
1 changed files with 4 additions and 4 deletions
|
@ -10,13 +10,14 @@ var crypto = require('./crypto')
|
||||||
var ECKey = require('./eckey')
|
var ECKey = require('./eckey')
|
||||||
var ecdsa = require('./ecdsa')
|
var ecdsa = require('./ecdsa')
|
||||||
|
|
||||||
|
var DEFAULT_SEQUENCE = 0xffffffff
|
||||||
|
|
||||||
function Transaction(doc) {
|
function Transaction(doc) {
|
||||||
if (!(this instanceof Transaction)) { return new Transaction(doc) }
|
if (!(this instanceof Transaction)) { return new Transaction(doc) }
|
||||||
this.version = 1
|
this.version = 1
|
||||||
this.locktime = 0
|
this.locktime = 0
|
||||||
this.ins = []
|
this.ins = []
|
||||||
this.outs = []
|
this.outs = []
|
||||||
this.defaultSequence = 0xffffffff
|
|
||||||
|
|
||||||
if (doc) {
|
if (doc) {
|
||||||
if (typeof doc == "string" || Array.isArray(doc)) {
|
if (typeof doc == "string" || Array.isArray(doc)) {
|
||||||
|
@ -75,8 +76,7 @@ Transaction.prototype.addInput = function (tx, outIndex) {
|
||||||
hash: hash,
|
hash: hash,
|
||||||
index: outIndex
|
index: outIndex
|
||||||
},
|
},
|
||||||
script: new Script(),
|
script: new Script()
|
||||||
sequence: this.defaultSequence
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ var TransactionIn = function (data) {
|
||||||
|
|
||||||
assert(data.script, 'Invalid TxIn parameters')
|
assert(data.script, 'Invalid TxIn parameters')
|
||||||
this.script = data.script
|
this.script = data.script
|
||||||
this.sequence = data.sequence || this.defaultSequence
|
this.sequence = data.sequence == undefined ? DEFAULT_SEQUENCE : data.sequence
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionIn.prototype.clone = function () {
|
TransactionIn.prototype.clone = function () {
|
||||||
|
|
Loading…
Reference in a new issue