Support to view memos
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,6 +8,7 @@ src/precompiled.h.cpp
|
|||||||
.qmake.stash
|
.qmake.stash
|
||||||
zec-qt-wallet
|
zec-qt-wallet
|
||||||
zec-qt-wallet.vcxproj*
|
zec-qt-wallet.vcxproj*
|
||||||
|
zec-qt-wallet.pro.user
|
||||||
Makefile
|
Makefile
|
||||||
Makefile.*
|
Makefile.*
|
||||||
qrc_application.cpp
|
qrc_application.cpp
|
||||||
|
|||||||
@@ -268,7 +268,9 @@ void MainWindow::setupTransactionsTab() {
|
|||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
|
|
||||||
auto txModel = dynamic_cast<TxTableModel *>(ui->transactionsTable->model());
|
auto txModel = dynamic_cast<TxTableModel *>(ui->transactionsTable->model());
|
||||||
|
|
||||||
QString txid = txModel->getTxId(index.row());
|
QString txid = txModel->getTxId(index.row());
|
||||||
|
QString memo = txModel->getMemo(index.row());
|
||||||
|
|
||||||
menu.addAction("Copy txid", [=] () {
|
menu.addAction("Copy txid", [=] () {
|
||||||
QGuiApplication::clipboard()->setText(txid);
|
QGuiApplication::clipboard()->setText(txid);
|
||||||
@@ -283,6 +285,11 @@ void MainWindow::setupTransactionsTab() {
|
|||||||
}
|
}
|
||||||
QDesktopServices::openUrl(QUrl(url));
|
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));
|
menu.exec(ui->transactionsTable->viewport()->mapToGlobal(pos));
|
||||||
});
|
});
|
||||||
|
|||||||
23
src/rpc.cpp
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
|
// Process all txids, removing duplicates. This can happen if the same address
|
||||||
// appears multiple times in a single tx's outputs.
|
// appears multiple times in a single tx's outputs.
|
||||||
QSet<QString> txids;
|
QSet<QString> txids;
|
||||||
|
QMap<QString, QString> memos;
|
||||||
for (auto it = zaddrTxids->constBegin(); it != zaddrTxids->constEnd(); it++) {
|
for (auto it = zaddrTxids->constBegin(); it != zaddrTxids->constEnd(); it++) {
|
||||||
for (auto& i : it.value().get<json::array_t>()) {
|
for (auto& i : it.value().get<json::array_t>()) {
|
||||||
// Filter out change txs
|
// Filter out change txs
|
||||||
if (! i["change"].get<json::boolean_t>())
|
if (! i["change"].get<json::boolean_t>()) {
|
||||||
txids.insert(QString::fromStdString(i["txid"].get<json::string_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 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);
|
txdata.push_front(tx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -602,7 +615,7 @@ void RPC::refreshTransactions() {
|
|||||||
QString::fromStdString(it["txid"]),
|
QString::fromStdString(it["txid"]),
|
||||||
it["amount"].get<json::number_float_t>() + fee,
|
it["amount"].get<json::number_float_t>() + fee,
|
||||||
it["confirmations"].get<json::number_unsigned_t>(),
|
it["confirmations"].get<json::number_unsigned_t>(),
|
||||||
""
|
"", ""
|
||||||
};
|
};
|
||||||
|
|
||||||
txdata.push_back(tx);
|
txdata.push_back(tx);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ struct TransactionItem {
|
|||||||
double amount;
|
double amount;
|
||||||
unsigned long confirmations;
|
unsigned long confirmations;
|
||||||
QString fromAddr;
|
QString fromAddr;
|
||||||
|
QString memo;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RPC
|
class RPC
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ QList<TransactionItem> SentTxStore::readSentTxFile() {
|
|||||||
sentTx["address"].toString(),
|
sentTx["address"].toString(),
|
||||||
sentTx["txid"].toString(),
|
sentTx["txid"].toString(),
|
||||||
sentTx["amount"].toDouble() + sentTx["fee"].toDouble(),
|
sentTx["amount"].toDouble() + sentTx["fee"].toDouble(),
|
||||||
0, sentTx["from"].toString()};
|
0, sentTx["from"].toString(), ""};
|
||||||
items.push_back(t);
|
items.push_back(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,4 +131,8 @@ void TxTableModel::updateAllData() {
|
|||||||
|
|
||||||
QString TxTableModel::getTxId(int row) {
|
QString TxTableModel::getTxId(int row) {
|
||||||
return modeldata->at(row).txid;
|
return modeldata->at(row).txid;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TxTableModel::getMemo(int row) {
|
||||||
|
return modeldata->at(row).memo;
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,7 @@ public:
|
|||||||
void addZRecvData(const QList<TransactionItem>& data);
|
void addZRecvData(const QList<TransactionItem>& data);
|
||||||
|
|
||||||
QString getTxId(int row);
|
QString getTxId(int row);
|
||||||
|
QString getMemo(int row);
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent) const;
|
int rowCount(const QModelIndex &parent) const;
|
||||||
int columnCount(const QModelIndex &parent) const;
|
int columnCount(const QModelIndex &parent) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user