Using getTransactionHistory from wallet

This commit is contained in:
Matias Pando 2014-11-11 17:56:12 -03:00
commit f8fb165630

View file

@ -33,13 +33,22 @@ angular.module('copayApp.controllers').controller('HistoryController',
log.info('Not available on mobile');
return;
}
var w = $rootScope.wallet;
if (!w) return;
var data = $scope.blockchain_txs;
var data = w.getTransactionHistory(null, function(err, res) {
if (err) throw err;
if (!res) {
return;
}
var data = res.items;
var filename = "copay_history.csv";
var csvContent = "data:text/csv;charset=utf-8,Date,Amount,Action,AddressTo,Comment\n";
data.forEach(function(it, index) {
var dataString = formatDate(it.ts) + ',' + it.amount + ',' + it.action + ',' + it.addressTo + ',' + formatString(it.comment);
var dataString = formatDate(it.minedTs || it.sentTs) + ',' + it.amount + ',' + it.action + ',' + it.addressTo + ',' + formatString(it.comment);
csvContent += index < data.length ? dataString + "\n" : dataString;
});
@ -64,11 +73,12 @@ angular.module('copayApp.controllers').controller('HistoryController',
return dateObj.toJSON().substring(0, 10);
}
function formatString(str) {
if (!str) return '';
return str;
}
});
};
@ -122,8 +132,6 @@ angular.module('copayApp.controllers').controller('HistoryController',
$scope.hasAction = function(actions, action) {
return actions.hasOwnProperty('create');
};