diff --git a/src/wallet.js b/src/wallet.js index 58cc098..2b69f32 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -3,7 +3,7 @@ var Transaction = require('./transaction').Transaction var HDNode = require('./hdwallet.js') var rng = require('secure-random') -var Wallet = function (seed, options) { +function Wallet(seed, options) { if (!(this instanceof Wallet)) { return new Wallet(seed, options); } var options = options || {} @@ -119,20 +119,20 @@ var Wallet = function (seed, options) { function validateUnspentOutput(uo) { var missingField - if(isNullOrUndefined(uo.hash) && isNullOrUndefined(uo.hashLittleEndian)){ + if (isNullOrUndefined(uo.hash) && isNullOrUndefined(uo.hashLittleEndian)) { missingField = "hash(or hashLittleEndian)" } var requiredKeys = ['outputIndex', 'address', 'value'] - requiredKeys.forEach(function(key){ - if(isNullOrUndefined(uo[key])){ + requiredKeys.forEach(function (key) { + if (isNullOrUndefined(uo[key])){ missingField = key } }) - if(missingField) { + if (missingField) { var message = [ - 'Invalid unspent output: key', field, 'is missing.', + 'Invalid unspent output: key', missingField, 'is missing.', 'A valid unspent output must contain' ] message.push(requiredKeys.join(', ')) @@ -141,7 +141,7 @@ var Wallet = function (seed, options) { } } - function isNullOrUndefined(value){ + function isNullOrUndefined(value) { return value == undefined } diff --git a/test/wallet.js b/test/wallet.js index c4fe9c1..cfc5626 100644 --- a/test/wallet.js +++ b/test/wallet.js @@ -22,6 +22,10 @@ describe('Wallet', function() { }) describe('constructor', function() { + it('should be ok to call without new', function() { + assert.ok(Wallet(seed) instanceof Wallet) + }) + it('defaults to Bitcoin mainnet', function() { assert.equal(wallet.getMasterKey().network, 'mainnet') })