Merge pull request #288 from isocolsky/confirmed_first
Avoid adding extra attributes to utxo list when sorting
This commit is contained in:
commit
fa778d81ff
|
@ -769,16 +769,21 @@ WalletService.prototype._selectTxInputs = function(txp, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
function sortUtxos(utxos) {
|
function sortUtxos(utxos) {
|
||||||
_.each(utxos, function(utxo) {
|
var list = _.map(utxos, function(utxo) {
|
||||||
|
var order;
|
||||||
if (utxo.confirmations == 0) {
|
if (utxo.confirmations == 0) {
|
||||||
utxo.confirmationLevel = 0;
|
order = 0;
|
||||||
} else if (utxo.confirmations < 6) {
|
} else if (utxo.confirmations < 6) {
|
||||||
utxo.confirmationLevel = -1;
|
order = -1;
|
||||||
} else {
|
} 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) {
|
self._getUtxos(function(err, utxos) {
|
||||||
|
|
Loading…
Reference in New Issue