From efdd5d8761e867a96785f6eaad1297f85b46f772 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Fri, 17 Jul 2015 10:52:00 -0300 Subject: [PATCH] avoid adding extra attributes to utxo list --- lib/server.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/server.js b/lib/server.js index d23f85e..f7a9c24 100644 --- a/lib/server.js +++ b/lib/server.js @@ -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) {