Browse Source

Rename to save Z txs

import_zecw
Aditya Kulkarni 6 years ago
parent
commit
cdc46b3022
  1. 23
      src/mainwindow.cpp
  2. 18
      src/rpc.cpp
  3. 2
      src/senttxstore.cpp
  4. 12
      src/settings.cpp
  5. 4
      src/settings.h
  6. 10
      src/settings.ui
  7. 4
      src/txtablemodel.cpp
  8. 8
      src/ui_settings.h

23
src/mainwindow.cpp

@ -49,14 +49,6 @@ MainWindow::MainWindow(QWidget *parent) :
aboutDialog.exec(); aboutDialog.exec();
}); });
// Set up delete sent history action
QObject::connect(ui->actionDelete_Sent_History, &QAction::triggered, [=] () {
bool confirm = QMessageBox::information(this, "Delete Sent History?",
"Shielded z-Address sent transactions are stored locally in your wallet. You may delete this saved information safely any time for your privacy.\nDo you want to delete this now?",
QMessageBox::Yes, QMessageBox::No);
if (confirm) SentTxStore::deleteHistory();
});
// Initialize to the balances tab // Initialize to the balances tab
ui->tabWidget->setCurrentIndex(0); ui->tabWidget->setCurrentIndex(0);
@ -130,13 +122,13 @@ void MainWindow::setupSettingsModal() {
// Setup save sent check box // Setup save sent check box
QObject::connect(settings.chkSaveTxs, &QCheckBox::stateChanged, [=](auto checked) { QObject::connect(settings.chkSaveTxs, &QCheckBox::stateChanged, [=](auto checked) {
Settings::getInstance()->setSaveSent(checked); Settings::getInstance()->setSaveZtxs(checked);
}); });
// Setup clear button // Setup clear button
QObject::connect(settings.btnClearSaved, &QCheckBox::clicked, [=]() { QObject::connect(settings.btnClearSaved, &QCheckBox::clicked, [=]() {
if (QMessageBox::warning(this, "Clear saved history?", if (QMessageBox::warning(this, "Clear saved history?",
"Shielded z-Address sent transactions are stored locally in your wallet. You may delete this saved information safely any time for your privacy.\nDo you want to delete this now ?", "Shielded z-Address transactions are stored locally in your wallet, outside zcashd. You may delete this saved information safely any time for your privacy.\nDo you want to delete the saved shielded transactions now ?",
QMessageBox::Yes, QMessageBox::Cancel)) { QMessageBox::Yes, QMessageBox::Cancel)) {
SentTxStore::deleteHistory(); SentTxStore::deleteHistory();
// Reload after the clear button so existing txs disappear // Reload after the clear button so existing txs disappear
@ -145,7 +137,7 @@ void MainWindow::setupSettingsModal() {
}); });
// Save sent transactions // Save sent transactions
settings.chkSaveTxs->setChecked(Settings::getInstance()->getSaveSent()); settings.chkSaveTxs->setChecked(Settings::getInstance()->getSaveZtxs());
// Connection Settings // Connection Settings
QIntValidator validator(0, 65535); QIntValidator validator(0, 65535);
@ -185,11 +177,12 @@ void MainWindow::setupSettingsModal() {
settings.port->text(), settings.port->text(),
settings.rpcuser->text(), settings.rpcuser->text(),
settings.rpcpassword->text()); settings.rpcpassword->text());
this->rpc->reloadConnectionInfo();
}
// Then refresh everything. // Then refresh everything.
this->rpc->reloadConnectionInfo(); this->rpc->refresh();
this->rpc->refresh();
}
}; };
}); });

18
src/rpc.cpp

@ -332,8 +332,21 @@ void RPC::getBatchRPC(
waitTimer->start(100); waitTimer->start(100);
} }
/// Batch RPC methods // Refresh received z txs by calling z_listreceivedbyaddress/gettransaction
void RPC::refreshReceivedZTrans(QList<QString> zaddrs, QList<QString> txidFilter) { void RPC::refreshReceivedZTrans(QList<QString> zaddrs, QList<QString> txidFilter) {
// We'll only refresh the received Z txs if settings allows us.
if (!Settings::getInstance()->getSaveZtxs()) {
QList<TransactionItem> emptylist;
transactionsTableModel->addZRecvData(emptylist);
return;
}
// This method is complicated because z_listreceivedbyaddress only returns the txid, and
// we have to make a follow up call to gettransaction to get details of that transaction.
// Additionally, it has to be done in batches, because there are multiple z-Addresses,
// and each z-Addr can have multiple received txs.
// 1. For each z-Addr, get list of received txs // 1. For each z-Addr, get list of received txs
getBatchRPC(zaddrs, getBatchRPC(zaddrs,
[=] (QString zaddr) { [=] (QString zaddr) {
@ -347,7 +360,8 @@ void RPC::refreshReceivedZTrans(QList<QString> zaddrs, QList<QString> txidFilter
return payload; return payload;
}, },
[=] (QMap<QString, json>* zaddrTxids) { [=] (QMap<QString, json>* zaddrTxids) {
// Process all txids // Process all txids, removing duplicates. This can happen if the same address
// appears multiple times in a single tx's outputs.
QSet<QString> txids; QSet<QString> txids;
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>()) {

2
src/senttxstore.cpp

@ -51,7 +51,7 @@ QList<TransactionItem> SentTxStore::readSentTxFile() {
void SentTxStore::addToSentTx(Tx tx, QString txid) { void SentTxStore::addToSentTx(Tx tx, QString txid) {
// Save transactions only if the settings are allowed // Save transactions only if the settings are allowed
if (!Settings::getInstance()->getSaveSent()) if (!Settings::getInstance()->getSaveZtxs())
return; return;
QFile data(writeableFile()); QFile data(writeableFile());

12
src/settings.cpp

@ -11,17 +11,13 @@ Settings::~Settings() {
delete uisettings; delete uisettings;
} }
bool Settings::getSaveSent() { bool Settings::getSaveZtxs() {
// Load from the QT Settings. // Load from the QT Settings.
QSettings s; return QSettings().value("options/savesenttx", true).toBool();
return s.value("options/savesenttx", true).toBool();
} }
void Settings::setSaveSent(bool savesent) { void Settings::setSaveZtxs(bool save) {
QSettings s; QSettings().setValue("options/savesenttx", save);
s.setValue("options/savesenttx", savesent);
} }
Settings* Settings::init() { Settings* Settings::init() {

4
src/settings.h

@ -36,8 +36,8 @@ public:
int getBlockNumber(); int getBlockNumber();
void setBlockNumber(int number); void setBlockNumber(int number);
bool getSaveSent(); bool getSaveZtxs();
void setSaveSent(bool savesent); void setSaveZtxs(bool save);
bool isSaplingActive(); bool isSaplingActive();

10
src/settings.ui

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>441</width> <width>455</width>
<height>430</height> <height>391</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -155,7 +155,7 @@
<item row="1" column="0" colspan="2"> <item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
<string>Outgoing shielded transactions can be saved locally in the UI for convinence. These are not saved with zcashd.</string> <string>Shielded transactions are saved locally and shown in the Transactions tab. If you uncheck this, shielded transactions will not appear in the transactions tab.</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
@ -165,14 +165,14 @@
<item row="2" column="1"> <item row="2" column="1">
<widget class="QPushButton" name="btnClearSaved"> <widget class="QPushButton" name="btnClearSaved">
<property name="text"> <property name="text">
<string>Clear Saved</string> <string>Delete History</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="chkSaveTxs"> <widget class="QCheckBox" name="chkSaveTxs">
<property name="text"> <property name="text">
<string>Save sent shielded transactions</string> <string>Remember Shielded Transactions</string>
</property> </property>
</widget> </widget>
</item> </item>

4
src/txtablemodel.cpp

@ -40,7 +40,7 @@ void TxTableModel::addTData(const QList<TransactionItem>& data) {
void TxTableModel::updateAllData() { void TxTableModel::updateAllData() {
auto newmodeldata = new QList<TransactionItem>(); auto newmodeldata = new QList<TransactionItem>();
if (tTrans != nullptr) std::copy( tTrans->begin(), tTrans->end(), std::back_inserter(*newmodeldata)); if (tTrans != nullptr) std::copy( tTrans->begin(), tTrans->end(), std::back_inserter(*newmodeldata));
if (zsTrans != nullptr) std::copy(zsTrans->begin(), zsTrans->end(), std::back_inserter(*newmodeldata)); if (zsTrans != nullptr) std::copy(zsTrans->begin(), zsTrans->end(), std::back_inserter(*newmodeldata));
if (zrTrans != nullptr) std::copy(zrTrans->begin(), zrTrans->end(), std::back_inserter(*newmodeldata)); if (zrTrans != nullptr) std::copy(zrTrans->begin(), zrTrans->end(), std::back_inserter(*newmodeldata));
@ -48,7 +48,7 @@ void TxTableModel::updateAllData() {
std::sort(newmodeldata->begin(), newmodeldata->end(), [=] (auto a, auto b) { std::sort(newmodeldata->begin(), newmodeldata->end(), [=] (auto a, auto b) {
return a.datetime > b.datetime; // reverse sort return a.datetime > b.datetime; // reverse sort
}); });
// And then swap out the modeldata with the new one. // And then swap out the modeldata with the new one.
delete modeldata; delete modeldata;
modeldata = newmodeldata; modeldata = newmodeldata;

8
src/ui_settings.h

@ -58,7 +58,7 @@ public:
{ {
if (Settings->objectName().isEmpty()) if (Settings->objectName().isEmpty())
Settings->setObjectName(QStringLiteral("Settings")); Settings->setObjectName(QStringLiteral("Settings"));
Settings->resize(441, 430); Settings->resize(455, 391);
Settings->setModal(true); Settings->setModal(true);
verticalLayout = new QVBoxLayout(Settings); verticalLayout = new QVBoxLayout(Settings);
verticalLayout->setObjectName(QStringLiteral("verticalLayout")); verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
@ -196,9 +196,9 @@ public:
label_3->setText(QApplication::translate("Settings", "RPC Username", nullptr)); label_3->setText(QApplication::translate("Settings", "RPC Username", nullptr));
label_4->setText(QApplication::translate("Settings", "RPC Password", nullptr)); label_4->setText(QApplication::translate("Settings", "RPC Password", nullptr));
tabWidget->setTabText(tabWidget->indexOf(tab), QApplication::translate("Settings", "zcashd connection", nullptr)); tabWidget->setTabText(tabWidget->indexOf(tab), QApplication::translate("Settings", "zcashd connection", nullptr));
label_5->setText(QApplication::translate("Settings", "Outgoing shielded transactions can be saved locally in the UI for convinence. These are not saved with zcashd.", nullptr)); label_5->setText(QApplication::translate("Settings", "Shielded transactions are saved locally and shown in the Transactions tab. If you uncheck this, shielded transactions will not appear in the transactions tab.", nullptr));
btnClearSaved->setText(QApplication::translate("Settings", "Clear Saved", nullptr)); btnClearSaved->setText(QApplication::translate("Settings", "Delete History", nullptr));
chkSaveTxs->setText(QApplication::translate("Settings", "Save sent shielded transactions", nullptr)); chkSaveTxs->setText(QApplication::translate("Settings", "Remember Shielded Transactions", nullptr));
tabWidget->setTabText(tabWidget->indexOf(tab_2), QApplication::translate("Settings", "Options", nullptr)); tabWidget->setTabText(tabWidget->indexOf(tab_2), QApplication::translate("Settings", "Options", nullptr));
} // retranslateUi } // retranslateUi

Loading…
Cancel
Save