From 6c9f95c253fe0b879ab687b09a83a59df799e6a6 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Mon, 16 Jun 2014 18:41:01 +1000 Subject: [PATCH] Transaction: add sequence parameter to addInput --- src/transaction.js | 6 ++++-- test/transaction.js | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/transaction.js b/src/transaction.js index 6528adf..f99976e 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -32,7 +32,9 @@ function Transaction() { * * Note that this method does not sign the created input. */ -Transaction.prototype.addInput = function(tx, index) { +Transaction.prototype.addInput = function(tx, index, sequence) { + if (sequence == undefined) sequence = DEFAULT_SEQUENCE + var hash if (typeof tx === 'string') { @@ -54,7 +56,7 @@ Transaction.prototype.addInput = function(tx, index) { hash: hash, index: index, script: Script.EMPTY, - sequence: DEFAULT_SEQUENCE + sequence: sequence }) - 1) } diff --git a/test/transaction.js b/test/transaction.js index eb416e6..e93ea11 100644 --- a/test/transaction.js +++ b/test/transaction.js @@ -100,11 +100,15 @@ describe('Transaction', function() { Array.prototype.reverse.call(txInId) txInId = txInId.toString('hex') - var j = tx.addInput(txInId, txIn.index) + var j = tx.addInput(txInId, txIn.index, txIn.sequence) assert.equal(i, j) assert.deepEqual(tx.ins[i].hash, txIn.hash) assert.equal(tx.ins[i].index, txIn.index) + + var sequence = txIn.sequence + if (sequence == undefined) sequence = Transaction.DEFAULT_SEQUENCE + assert.equal(tx.ins[i].sequence, sequence) }) }) })