diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui
index 8f53b2fa8c..300e2520e9 100644
--- a/src/qt/forms/optionsdialog.ui
+++ b/src/qt/forms/optionsdialog.ui
@@ -139,7 +139,7 @@
true
-
+
-
@@ -315,6 +315,16 @@
+
-
+
+
+ Whether to set subtract fee from amount as default or not.
+
+
+ Subtract &fee from amount by default
+
+
+
-
-
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index a5587373bb..5337fb163c 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -325,6 +325,7 @@ void OptionsDialog::setMapper()
/* Wallet */
mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);
+ mapper->addMapping(ui->subFeeFromAmount, OptionsModel::SubFeeFromAmount);
mapper->addMapping(ui->keepChangeAddress, OptionsModel::KeepChangeAddress);
mapper->addMapping(ui->showMasternodesTab, OptionsModel::ShowMasternodesTab);
mapper->addMapping(ui->showGovernanceTab, OptionsModel::ShowGovernanceTab);
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 874a255b84..fcf84bf5ec 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -222,6 +222,11 @@ void OptionsModel::Init(bool resetSettings)
if (!gArgs.SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
addOverriddenOption("-spendzeroconfchange");
+ if (!settings.contains("SubFeeFromAmount")) {
+ settings.setValue("SubFeeFromAmount", false);
+ }
+ m_sub_fee_from_amount = settings.value("SubFeeFromAmount", false).toBool();
+
// CoinJoin
if (!settings.contains("nCoinJoinSessions"))
settings.setValue("nCoinJoinSessions", DEFAULT_COINJOIN_SESSIONS);
@@ -458,6 +463,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
#ifdef ENABLE_WALLET
case SpendZeroConfChange:
return settings.value("bSpendZeroConfChange");
+ case SubFeeFromAmount:
+ return m_sub_fee_from_amount;
case ShowMasternodesTab:
return settings.value("fShowMasternodesTab");
case ShowGovernanceTab:
@@ -633,6 +640,10 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
setRestartRequired(true);
}
break;
+ case SubFeeFromAmount:
+ m_sub_fee_from_amount = value.toBool();
+ settings.setValue("SubFeeFromAmount", m_sub_fee_from_amount);
+ break;
case ShowGovernanceTab:
if (settings.value("fShowGovernanceTab") != value) {
settings.setValue("fShowGovernanceTab", value);
diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h
index b34804ed21..eaf4a8f6f8 100644
--- a/src/qt/optionsmodel.h
+++ b/src/qt/optionsmodel.h
@@ -67,6 +67,7 @@ public:
FontWeightBold, // int
Language, // QString
CoinControlFeatures, // bool
+ SubFeeFromAmount, // bool
KeepChangeAddress, // bool
ThreadsScriptVerif, // int
Prune, // bool
@@ -105,6 +106,7 @@ public:
int getDisplayUnit() const { return nDisplayUnit; }
QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; }
bool getCoinControlFeatures() const { return fCoinControlFeatures; }
+ bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; }
bool getKeepChangeAddress() const { return fKeepChangeAddress; }
bool getShowAdvancedCJUI() { return fShowAdvancedCJUI; }
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
@@ -132,6 +134,7 @@ private:
int nDisplayUnit;
QString strThirdPartyTxUrls;
bool fCoinControlFeatures;
+ bool m_sub_fee_from_amount;
bool fKeepChangeAddress;
bool fShowAdvancedCJUI;
/* settings that were overridden by command-line */
diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp
index 7fea4dcbec..004c7853c0 100644
--- a/src/qt/sendcoinsentry.cpp
+++ b/src/qt/sendcoinsentry.cpp
@@ -103,7 +103,9 @@ void SendCoinsEntry::clear()
ui->payTo->clear();
ui->addAsLabel->clear();
ui->payAmount->clear();
- ui->checkboxSubtractFeeFromAmount->setCheckState(Qt::Unchecked);
+ if (model && model->getOptionsModel()) {
+ ui->checkboxSubtractFeeFromAmount->setChecked(model->getOptionsModel()->getSubFeeFromAmount());
+ }
ui->messageTextLabel->clear();
ui->messageTextLabel->hide();
ui->messageLabel->hide();