Transaction: use isFinite instead over typeof number

This commit is contained in:
Daniel Cousens 2014-09-08 18:42:47 +10:00
parent 07a438dd8a
commit 6c5a68207a
2 changed files with 4 additions and 4 deletions

View file

@ -49,8 +49,8 @@ Transaction.prototype.addInput = function(tx, index, sequence) {
assert(Buffer.isBuffer(hash), 'Expected Transaction, txId or txHash, got ' + tx) assert(Buffer.isBuffer(hash), 'Expected Transaction, txId or txHash, got ' + tx)
assert.equal(hash.length, 32, 'Expected hash length of 32, got ' + hash.length) assert.equal(hash.length, 32, 'Expected hash length of 32, got ' + hash.length)
assert.equal(typeof index, 'number', 'Expected number index, got ' + index) assert(Number.isFinite(index), 'Expected number index, got ' + index)
assert.equal(typeof sequence, 'number', 'Expected number sequence, got ' + sequence) assert(Number.isFinite(sequence), 'Expected number sequence, got ' + sequence)
// Add the input and return the input's index // Add the input and return the input's index
return (this.ins.push({ return (this.ins.push({
@ -82,7 +82,7 @@ Transaction.prototype.addOutput = function(scriptPubKey, value) {
} }
assert(scriptPubKey instanceof Script, 'Expected Address or Script, got ' + scriptPubKey) assert(scriptPubKey instanceof Script, 'Expected Address or Script, got ' + scriptPubKey)
assert.equal(typeof value, 'number', 'Expected number value, got ' + value) assert(Number.isFinite(value), 'Expected number value, got ' + value)
// Add the output and return the output's index // Add the output and return the output's index
return (this.outs.push({ return (this.outs.push({

View file

@ -303,7 +303,7 @@ Wallet.prototype.setUnspentOutputs = function(unspents) {
assert.equal(typeof txId, 'string', 'Expected txId, got ' + txId) assert.equal(typeof txId, 'string', 'Expected txId, got ' + txId)
assert.equal(txId.length, 64, 'Expected valid txId, got ' + txId) assert.equal(txId.length, 64, 'Expected valid txId, got ' + txId)
assert.doesNotThrow(function() { Address.fromBase58Check(unspent.address) }, 'Expected Base58 Address, got ' + unspent.address) assert.doesNotThrow(function() { Address.fromBase58Check(unspent.address) }, 'Expected Base58 Address, got ' + unspent.address)
assert.equal(typeof index, 'number', 'Expected number index, got ' + index) assert(Number.isFinite(index), 'Expected number index, got ' + index)
assert.equal(typeof unspent.value, 'number', 'Expected number value, got ' + unspent.value) assert.equal(typeof unspent.value, 'number', 'Expected number value, got ' + unspent.value)
// FIXME: remove branch in 2.0.0 // FIXME: remove branch in 2.0.0