diff --git a/lib/server.js b/lib/server.js index 44acc0f..227b844 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1175,6 +1175,7 @@ WalletService.prototype.getSendMaxInfo = function(opts, cb) { amount: 0, fee: 0, nbInputs: 0, + inputs: [], }; var inputs = _.reject(utxos, 'locked'); @@ -1197,8 +1198,8 @@ WalletService.prototype.getSendMaxInfo = function(opts, cb) { _.eachRight(inputs, function(input) { txp.inputs.push(input); var fee = txp.getEstimatedFee(); - if (fee - lastFee > input.satoshis || - txp.getEstimatedSize() / 1000. > Defaults.MAX_TX_SIZE_IN_KB) { + var sizeInKb = txp.getEstimatedSize() / 1000.; + if (fee - lastFee > input.satoshis || sizeInKb > Defaults.MAX_TX_SIZE_IN_KB) { txp.inputs.pop(); return false; } @@ -1210,6 +1211,7 @@ WalletService.prototype.getSendMaxInfo = function(opts, cb) { info.fee = txp.getEstimatedFee(); info.amount = _.sum(txp.inputs, 'satoshis') - info.fee; info.nbInputs = txp.inputs.length; + info.inputs = txp.inputs; return cb(null, info); }); diff --git a/test/integration/server.js b/test/integration/server.js index 588f2b5..52621f8 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -3613,10 +3613,9 @@ describe('Wallet service', function() { amount: info.amount, fee: info.fee, }], + inputs: info.inputs, }; server.createTx(txOpts, function(err, tx) { - console.log('*** [server.js ln3150] err:', err); // TODO - should.not.exist(err); should.exist(tx); tx.inputs.length.should.equal(info.nbInputs); @@ -3722,7 +3721,7 @@ describe('Wallet service', function() { }); }); }); - it.only('should not go beyond max tx size', function(done) { + it('should not go beyond max tx size', function(done) { var _oldDefault = Defaults.MAX_TX_SIZE_IN_KB; Defaults.MAX_TX_SIZE_IN_KB = 2; helpers.stubUtxos(server, wallet, _.range(1, 10, 0), function() {