From 9fdf06c28c61beb659438b88a3aa8a9e51318c91 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Wed, 12 Nov 2014 17:06:35 -0300 Subject: [PATCH] assign addressTo and labelTo on outgoing txs only --- js/models/Wallet.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/js/models/Wallet.js b/js/models/Wallet.js index 53f8a1b94..a2cffb06d 100644 --- a/js/models/Wallet.js +++ b/js/models/Wallet.js @@ -1323,7 +1323,10 @@ Wallet.prototype.getPendingTxProposals = function() { }); txp.outs = []; _.each(addresses, function(value, address) { - txp.outs.push({address: address, value: value * satToUnit}); + txp.outs.push({ + address: address, + value: value * satToUnit + }); }); // extra fields txp.fee = txp.builder.feeSat * satToUnit; @@ -2931,12 +2934,16 @@ Wallet.prototype.getTransactionHistory = function(opts, cb) { tx.action = amount > 0 ? 'sent' : 'received'; } - var firstOut = _.findWhere(items, { - type: 'out' - }); + if (tx.action == 'sent' || tx.action == 'moved') { + var firstOut = _.findWhere(items, { + type: 'out' + }); + if (firstOut) { + tx.labelTo = firstOut.label; + tx.addressTo = firstOut.address; + } + }; - tx.labelTo = firstOut ? firstOut.label : undefined; - tx.addressTo = firstOut ? firstOut.address : undefined; tx.amountSat = Math.abs(amount); tx.amount = tx.amountSat * satToUnit; tx.minedTs = !_.isNaN(tx.time) ? tx.time * 1000 : undefined;