avoid adding extra attributes to utxo list

This commit is contained in:
Ivan Socolsky 2015-07-17 10:52:00 -03:00
parent 1fd1fce82f
commit efdd5d8761
1 changed files with 10 additions and 5 deletions

View File

@ -769,16 +769,21 @@ WalletService.prototype._selectTxInputs = function(txp, cb) {
var self = this;
function sortUtxos(utxos) {
_.each(utxos, function(utxo) {
var list = _.map(utxos, function(utxo) {
var order;
if (utxo.confirmations == 0) {
utxo.confirmationLevel = 0;
order = 0;
} else if (utxo.confirmations < 6) {
utxo.confirmationLevel = -1;
order = -1;
} else {
utxo.confirmationLevel = -2;
order = -2;
}
return {
order: order,
utxo: utxo
};
});
return _.sortBy(utxos, 'confirmationLevel');
return _.pluck(_.sortBy(list, 'order'), 'utxo');
};
self._getUtxos(function(err, utxos) {