diff --git a/lib/server.js b/lib/server.js index d8026aa..517b973 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1335,7 +1335,7 @@ WalletService.prototype._selectTxInputs = function(txp, utxosToExclude, cb) { log.debug('Considering ' + smallInputs.length + ' small inputs (' + Utils.formatUtxos(smallInputs) + ')'); var total = 0; - var netTotal = 0; + var netTotal = -baseTxpFee; var selected = []; var fee; var error; diff --git a/test/integration/server.js b/test/integration/server.js index 45e2334..8acd72a 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -3562,9 +3562,22 @@ describe('Wallet service', function() { }); }); }); - - - + it('should always select inputs as long as there are sufficient funds', function(done) { + helpers.stubUtxos(server, wallet, [80, '50bit', '50bit', '50bit', '50bit', '50bit'], function() { + var txOpts = { + outputs: [{ + toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', + amount: 101e2, + }], + feePerKb: 100e2, + }; + server.createTx(txOpts, function(err, txp) { + should.not.exist(err); + should.exist(txp); + done(); + }); + }); + }); }); });