#75 Indicate if an address has been previously used
This commit is contained in:
@@ -1054,7 +1054,6 @@ void MainWindow::setupRecieveTab() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// zAddr toggle button, one for sprout and one for sapling
|
// zAddr toggle button, one for sprout and one for sapling
|
||||||
QObject::connect(ui->rdioZAddr, &QRadioButton::toggled, addZAddrsToComboList(false));
|
QObject::connect(ui->rdioZAddr, &QRadioButton::toggled, addZAddrsToComboList(false));
|
||||||
QObject::connect(ui->rdioZSAddr, &QRadioButton::toggled, addZAddrsToComboList(true));
|
QObject::connect(ui->rdioZSAddr, &QRadioButton::toggled, addZAddrsToComboList(true));
|
||||||
@@ -1116,6 +1115,7 @@ void MainWindow::setupRecieveTab() {
|
|||||||
ui->rcvBal->clear();
|
ui->rcvBal->clear();
|
||||||
ui->txtRecieve->clear();
|
ui->txtRecieve->clear();
|
||||||
ui->qrcodeDisplay->clear();
|
ui->qrcodeDisplay->clear();
|
||||||
|
ui->lblUsed->clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1126,11 +1126,17 @@ void MainWindow::setupRecieveTab() {
|
|||||||
else {
|
else {
|
||||||
ui->rcvUpdateLabel->setText("Update Label");
|
ui->rcvUpdateLabel->setText("Update Label");
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->rcvLabel->setText(label);
|
ui->rcvLabel->setText(label);
|
||||||
ui->rcvBal->setText(Settings::getZECUSDDisplayFormat(rpc->getAllBalances()->value(addr)));
|
ui->rcvBal->setText(Settings::getZECUSDDisplayFormat(rpc->getAllBalances()->value(addr)));
|
||||||
ui->txtRecieve->setPlainText(addr);
|
ui->txtRecieve->setPlainText(addr);
|
||||||
ui->qrcodeDisplay->setAddress(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
|
// Recieve tab add/update label
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -749,7 +749,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1" colspan="2">
|
<item row="4" column="1" colspan="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_16">
|
<layout class="QHBoxLayout" name="horizontalLayout_16">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="exportKey">
|
<widget class="QPushButton" name="exportKey">
|
||||||
@@ -773,6 +773,20 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_15">
|
||||||
|
<property name="text">
|
||||||
|
<string>Address used</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1" colspan="2">
|
||||||
|
<widget class="QLabel" name="lblUsed">
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
14
src/rpc.cpp
14
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
|
// Start at every 10s. When an operation is pending, this will change to every second
|
||||||
txTimer->start(Settings::updateSpeed);
|
txTimer->start(Settings::updateSpeed);
|
||||||
|
|
||||||
|
usedAddresses = new QMap<QString, bool>();
|
||||||
}
|
}
|
||||||
|
|
||||||
RPC::~RPC() {
|
RPC::~RPC() {
|
||||||
@@ -60,6 +62,7 @@ RPC::~RPC() {
|
|||||||
|
|
||||||
delete utxos;
|
delete utxos;
|
||||||
delete allBalances;
|
delete allBalances;
|
||||||
|
delete usedAddresses;
|
||||||
delete zaddresses;
|
delete zaddresses;
|
||||||
|
|
||||||
delete conn;
|
delete conn;
|
||||||
@@ -410,6 +413,9 @@ void RPC::refreshReceivedZTrans(QList<QString> zaddrs) {
|
|||||||
for (auto it = zaddrTxids->constBegin(); it != zaddrTxids->constEnd(); it++) {
|
for (auto it = zaddrTxids->constBegin(); it != zaddrTxids->constEnd(); it++) {
|
||||||
auto zaddr = it.key();
|
auto zaddr = it.key();
|
||||||
for (auto& i : it.value().get<json::array_t>()) {
|
for (auto& i : it.value().get<json::array_t>()) {
|
||||||
|
// Mark the address as used
|
||||||
|
usedAddresses->insert(zaddr, true);
|
||||||
|
|
||||||
// Filter out change txs
|
// Filter out change txs
|
||||||
if (! i["change"].get<json::boolean_t>()) {
|
if (! i["change"].get<json::boolean_t>()) {
|
||||||
auto txid = QString::fromStdString(i["txid"].get<json::string_t>());
|
auto txid = QString::fromStdString(i["txid"].get<json::string_t>());
|
||||||
@@ -424,7 +430,7 @@ void RPC::refreshReceivedZTrans(QList<QString> zaddrs) {
|
|||||||
memos[zaddr + txid] = memo;
|
memos[zaddr + txid] = memo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. For all txids, go and get the details of that txid.
|
// 2. For all txids, go and get the details of that txid.
|
||||||
@@ -732,16 +738,20 @@ void RPC::refreshTransactions() {
|
|||||||
fee = it["fee"].get<json::number_float_t>();
|
fee = it["fee"].get<json::number_float_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString address = (it["address"].is_null() ? "" : QString::fromStdString(it["address"]));
|
||||||
|
|
||||||
TransactionItem tx{
|
TransactionItem tx{
|
||||||
QString::fromStdString(it["category"]),
|
QString::fromStdString(it["category"]),
|
||||||
(qint64)it["time"].get<json::number_unsigned_t>(),
|
(qint64)it["time"].get<json::number_unsigned_t>(),
|
||||||
(it["address"].is_null() ? "" : QString::fromStdString(it["address"])),
|
address,
|
||||||
QString::fromStdString(it["txid"]),
|
QString::fromStdString(it["txid"]),
|
||||||
it["amount"].get<json::number_float_t>() + fee,
|
it["amount"].get<json::number_float_t>() + fee,
|
||||||
(unsigned long)it["confirmations"].get<json::number_unsigned_t>(),
|
(unsigned long)it["confirmations"].get<json::number_unsigned_t>(),
|
||||||
"", "" };
|
"", "" };
|
||||||
|
|
||||||
txdata.push_back(tx);
|
txdata.push_back(tx);
|
||||||
|
if (!address.isEmpty())
|
||||||
|
usedAddresses->insert(address, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update model data, which updates the table view
|
// Update model data, which updates the table view
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public:
|
|||||||
const QList<QString>* getAllZAddresses() { return zaddresses; }
|
const QList<QString>* getAllZAddresses() { return zaddresses; }
|
||||||
const QList<UnspentOutput>* getUTXOs() { return utxos; }
|
const QList<UnspentOutput>* getUTXOs() { return utxos; }
|
||||||
const QMap<QString, double>* getAllBalances() { return allBalances; }
|
const QMap<QString, double>* getAllBalances() { return allBalances; }
|
||||||
|
const QMap<QString, bool>* getUsedAddresses() { return usedAddresses; }
|
||||||
|
|
||||||
void newZaddr(bool sapling, const std::function<void(json)>& cb);
|
void newZaddr(bool sapling, const std::function<void(json)>& cb);
|
||||||
void newTaddr(const std::function<void(json)>& cb);
|
void newTaddr(const std::function<void(json)>& cb);
|
||||||
@@ -93,6 +94,7 @@ private:
|
|||||||
|
|
||||||
QList<UnspentOutput>* utxos = nullptr;
|
QList<UnspentOutput>* utxos = nullptr;
|
||||||
QMap<QString, double>* allBalances = nullptr;
|
QMap<QString, double>* allBalances = nullptr;
|
||||||
|
QMap<QString, bool>* usedAddresses = nullptr;
|
||||||
QList<QString>* zaddresses = nullptr;
|
QList<QString>* zaddresses = nullptr;
|
||||||
|
|
||||||
QMap<QString, Tx> watchingOps;
|
QMap<QString, Tx> watchingOps;
|
||||||
|
|||||||
@@ -379,8 +379,6 @@ void MainWindow::maxAmountChecked(int checked) {
|
|||||||
sumAllAmounts += Settings::getMinerFee();
|
sumAllAmounts += Settings::getMinerFee();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
auto addr = ui->inputsCombo->currentText();
|
auto addr = ui->inputsCombo->currentText();
|
||||||
|
|
||||||
auto maxamount = rpc->getAllBalances()->value(addr) - sumAllAmounts;
|
auto maxamount = rpc->getAllBalances()->value(addr) - sumAllAmounts;
|
||||||
|
|||||||
Reference in New Issue
Block a user