From 73f7d9a22b6de4e85ce6e4f671b372146ebef93c Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 17 Jul 2015 14:30:55 -0300 Subject: [PATCH 1/3] add fee to tx history --- public/views/modals/tx-details.html | 4 ++++ src/js/controllers/index.js | 4 ++++ src/js/controllers/walletHome.js | 1 + 3 files changed, 9 insertions(+) diff --git a/public/views/modals/tx-details.html b/public/views/modals/tx-details.html index 7127f0360..459d6601e 100644 --- a/public/views/modals/tx-details.html +++ b/public/views/modals/tx-details.html @@ -50,6 +50,10 @@ +
  • + Fee: + {{feeStr}} +
  • Note: diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 845e78dd2..b737b38fb 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -442,6 +442,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r }; self.setTxHistory = function(txs) { + var config = configService.getSync().wallet.settings; var now = Math.floor(Date.now() / 1000); var c = 0; self.txHistoryPaging = txs[self.limitHistory] ? true : false; @@ -453,6 +454,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r tx.rateTs = Math.floor((tx.ts || now) / 1000); tx.amountStr = profileService.formatAmount(tx.amount); //$filter('noFractionNumber')( + if (tx.fees) + tx.feeStr = profileService.formatAmount(tx.fees) + ' ' + config.unitName; + if (c < self.limitHistory) { self.txHistory.push(tx); c++; diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index cd6129406..4ada49f85 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -994,6 +994,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi $scope.color = fc.backgroundColor; $scope.copayerId = fc.credentials.copayerId; $scope.isShared = fc.credentials.n > 1; + $scope.feeStr = btx.feeStr; $scope.getAmount = function(amount) { return self.getAmount(amount); From 4fa62b0e4e47729ff323aee36c0e2a56ccfd99de Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 17 Jul 2015 14:43:40 -0300 Subject: [PATCH 2/3] handle moved + fee --- src/js/controllers/index.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index b737b38fb..dc6d91985 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -645,8 +645,20 @@ angular.module('copayApp.controllers').controller('indexController', function($r var _amount, _note; var dataString; data.forEach(function(it, index) { - _amount = (it.action == 'sent' ? '-' : '') + (it.amount * satToBtc).toFixed(8); - _note = formatString((it.message ? 'Note: ' + it.message + ' - ' : '') + 'TxId: ' + it.txid); + var amount = it.amount; + + if (it.action == 'moved') + amount = 0; + + if (it.action == 'sent' || it.action=='moved') + amount += it.fees; + + _amount = (it.action == 'sent' ? '-' : '') + (amount * satToBtc).toFixed(8); + _note = formatString((it.message ? 'Note: ' + it.message + ' - ' : '') + 'TxId: ' + it.txid + ' Fee'+ (it.fees * satToBtc).toFixed(8)) ; + + if (it.action == 'moved') + _note += ' Moved:' + (it.amount * satToBtc).toFixed(8) + dataString = formatDate(it.time * 1000) + ',' + formatString(it.addressTo) + ',' + _note + ',' + _amount + ',BTC,,,,'; csvContent += index < data.length ? dataString + "\n" : dataString; }); From c7caf71e938a0ad8653457675e64b404f0b5f7f6 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 17 Jul 2015 15:51:12 -0300 Subject: [PATCH 3/3] add a new record for network fees --- src/js/controllers/index.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index dc6d91985..344feaf7e 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -608,8 +608,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r if (txs && txs.length > 0) { allTxs.push(txs); return getHistory(skip + 100, cb); - } - else { + } else { return cb(null, lodash.flatten(allTxs)); } }); @@ -637,7 +636,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.satToUnit = 1 / self.unitToSatoshi; var data = txs; var satToBtc = 1 / 100000000; - var filename = 'Copay-' + (self.alias || self.walletName ) + '.csv'; + var filename = 'Copay-' + (self.alias || self.walletName) + '.csv'; var csvContent = ''; if (!isNode) csvContent = 'data:text/csv;charset=utf-8,'; csvContent += 'Date,Destination,Note,Amount,Currency,Spot Value,Total Value,Tax Type,Category\n'; @@ -650,23 +649,24 @@ angular.module('copayApp.controllers').controller('indexController', function($r if (it.action == 'moved') amount = 0; - if (it.action == 'sent' || it.action=='moved') - amount += it.fees; - - _amount = (it.action == 'sent' ? '-' : '') + (amount * satToBtc).toFixed(8); - _note = formatString((it.message ? 'Note: ' + it.message + ' - ' : '') + 'TxId: ' + it.txid + ' Fee'+ (it.fees * satToBtc).toFixed(8)) ; + _amount = (it.action == 'sent' ? '-' : '') + (amount * satToBtc).toFixed(8); + _note = formatString((it.message ? it.message : '') + ' TxId: ' + it.txid + ' Fee:' + (it.fees * satToBtc).toFixed(8)); if (it.action == 'moved') - _note += ' Moved:' + (it.amount * satToBtc).toFixed(8) + _note += ' Moved:' + (it.amount * satToBtc).toFixed(8) dataString = formatDate(it.time * 1000) + ',' + formatString(it.addressTo) + ',' + _note + ',' + _amount + ',BTC,,,,'; - csvContent += index < data.length ? dataString + "\n" : dataString; + csvContent += dataString + "\n"; + + if (it.fees && (it.action == 'moved' || it.action == 'sent')) { + var _fee = (it.fees * satToBtc).toFixed(8) + csvContent += formatDate(it.time * 1000) + ',Bitcoin Network Fees,, -' + _fee + ',BTC,,,,' + "\n"; + } }); if (isNode) { saveFile('#export_file', csvContent); - } - else { + } else { var encodedUri = encodeURI(csvContent); var link = document.createElement("a"); link.setAttribute("href", encodedUri);