Browse Source

Rename to save Z txs

recurring
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();
});
// 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
ui->tabWidget->setCurrentIndex(0);
@ -130,13 +122,13 @@ void MainWindow::setupSettingsModal() {
// Setup save sent check box
QObject::connect(settings.chkSaveTxs, &QCheckBox::stateChanged, [=](auto checked) {
Settings::getInstance()->setSaveSent(checked);
Settings::getInstance()->setSaveZtxs(checked);
});
// Setup clear button
QObject::connect(settings.btnClearSaved, &QCheckBox::clicked, [=]() {
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)) {
SentTxStore::deleteHistory();
// Reload after the clear button so existing txs disappear
@ -145,7 +137,7 @@ void MainWindow::setupSettingsModal() {
});
// Save sent transactions
settings.chkSaveTxs->setChecked(Settings::getInstance()->getSaveSent());
settings.chkSaveTxs->setChecked(Settings::getInstance()->getSaveZtxs());
// Connection Settings
QIntValidator validator(0, 65535);
@ -185,11 +177,12 @@ void MainWindow::setupSettingsModal() {
settings.port->text(),
settings.rpcuser->text(),
settings.rpcpassword->text());
this->rpc->reloadConnectionInfo();
}
// Then refresh everything.
this->rpc->reloadConnectionInfo();
this->rpc->refresh();
}
// Then refresh everything.
this->rpc->refresh();
};
});

18
src/rpc.cpp

@ -332,8 +332,21 @@ void RPC::getBatchRPC(
waitTimer->start(100);
}
/// Batch RPC methods
// Refresh received z txs by calling z_listreceivedbyaddress/gettransaction
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
getBatchRPC(zaddrs,
[=] (QString zaddr) {
@ -347,7 +360,8 @@ void RPC::refreshReceivedZTrans(QList<QString> zaddrs, QList<QString> txidFilter
return payload;
},
[=] (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;
for (auto it = zaddrTxids->constBegin(); it != zaddrTxids->constEnd(); it++) {
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) {
// Save transactions only if the settings are allowed
if (!Settings::getInstance()->getSaveSent())
if (!Settings::getInstance()->getSaveZtxs())
return;
QFile data(writeableFile());

12
src/settings.cpp

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

4
src/settings.h

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

10
src/settings.ui

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>441</width>
<height>430</height>
<width>455</width>
<height>391</height>
</rect>
</property>
<property name="windowTitle">
@ -155,7 +155,7 @@
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<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 name="wordWrap">
<bool>true</bool>
@ -165,14 +165,14 @@
<item row="2" column="1">
<widget class="QPushButton" name="btnClearSaved">
<property name="text">
<string>Clear Saved</string>
<string>Delete History</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="chkSaveTxs">
<property name="text">
<string>Save sent shielded transactions</string>
<string>Remember Shielded Transactions</string>
</property>
</widget>
</item>

4
src/txtablemodel.cpp

@ -40,7 +40,7 @@ void TxTableModel::addTData(const QList<TransactionItem>& data) {
void TxTableModel::updateAllData() {
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 (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) {
return a.datetime > b.datetime; // reverse sort
});
// And then swap out the modeldata with the new one.
delete modeldata;
modeldata = newmodeldata;

8
src/ui_settings.h

@ -58,7 +58,7 @@ public:
{
if (Settings->objectName().isEmpty())
Settings->setObjectName(QStringLiteral("Settings"));
Settings->resize(441, 430);
Settings->resize(455, 391);
Settings->setModal(true);
verticalLayout = new QVBoxLayout(Settings);
verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
@ -196,9 +196,9 @@ public:
label_3->setText(QApplication::translate("Settings", "RPC Username", nullptr));
label_4->setText(QApplication::translate("Settings", "RPC Password", 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));
btnClearSaved->setText(QApplication::translate("Settings", "Clear Saved", nullptr));
chkSaveTxs->setText(QApplication::translate("Settings", "Save sent shielded transactions", 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", "Delete History", nullptr));
chkSaveTxs->setText(QApplication::translate("Settings", "Remember Shielded Transactions", nullptr));
tabWidget->setTabText(tabWidget->indexOf(tab_2), QApplication::translate("Settings", "Options", nullptr));
} // retranslateUi

Loading…
Cancel
Save