From 09c6a787d9d89416a1e6483814054918b214d3fd Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Fri, 2 May 2014 06:08:45 +1000 Subject: [PATCH] Changes sequence number to an actual Number --- src/transaction.js | 6 +++--- test/transaction.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/transaction.js b/src/transaction.js index 0fe3c28..11d6880 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -16,7 +16,7 @@ var Transaction = function (doc) { this.locktime = 0 this.ins = [] this.outs = [] - this.defaultSequence = [255, 255, 255, 255] // 0xFFFFFFFF + this.defaultSequence = 0xffffffff if (doc) { if (typeof doc == "string" || Array.isArray(doc)) { @@ -137,7 +137,7 @@ Transaction.prototype.serialize = function () { var scriptBytes = txin.script.buffer buffer = buffer.concat(convert.numToVarInt(scriptBytes.length)) buffer = buffer.concat(scriptBytes) - buffer = buffer.concat(txin.sequence) + buffer = buffer.concat(convert.numToBytes(txin.sequence, 4)) }) buffer = buffer.concat(convert.numToVarInt(this.outs.length)) @@ -289,7 +289,7 @@ Transaction.deserialize = function(buffer) { index: readAsInt(4) }, script: new Script(readVarString()), - sequence: readBytes(4) + sequence: readAsInt(4) }) } var outs = readVarInt() diff --git a/test/transaction.js b/test/transaction.js index 43436d8..722ff93 100644 --- a/test/transaction.js +++ b/test/transaction.js @@ -50,7 +50,7 @@ describe('Transaction', function() { assert.equal(tx.ins.length, 1) var input = tx.ins[0] - assert.deepEqual(input.sequence, [255, 255, 255, 255]) + assert.equal(input.sequence, 4294967295) assert.equal(input.outpoint.index, 0) assert.equal(input.outpoint.hash, "69d02fc05c4e0ddc87e796eee42693c244a3112fffe1f762c3fb61ffcb304634") @@ -128,7 +128,7 @@ describe('Transaction', function() { assert.equal(tx.ins.length, 1) var input = tx.ins[0] - assert.deepEqual(input.sequence, [255, 255, 255, 255]) + assert.equal(input.sequence, 4294967295) assert.equal(input.outpoint.index, 0) assert.equal(input.outpoint.hash, "0cb859105100ebc3344f749c835c7af7d7103ec0d8cbc3d8ccbd5d28c3c36b57")