removed unused code in wallet + tests
This commit is contained in:
parent
57ae7485a4
commit
6797c3db19
2 changed files with 0 additions and 149 deletions
|
|
@ -2543,85 +2543,6 @@ Wallet.prototype.isComplete = function() {
|
|||
return this.publicKeyRing.isComplete();
|
||||
};
|
||||
|
||||
/**
|
||||
* @desc Return a list of transactions on CSV format
|
||||
* @return {Object} the list of transactions on CSV format
|
||||
*/
|
||||
Wallet.prototype.getTransactionHistoryCsv = function(cb) {
|
||||
var self = this;
|
||||
self.getTransactionHistory(function(err, res) {
|
||||
preconditions.checkState(res);
|
||||
if (err) {
|
||||
log.warn(err);
|
||||
return cb(new Error('TXHISTORY: ' + err.toString()));
|
||||
}
|
||||
|
||||
var unit = self.settings.unitName;
|
||||
var data = res.items;
|
||||
|
||||
var csvContent = "data:text/csv;charset=utf-8,";
|
||||
csvContent += "Date,Amount(" + unit + "),Action,AddressTo,Comment";
|
||||
|
||||
if (self.isShared()) {
|
||||
csvContent += ",Signers\n";
|
||||
} else {
|
||||
csvContent += "\n";
|
||||
}
|
||||
|
||||
data.forEach(function(it, index) {
|
||||
if (!it) {
|
||||
return cb(new Error('TXHISTORY: The item is null'));
|
||||
}
|
||||
var dataString = formatDate(it.minedTs || it.sentTs) + ',' + it.amount + ',' + it.action + ',' + formatString(it.addressTo) + ',' + formatString(it.comment);
|
||||
if (self.isShared() && it.actionList) {
|
||||
dataString += ',' + formatSigners(it.actionList);
|
||||
}
|
||||
csvContent += index < data.length ? dataString + "\n" : dataString;
|
||||
});
|
||||
|
||||
|
||||
|
||||
return cb(csvContent);
|
||||
|
||||
function formatDate(date) {
|
||||
var dateObj = new Date(date);
|
||||
if (!dateObj) {
|
||||
log.warn('Error formating a date');
|
||||
return 'DateError'
|
||||
}
|
||||
if (!dateObj.toJSON()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return dateObj.toJSON().substring(0, 10);
|
||||
}
|
||||
|
||||
function formatString(str) {
|
||||
if (!str) return '';
|
||||
|
||||
if (str.indexOf('"') !== -1) {
|
||||
//replace all
|
||||
str = str.replace(new RegExp('"', 'g'), '\'');
|
||||
}
|
||||
|
||||
//escaping commas
|
||||
str = '\"' + str + '\"';
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
function formatSigners(item) {
|
||||
if (!item) return '';
|
||||
var str = '';
|
||||
item.forEach(function(it, index) {
|
||||
str += index == 0 ? self.publicKeyRing.nicknameForCopayer(it.cId) : '|' + self.publicKeyRing.nicknameForCopayer(it.cId);
|
||||
});
|
||||
return str;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc Sets the version of this wallet object
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue