Merge pull request #287 from isocolsky/confirmed_first

Improve prioritization of confirmed vs unconfirmed UTXOs
This commit is contained in:
Matias Alejo Garcia 2015-07-16 16:21:25 -03:00
commit 7d74b4b082
1 changed files with 6 additions and 7 deletions

View File

@ -769,17 +769,16 @@ WalletService.prototype._selectTxInputs = function(txp, cb) {
var self = this;
function sortUtxos(utxos) {
var confirmed = [];
var unconfirmed = [];
_.each(utxos, function(utxo) {
if (utxo.confirmations > 0) {
confirmed.push(utxo);
if (utxo.confirmations == 0) {
utxo.confirmationLevel = 0;
} else if (utxo.confirmations < 6) {
utxo.confirmationLevel = -1;
} else {
unconfirmed.push(utxo);
utxo.confirmationLevel = -2;
}
});
return confirmed.concat(unconfirmed);
return _.sortBy(utxos, 'confirmationLevel');
};
self._getUtxos(function(err, utxos) {