Double opt in for custom fees
This commit is contained in:
@@ -375,6 +375,9 @@ void MainWindow::setupSettingsModal() {
|
||||
// Save sent transactions
|
||||
settings.chkSaveTxs->setChecked(Settings::getInstance()->getSaveZtxs());
|
||||
|
||||
// Custom fees
|
||||
settings.chkCustomFees->setChecked(Settings::getInstance()->getAllowCustomFees());
|
||||
|
||||
// Connection Settings
|
||||
QIntValidator validator(0, 65535);
|
||||
settings.port->setValidator(&validator);
|
||||
@@ -407,6 +410,13 @@ void MainWindow::setupSettingsModal() {
|
||||
settings.tabWidget->setCurrentIndex(0);
|
||||
|
||||
if (settingsDialog.exec() == QDialog::Accepted) {
|
||||
// Custom fees
|
||||
bool customFees = settings.chkCustomFees->isChecked();
|
||||
Settings::getInstance()->setAllowCustomFees(customFees);
|
||||
ui->minerFeeAmt->setReadOnly(!customFees);
|
||||
if (!customFees)
|
||||
ui->minerFeeAmt->setText(Settings::getDecimalString(Settings::getMinerFee()));
|
||||
|
||||
if (zcashConfLocation.isEmpty()) {
|
||||
// Save settings
|
||||
Settings::getInstance()->saveSettings(
|
||||
|
||||
@@ -327,8 +327,12 @@ void RPC::fillTxJsonParams(json& params, Tx tx) {
|
||||
// Add sender
|
||||
params.push_back(tx.fromAddr.toStdString());
|
||||
params.push_back(allRecepients);
|
||||
params.push_back(1); // minconf
|
||||
params.push_back(QString::number(tx.fee, 'f', 8).toDouble());
|
||||
|
||||
// Add fees if custom fees are allowed.
|
||||
if (Settings::getInstance()->getAllowCustomFees()) {
|
||||
params.push_back(1); // minconf
|
||||
params.push_back(QString::number(tx.fee, 'f', 8).toDouble());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -62,6 +62,8 @@ void MainWindow::setupSendTab() {
|
||||
});
|
||||
|
||||
// Fee amount changed
|
||||
// Disable custom fees if settings say no
|
||||
ui->minerFeeAmt->setReadOnly(!Settings::getInstance()->getAllowCustomFees());
|
||||
QObject::connect(ui->minerFeeAmt, &QLineEdit::textChanged, [=](auto txt) {
|
||||
ui->lblMinerFeeUSD->setText(Settings::getUSDFormat(txt.toDouble()));
|
||||
});
|
||||
@@ -381,7 +383,12 @@ Tx MainWindow::createTxFromSendPage() {
|
||||
tx.toAddrs.push_back( ToFields{addr, amt, memo, memo.toUtf8().toHex()} );
|
||||
}
|
||||
|
||||
tx.fee = ui->minerFeeAmt->text().toDouble();
|
||||
if (Settings::getInstance()->getAllowCustomFees()) {
|
||||
tx.fee = ui->minerFeeAmt->text().toDouble();
|
||||
} else {
|
||||
tx.fee = Settings::getMinerFee();
|
||||
}
|
||||
|
||||
return tx;
|
||||
}
|
||||
|
||||
@@ -490,11 +497,11 @@ bool MainWindow::confirmTx(Tx tx) {
|
||||
confirm.gridLayout->addWidget(minerFeeUSD, i, 2, 1, 1);
|
||||
minerFeeUSD->setText(Settings::getUSDFormat(tx.fee));
|
||||
|
||||
if (tx.fee == Settings::getMinerFee()) {
|
||||
if (Settings::getInstance()->getAllowCustomFees() && tx.fee != Settings::getMinerFee()) {
|
||||
confirm.warningLabel->setVisible(true);
|
||||
} else {
|
||||
// Default fee
|
||||
confirm.warningLabel->setVisible(false);
|
||||
} else {
|
||||
confirm.warningLabel->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,15 +5,6 @@
|
||||
|
||||
Settings* Settings::instance = nullptr;
|
||||
|
||||
bool Settings::getSaveZtxs() {
|
||||
// Load from the QT Settings.
|
||||
return QSettings().value("options/savesenttx", true).toBool();
|
||||
}
|
||||
|
||||
void Settings::setSaveZtxs(bool save) {
|
||||
QSettings().setValue("options/savesenttx", save);
|
||||
}
|
||||
|
||||
Settings* Settings::init() {
|
||||
if (instance == nullptr)
|
||||
instance = new Settings();
|
||||
@@ -102,6 +93,37 @@ double Settings::getZECPrice() {
|
||||
return zecPrice;
|
||||
}
|
||||
|
||||
|
||||
bool Settings::getAllowCustomFees() {
|
||||
// Load from the QT Settings.
|
||||
return QSettings().value("options/customfees", false).toBool();
|
||||
}
|
||||
|
||||
void Settings::setAllowCustomFees(bool allow) {
|
||||
QSettings().setValue("options/customfees", allow);
|
||||
}
|
||||
|
||||
bool Settings::getSaveZtxs() {
|
||||
// Load from the QT Settings.
|
||||
return QSettings().value("options/savesenttx", true).toBool();
|
||||
}
|
||||
|
||||
void Settings::setSaveZtxs(bool save) {
|
||||
QSettings().setValue("options/savesenttx", save);
|
||||
}
|
||||
|
||||
|
||||
//=================================
|
||||
// Static Stuff
|
||||
//=================================
|
||||
void Settings::saveRestore(QDialog* d) {
|
||||
d->restoreGeometry(QSettings().value(d->objectName() % "geometry").toByteArray());
|
||||
|
||||
QObject::connect(d, &QDialog::finished, [=](auto) {
|
||||
QSettings().setValue(d->objectName() % "geometry", d->saveGeometry());
|
||||
});
|
||||
}
|
||||
|
||||
QString Settings::getUSDFormat(double bal) {
|
||||
if (!Settings::getInstance()->isTestnet() && Settings::getInstance()->getZECPrice() > 0)
|
||||
return "$" + QLocale(QLocale::English).toString(bal * Settings::getInstance()->getZECPrice(), 'f', 2);
|
||||
@@ -131,18 +153,6 @@ QString Settings::getZECUSDDisplayFormat(double bal) {
|
||||
return getZECDisplayFormat(bal);
|
||||
}
|
||||
|
||||
void Settings::saveRestore(QDialog* d) {
|
||||
d->restoreGeometry(QSettings().value(d->objectName() % "geometry").toByteArray());
|
||||
|
||||
QObject::connect(d, &QDialog::finished, [=](auto) {
|
||||
QSettings().setValue(d->objectName() % "geometry", d->saveGeometry());
|
||||
});
|
||||
}
|
||||
|
||||
//=================================
|
||||
// Static Stuff
|
||||
//=================================
|
||||
|
||||
const QString Settings::txidStatusMessage = QString("Tx submitted (right click to copy) txid:");
|
||||
|
||||
const QString Settings::getTokenName() {
|
||||
|
||||
@@ -19,8 +19,6 @@ public:
|
||||
static Settings* init();
|
||||
static Settings* getInstance();
|
||||
|
||||
static void saveRestore(QDialog* d);
|
||||
|
||||
Config getSettings();
|
||||
void saveSettings(const QString& host, const QString& port, const QString& username, const QString& password);
|
||||
|
||||
@@ -46,6 +44,9 @@ public:
|
||||
bool getSaveZtxs();
|
||||
void setSaveZtxs(bool save);
|
||||
|
||||
bool getAllowCustomFees();
|
||||
void setAllowCustomFees(bool allow);
|
||||
|
||||
bool isSaplingActive();
|
||||
|
||||
void setUsingZcashConf(QString confLocation);
|
||||
@@ -56,6 +57,8 @@ public:
|
||||
|
||||
// Static stuff
|
||||
static const QString txidStatusMessage;
|
||||
|
||||
static void saveRestore(QDialog* d);
|
||||
|
||||
static QString getDecimalString(double amt);
|
||||
static QString getUSDFormat(double bal);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
@@ -172,11 +172,11 @@
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="chkSaveTxs">
|
||||
<property name="text">
|
||||
<string>Remember Shielded Transactions</string>
|
||||
<string>Remember shielded transactions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<item row="6" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -189,13 +189,30 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="chkCustomFees">
|
||||
<property name="text">
|
||||
<string>Allow custom fees</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Allow overriding the default fees when sending transactions. Enabling this option may comprimise your privacy since fees are transparent. </string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
Reference in New Issue
Block a user