diff --git a/lib/server.js b/lib/server.js index 9f86c2e..6a3a367 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1680,10 +1680,6 @@ WalletService.prototype._validateAndSanitizeTxOpts = function(wallet, opts, cb) async.series([ - function(next) { - if (!checkRequired(opts, ['outputs'], next)) return; - next(); - }, function(next) { // feePerKb is required unless inputs & fee are specified if (!_.isNumber(opts.feePerKb) && !(opts.inputs && _.isNumber(opts.fee))) @@ -1755,6 +1751,10 @@ WalletService.prototype._validateAndSanitizeTxOpts = function(wallet, opts, cb) WalletService.prototype.createTx = function(opts, cb) { var self = this; + opts = opts || {}; + + if (!checkRequired(opts, ['outputs'], cb)) return; + function getChangeAddress(wallet, cb) { if (wallet.singleAddress) { self.storage.fetchAddresses(self.walletId, function(err, addresses) { diff --git a/test/integration/server.js b/test/integration/server.js index 3541a30..75b98c3 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -2294,6 +2294,21 @@ describe('Wallet service', function() { }); }); }); + it('should fail to create a tx without outputs param', function(done) { + helpers.stubUtxos(server, wallet, [1, 2], function() { + var txOpts = { + toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', + amount: 0.8 * 1e8, + message: 'some message', + feePerKb: 123e2, + }; + server.createTx(txOpts, function(err, tx) { + should.exist(err); + should.not.exist(tx); + done(); + }); + }); + }); it('should be able to publish a temporary tx proposal', function(done) { helpers.stubUtxos(server, wallet, [1, 2], function() { var txOpts = {