From db814439a3c9b5c81a2c7227bb94d920f73b0338 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Wed, 28 May 2014 15:13:45 +1000 Subject: [PATCH] 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. --- src/transaction.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/transaction.js b/src/transaction.js index 5d39d89..8ae24f6 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -10,13 +10,14 @@ var crypto = require('./crypto') var ECKey = require('./eckey') var ecdsa = require('./ecdsa') +var DEFAULT_SEQUENCE = 0xffffffff + function Transaction(doc) { if (!(this instanceof Transaction)) { return new Transaction(doc) } this.version = 1 this.locktime = 0 this.ins = [] this.outs = [] - this.defaultSequence = 0xffffffff if (doc) { if (typeof doc == "string" || Array.isArray(doc)) { @@ -75,8 +76,7 @@ Transaction.prototype.addInput = function (tx, outIndex) { hash: hash, index: outIndex }, - script: new Script(), - sequence: this.defaultSequence + script: new Script() })) } @@ -419,7 +419,7 @@ var TransactionIn = function (data) { assert(data.script, 'Invalid TxIn parameters') this.script = data.script - this.sequence = data.sequence || this.defaultSequence + this.sequence = data.sequence == undefined ? DEFAULT_SEQUENCE : data.sequence } TransactionIn.prototype.clone = function () {