Skip to content

Commit 368a6ef

Browse files
hebastoknst
authored andcommitted
Merge bitcoin-core/gui#390: Add SubFeeFromAmount to options
62b125f qt, refactor: Fix indentation (Prateek Sancheti) ad28b66 qt: Add SubFeeFromAmount option (Prateek Sancheti) Pull request description: This PR adds **_SubFeeFromAmount_** option which lets the user select their preferred setting of whether fee for a transaction is to be subtracted from the amount or not for future transactions. The setting chosen by the user is remembered even when the GUI mode is turned off. **_Functionality and Usage:_** - Go to `Settings > Options > Wallet` on _Windows/Linux_ or `bitcoin-qt > Preferences > Wallet` on _macOS_. - The checkbox **Subtract Fee From Amount** corresponds to the added option **SubFeeFromAmount**. - The preferred setting intended to be the default for all future send transactions should be selected by the user. - Click on **OK**. - Go to the **Send** tab in the wallet. - You shall notice, any new Send transaction created will have the preferred setting as chosen by the user.<br> (Try clicking on Add recipient or even restarting the Node in GUI) Attaching ScreenRecordings to explain the added feature. > Master.mov: Master Branch https://user-images.githubusercontent.com/54016434/127763378-be91837d-d0ab-4ae5-87c0-d303fa70a336.mov > PR.mov: PullRequest https://user-images.githubusercontent.com/54016434/127763404-05b834c1-4082-4fbd-9b05-1528ac898a21.mov Close #386 ACKs for top commit: Talkless: tACK 62b125f, tested on Debian Sid with 5.15.2 and it works as described. hebasto: re-ACK 62b125f, only removed the unused `SubFeeFromAmountChanged` signal since my [previous](bitcoin-core/gui#390 (review)) review. meshcollider: utACK 62b125f Tree-SHA512: 932ca89ae578a1e1c426561400d87cf005c231944feaf0f662ff8d88f32bdd65a927a090ea41510a15f8ec0ebcd5529672e9917720eb5ea85f413f081e45d5bb
1 parent 7df9788 commit 368a6ef

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

src/qt/forms/optionsdialog.ui

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
</property>
140140
<property name="checked">
141141
<bool>true</bool>
142-
</property>
142+
</property>
143143
</widget>
144144
</item>
145145
<item>
@@ -315,6 +315,16 @@
315315
</widget>
316316
<widget class="QWidget" name="pageWallet">
317317
<layout class="QVBoxLayout" name="verticalLayout_Wallet">
318+
<item>
319+
<widget class="QCheckBox" name="subFeeFromAmount">
320+
<property name="toolTip">
321+
<string extracomment="Tooltip text for Options window setting that sets subtracting the fee from a sending amount as default.">Whether to set subtract fee from amount as default or not.</string>
322+
</property>
323+
<property name="text">
324+
<string extracomment="An Options window setting to set subtracting the fee from a sending amount as default.">Subtract &amp;fee from amount by default</string>
325+
</property>
326+
</widget>
327+
</item>
318328
<item>
319329
<layout class="QVBoxLayout" name="verticalLayout_2">
320330
<item>

src/qt/optionsdialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ void OptionsDialog::setMapper()
325325

326326
/* Wallet */
327327
mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);
328+
mapper->addMapping(ui->subFeeFromAmount, OptionsModel::SubFeeFromAmount);
328329
mapper->addMapping(ui->keepChangeAddress, OptionsModel::KeepChangeAddress);
329330
mapper->addMapping(ui->showMasternodesTab, OptionsModel::ShowMasternodesTab);
330331
mapper->addMapping(ui->showGovernanceTab, OptionsModel::ShowGovernanceTab);

src/qt/optionsmodel.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ void OptionsModel::Init(bool resetSettings)
222222
if (!gArgs.SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
223223
addOverriddenOption("-spendzeroconfchange");
224224

225+
if (!settings.contains("SubFeeFromAmount")) {
226+
settings.setValue("SubFeeFromAmount", false);
227+
}
228+
m_sub_fee_from_amount = settings.value("SubFeeFromAmount", false).toBool();
229+
225230
// CoinJoin
226231
if (!settings.contains("nCoinJoinSessions"))
227232
settings.setValue("nCoinJoinSessions", DEFAULT_COINJOIN_SESSIONS);
@@ -458,6 +463,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
458463
#ifdef ENABLE_WALLET
459464
case SpendZeroConfChange:
460465
return settings.value("bSpendZeroConfChange");
466+
case SubFeeFromAmount:
467+
return m_sub_fee_from_amount;
461468
case ShowMasternodesTab:
462469
return settings.value("fShowMasternodesTab");
463470
case ShowGovernanceTab:
@@ -633,6 +640,10 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
633640
setRestartRequired(true);
634641
}
635642
break;
643+
case SubFeeFromAmount:
644+
m_sub_fee_from_amount = value.toBool();
645+
settings.setValue("SubFeeFromAmount", m_sub_fee_from_amount);
646+
break;
636647
case ShowGovernanceTab:
637648
if (settings.value("fShowGovernanceTab") != value) {
638649
settings.setValue("fShowGovernanceTab", value);

src/qt/optionsmodel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class OptionsModel : public QAbstractListModel
6767
FontWeightBold, // int
6868
Language, // QString
6969
CoinControlFeatures, // bool
70+
SubFeeFromAmount, // bool
7071
KeepChangeAddress, // bool
7172
ThreadsScriptVerif, // int
7273
Prune, // bool
@@ -105,6 +106,7 @@ class OptionsModel : public QAbstractListModel
105106
int getDisplayUnit() const { return nDisplayUnit; }
106107
QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; }
107108
bool getCoinControlFeatures() const { return fCoinControlFeatures; }
109+
bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; }
108110
bool getKeepChangeAddress() const { return fKeepChangeAddress; }
109111
bool getShowAdvancedCJUI() { return fShowAdvancedCJUI; }
110112
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
@@ -132,6 +134,7 @@ class OptionsModel : public QAbstractListModel
132134
int nDisplayUnit;
133135
QString strThirdPartyTxUrls;
134136
bool fCoinControlFeatures;
137+
bool m_sub_fee_from_amount;
135138
bool fKeepChangeAddress;
136139
bool fShowAdvancedCJUI;
137140
/* settings that were overridden by command-line */

src/qt/sendcoinsentry.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ void SendCoinsEntry::clear()
103103
ui->payTo->clear();
104104
ui->addAsLabel->clear();
105105
ui->payAmount->clear();
106-
ui->checkboxSubtractFeeFromAmount->setCheckState(Qt::Unchecked);
106+
if (model && model->getOptionsModel()) {
107+
ui->checkboxSubtractFeeFromAmount->setChecked(model->getOptionsModel()->getSubFeeFromAmount());
108+
}
107109
ui->messageTextLabel->clear();
108110
ui->messageTextLabel->hide();
109111
ui->messageLabel->hide();

0 commit comments

Comments
 (0)