|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
#include "TransactionInfo.h"
|
|
|
|
|
#include <wallet/api/wallet2_api.h>
|
|
|
|
|
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -113,3 +114,68 @@ TransactionHistory::TransactionHistory(Monero::TransactionHistory *pimpl, QObjec
|
|
|
|
|
m_firstDateTime = QDateTime(QDate(2014, 4, 18)); // the genesis block
|
|
|
|
|
m_lastDateTime = QDateTime::currentDateTime().addDays(1); // tomorrow (guard against jitter and timezones)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString TransactionHistory::writeCSV(quint32 accountIndex, QString out)
|
|
|
|
|
{
|
|
|
|
|
QList<TransactionInfo *> history = this->getAll(accountIndex);
|
|
|
|
|
if(history.count() < 1){
|
|
|
|
|
return QString("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// construct filename
|
|
|
|
|
qint64 now = QDateTime::currentDateTime().currentMSecsSinceEpoch();
|
|
|
|
|
QString fn = QString(QString("%1/monero-txs_%2.csv").arg(out, QString::number(now / 1000)));
|
|
|
|
|
|
|
|
|
|
// open file
|
|
|
|
|
QFile data(fn);
|
|
|
|
|
if(!data.open(QFile::WriteOnly | QFile::Truncate)){
|
|
|
|
|
return QString("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// write header
|
|
|
|
|
QTextStream output(&data);
|
|
|
|
|
output << "blockHeight,epoch,date,direction,amount,atomicAmount,fee,txid,label,subaddrAccount,paymentId\n";
|
|
|
|
|
|
|
|
|
|
foreach(const TransactionInfo *info, history)
|
|
|
|
|
{
|
|
|
|
|
// collect column data
|
|
|
|
|
double amount = info->amount();
|
|
|
|
|
quint64 atomicAmount = info->atomicAmount();
|
|
|
|
|
quint32 subaddrAccount = info->subaddrAccount();
|
|
|
|
|
QString fee = info->fee();
|
|
|
|
|
QString direction = QString("");
|
|
|
|
|
TransactionInfo::Direction _direction = info->direction();
|
|
|
|
|
if(_direction == TransactionInfo::Direction_In)
|
|
|
|
|
{
|
|
|
|
|
direction = QString("in");
|
|
|
|
|
}
|
|
|
|
|
else if(_direction == TransactionInfo::Direction_Out){
|
|
|
|
|
direction = QString("out");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
continue; // skip TransactionInfo::Direction_Both
|
|
|
|
|
}
|
|
|
|
|
QString label = info->label();
|
|
|
|
|
label.remove(QChar('"')); // reserved
|
|
|
|
|
quint64 blockHeight = info->blockHeight();
|
|
|
|
|
QDateTime timeStamp = info->timestamp();
|
|
|
|
|
QString date = info->date() + " " + info->time();
|
|
|
|
|
uint epoch = timeStamp.toTime_t();
|
|
|
|
|
QString displayAmount = info->displayAmount();
|
|
|
|
|
QString paymentId = info->paymentId();
|
|
|
|
|
if(paymentId == "0000000000000000"){
|
|
|
|
|
paymentId = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// format and write
|
|
|
|
|
QString line = QString("%1,%2,%3,%4,%5,%6,%7,%8,\"%9\",%10,%11\n")
|
|
|
|
|
.arg(QString::number(blockHeight), QString::number(epoch), date)
|
|
|
|
|
.arg(direction, QString::number(amount), QString::number(atomicAmount))
|
|
|
|
|
.arg(info->fee(), info->hash(), label, QString::number(subaddrAccount))
|
|
|
|
|
.arg(paymentId);
|
|
|
|
|
output << line;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.close();
|
|
|
|
|
return fn;
|
|
|
|
|
}
|
|
|
|
|