return utxo list

This commit is contained in:
Ivan Socolsky 2016-02-24 16:42:45 -03:00
parent 0aa0f345a3
commit 755449e32d
2 changed files with 6 additions and 5 deletions

View File

@ -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);
});

View File

@ -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() {