Browse Source

Support to view memos

import_zecw
Aditya Kulkarni 6 years ago
parent
commit
4bd43bf030
  1. 1
      .gitignore
  2. 7
      src/mainwindow.cpp
  3. 23
      src/rpc.cpp
  4. 1
      src/rpc.h
  5. 2
      src/senttxstore.cpp
  6. 4
      src/txtablemodel.cpp
  7. 1
      src/txtablemodel.h

1
.gitignore

@ -8,6 +8,7 @@ src/precompiled.h.cpp
.qmake.stash
zec-qt-wallet
zec-qt-wallet.vcxproj*
zec-qt-wallet.pro.user
Makefile
Makefile.*
qrc_application.cpp

7
src/mainwindow.cpp

@ -268,7 +268,9 @@ void MainWindow::setupTransactionsTab() {
QMenu menu(this);
auto txModel = dynamic_cast<TxTableModel *>(ui->transactionsTable->model());
QString txid = txModel->getTxId(index.row());
QString memo = txModel->getMemo(index.row());
menu.addAction("Copy txid", [=] () {
QGuiApplication::clipboard()->setText(txid);
@ -283,6 +285,11 @@ void MainWindow::setupTransactionsTab() {
}
QDesktopServices::openUrl(QUrl(url));
});
if (!memo.isEmpty()) {
menu.addAction("View Memo", [=] () {
QMessageBox::information(this, "Memo", memo, QMessageBox::Ok);
});
}
menu.exec(ui->transactionsTable->viewport()->mapToGlobal(pos));
});

23
src/rpc.cpp

@ -364,11 +364,23 @@ void RPC::refreshReceivedZTrans(QList<QString> zaddrs) {
// Process all txids, removing duplicates. This can happen if the same address
// appears multiple times in a single tx's outputs.
QSet<QString> txids;
QMap<QString, QString> memos;
for (auto it = zaddrTxids->constBegin(); it != zaddrTxids->constEnd(); it++) {
for (auto& i : it.value().get<json::array_t>()) {
// Filter out change txs
if (! i["change"].get<json::boolean_t>())
txids.insert(QString::fromStdString(i["txid"].get<json::string_t>()));
if (! i["change"].get<json::boolean_t>()) {
auto txid = QString::fromStdString(i["txid"].get<json::string_t>());
txids.insert(txid);
// Check for Memos
QString memoBytes = QString::fromStdString(i["memo"].get<json::string_t>());
if (!memoBytes.startsWith("f600")) {
QString memo(QByteArray::fromHex(
QByteArray::fromStdString(i["memo"].get<json::string_t>())));
if (!memo.trimmed().isEmpty())
memos[txid] = memo;
}
}
}
}
@ -408,9 +420,10 @@ void RPC::refreshReceivedZTrans(QList<QString> zaddrs) {
}
auto amount = i["amount"].get<json::number_float_t>();
auto confirmations = txidInfo["confirmations"].get<json::number_unsigned_t>();
auto confirmations = txidInfo["confirmations"].get<json::number_unsigned_t>();
TransactionItem tx{ QString("receive"), timestamp, zaddr, txid, amount, confirmations, "" };
TransactionItem tx{ QString("receive"), timestamp, zaddr, txid, amount,
confirmations, "", memos.value(txid, "") };
txdata.push_front(tx);
}
}
@ -602,7 +615,7 @@ void RPC::refreshTransactions() {
QString::fromStdString(it["txid"]),
it["amount"].get<json::number_float_t>() + fee,
it["confirmations"].get<json::number_unsigned_t>(),
""
"", ""
};
txdata.push_back(tx);

1
src/rpc.h

@ -20,6 +20,7 @@ struct TransactionItem {
double amount;
unsigned long confirmations;
QString fromAddr;
QString memo;
};
class RPC

2
src/senttxstore.cpp

@ -42,7 +42,7 @@ QList<TransactionItem> SentTxStore::readSentTxFile() {
sentTx["address"].toString(),
sentTx["txid"].toString(),
sentTx["amount"].toDouble() + sentTx["fee"].toDouble(),
0, sentTx["from"].toString()};
0, sentTx["from"].toString(), ""};
items.push_back(t);
}

4
src/txtablemodel.cpp

@ -131,4 +131,8 @@ void TxTableModel::updateAllData() {
QString TxTableModel::getTxId(int row) {
return modeldata->at(row).txid;
}
QString TxTableModel::getMemo(int row) {
return modeldata->at(row).memo;
}

1
src/txtablemodel.h

@ -16,6 +16,7 @@ public:
void addZRecvData(const QList<TransactionItem>& data);
QString getTxId(int row);
QString getMemo(int row);
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;

Loading…
Cancel
Save