Browse Source

Transaction: add sequence parameter to addInput

hk-custom-address
Daniel Cousens 11 years ago
parent
commit
6c9f95c253
  1. 6
      src/transaction.js
  2. 6
      test/transaction.js

6
src/transaction.js

@ -32,7 +32,9 @@ function Transaction() {
* *
* Note that this method does not sign the created input. * 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 var hash
if (typeof tx === 'string') { if (typeof tx === 'string') {
@ -54,7 +56,7 @@ Transaction.prototype.addInput = function(tx, index) {
hash: hash, hash: hash,
index: index, index: index,
script: Script.EMPTY, script: Script.EMPTY,
sequence: DEFAULT_SEQUENCE sequence: sequence
}) - 1) }) - 1)
} }

6
test/transaction.js

@ -100,11 +100,15 @@ describe('Transaction', function() {
Array.prototype.reverse.call(txInId) Array.prototype.reverse.call(txInId)
txInId = txInId.toString('hex') 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.equal(i, j)
assert.deepEqual(tx.ins[i].hash, txIn.hash) assert.deepEqual(tx.ins[i].hash, txIn.hash)
assert.equal(tx.ins[i].index, txIn.index) 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)
}) })
}) })
}) })

Loading…
Cancel
Save