diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index a29a40b..c0305ca 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1054,7 +1054,6 @@ void MainWindow::setupRecieveTab() {
}
});
-
// zAddr toggle button, one for sprout and one for sapling
QObject::connect(ui->rdioZAddr, &QRadioButton::toggled, addZAddrsToComboList(false));
QObject::connect(ui->rdioZSAddr, &QRadioButton::toggled, addZAddrsToComboList(true));
@@ -1116,6 +1115,7 @@ void MainWindow::setupRecieveTab() {
ui->rcvBal->clear();
ui->txtRecieve->clear();
ui->qrcodeDisplay->clear();
+ ui->lblUsed->clear();
return;
}
@@ -1126,11 +1126,17 @@ void MainWindow::setupRecieveTab() {
else {
ui->rcvUpdateLabel->setText("Update Label");
}
-
+
ui->rcvLabel->setText(label);
ui->rcvBal->setText(Settings::getZECUSDDisplayFormat(rpc->getAllBalances()->value(addr)));
ui->txtRecieve->setPlainText(addr);
ui->qrcodeDisplay->setAddress(addr);
+ if (rpc->getUsedAddresses()->value(addr, false)) {
+ ui->lblUsed->setText(tr("Address has been previously used"));
+ } else {
+ ui->lblUsed->setText(tr("Address is unused"));
+ }
+
});
// Recieve tab add/update label
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index ea17051..917bc9d 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -22,7 +22,7 @@
-
- 1
+ 2
@@ -749,7 +749,7 @@
- -
+
-
-
@@ -773,6 +773,20 @@
+ -
+
+
+ Address used
+
+
+
+ -
+
+
+ TextLabel
+
+
+
-
diff --git a/src/rpc.cpp b/src/rpc.cpp
index 022b225..5bec7ca 100644
--- a/src/rpc.cpp
+++ b/src/rpc.cpp
@@ -48,6 +48,8 @@ RPC::RPC(MainWindow* main) {
});
// Start at every 10s. When an operation is pending, this will change to every second
txTimer->start(Settings::updateSpeed);
+
+ usedAddresses = new QMap();
}
RPC::~RPC() {
@@ -60,6 +62,7 @@ RPC::~RPC() {
delete utxos;
delete allBalances;
+ delete usedAddresses;
delete zaddresses;
delete conn;
@@ -410,6 +413,9 @@ void RPC::refreshReceivedZTrans(QList zaddrs) {
for (auto it = zaddrTxids->constBegin(); it != zaddrTxids->constEnd(); it++) {
auto zaddr = it.key();
for (auto& i : it.value().get()) {
+ // Mark the address as used
+ usedAddresses->insert(zaddr, true);
+
// Filter out change txs
if (! i["change"].get()) {
auto txid = QString::fromStdString(i["txid"].get());
@@ -424,7 +430,7 @@ void RPC::refreshReceivedZTrans(QList zaddrs) {
memos[zaddr + txid] = memo;
}
}
- }
+ }
}
// 2. For all txids, go and get the details of that txid.
@@ -732,16 +738,20 @@ void RPC::refreshTransactions() {
fee = it["fee"].get();
}
+ QString address = (it["address"].is_null() ? "" : QString::fromStdString(it["address"]));
+
TransactionItem tx{
QString::fromStdString(it["category"]),
(qint64)it["time"].get(),
- (it["address"].is_null() ? "" : QString::fromStdString(it["address"])),
+ address,
QString::fromStdString(it["txid"]),
it["amount"].get() + fee,
(unsigned long)it["confirmations"].get(),
"", "" };
txdata.push_back(tx);
+ if (!address.isEmpty())
+ usedAddresses->insert(address, true);
}
// Update model data, which updates the table view
diff --git a/src/rpc.h b/src/rpc.h
index 88b5bd5..358031c 100644
--- a/src/rpc.h
+++ b/src/rpc.h
@@ -50,6 +50,7 @@ public:
const QList* getAllZAddresses() { return zaddresses; }
const QList* getUTXOs() { return utxos; }
const QMap* getAllBalances() { return allBalances; }
+ const QMap* getUsedAddresses() { return usedAddresses; }
void newZaddr(bool sapling, const std::function& cb);
void newTaddr(const std::function& cb);
@@ -93,6 +94,7 @@ private:
QList* utxos = nullptr;
QMap* allBalances = nullptr;
+ QMap* usedAddresses = nullptr;
QList* zaddresses = nullptr;
QMap watchingOps;
diff --git a/src/sendtab.cpp b/src/sendtab.cpp
index efd196a..8f99194 100644
--- a/src/sendtab.cpp
+++ b/src/sendtab.cpp
@@ -379,8 +379,6 @@ void MainWindow::maxAmountChecked(int checked) {
sumAllAmounts += Settings::getMinerFee();
}
-
-
auto addr = ui->inputsCombo->currentText();
auto maxamount = rpc->getAllBalances()->value(addr) - sumAllAmounts;