#75 Indicate if an address has been previously used
This commit is contained in:
parent
e2b65c6047
commit
1e954818b3
|
@ -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
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
|
@ -749,7 +749,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<item row="4" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_16">
|
||||
<item>
|
||||
<widget class="QPushButton" name="exportKey">
|
||||
|
@ -773,6 +773,20 @@
|
|||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
</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
|
||||
txTimer->start(Settings::updateSpeed);
|
||||
|
||||
usedAddresses = new QMap<QString, bool>();
|
||||
}
|
||||
|
||||
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<QString> zaddrs) {
|
|||
for (auto it = zaddrTxids->constBegin(); it != zaddrTxids->constEnd(); it++) {
|
||||
auto zaddr = it.key();
|
||||
for (auto& i : it.value().get<json::array_t>()) {
|
||||
// Mark the address as used
|
||||
usedAddresses->insert(zaddr, true);
|
||||
|
||||
// Filter out change txs
|
||||
if (! i["change"].get<json::boolean_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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>();
|
||||
}
|
||||
|
||||
QString address = (it["address"].is_null() ? "" : QString::fromStdString(it["address"]));
|
||||
|
||||
TransactionItem tx{
|
||||
QString::fromStdString(it["category"]),
|
||||
(qint64)it["time"].get<json::number_unsigned_t>(),
|
||||
(it["address"].is_null() ? "" : QString::fromStdString(it["address"])),
|
||||
address,
|
||||
QString::fromStdString(it["txid"]),
|
||||
it["amount"].get<json::number_float_t>() + fee,
|
||||
(unsigned long)it["confirmations"].get<json::number_unsigned_t>(),
|
||||
"", "" };
|
||||
|
||||
txdata.push_back(tx);
|
||||
if (!address.isEmpty())
|
||||
usedAddresses->insert(address, true);
|
||||
}
|
||||
|
||||
// Update model data, which updates the table view
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
const QList<QString>* getAllZAddresses() { return zaddresses; }
|
||||
const QList<UnspentOutput>* getUTXOs() { return utxos; }
|
||||
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 newTaddr(const std::function<void(json)>& cb);
|
||||
|
@ -93,6 +94,7 @@ private:
|
|||
|
||||
QList<UnspentOutput>* utxos = nullptr;
|
||||
QMap<QString, double>* allBalances = nullptr;
|
||||
QMap<QString, bool>* usedAddresses = nullptr;
|
||||
QList<QString>* zaddresses = nullptr;
|
||||
|
||||
QMap<QString, Tx> watchingOps;
|
||||
|
|
|
@ -379,8 +379,6 @@ void MainWindow::maxAmountChecked(int checked) {
|
|||
sumAllAmounts += Settings::getMinerFee();
|
||||
}
|
||||
|
||||
|
||||
|
||||
auto addr = ui->inputsCombo->currentText();
|
||||
|
||||
auto maxamount = rpc->getAllBalances()->value(addr) - sumAllAmounts;
|
||||
|
|
Loading…
Reference in New Issue