Skip to content

Commit 25d8161

Browse files
committed
Merge pull request #3676
29d4507 qt: Add option to (not) spend unconfirmed change (Wladimir J. van der Laan)
2 parents 085c621 + 29d4507 commit 25d8161

File tree

4 files changed

+101
-47
lines changed

4 files changed

+101
-47
lines changed

src/qt/forms/optionsdialog.ui

Lines changed: 83 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,52 +27,6 @@
2727
<string>&amp;Main</string>
2828
</attribute>
2929
<layout class="QVBoxLayout" name="verticalLayout_Main">
30-
<item>
31-
<widget class="QLabel" name="transactionFeeInfoLabel">
32-
<property name="text">
33-
<string>Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB.</string>
34-
</property>
35-
<property name="textFormat">
36-
<enum>Qt::PlainText</enum>
37-
</property>
38-
<property name="wordWrap">
39-
<bool>true</bool>
40-
</property>
41-
</widget>
42-
</item>
43-
<item>
44-
<layout class="QHBoxLayout" name="horizontalLayout_1_Main">
45-
<item>
46-
<widget class="QLabel" name="transactionFeeLabel">
47-
<property name="text">
48-
<string>Pay transaction &amp;fee</string>
49-
</property>
50-
<property name="textFormat">
51-
<enum>Qt::PlainText</enum>
52-
</property>
53-
<property name="buddy">
54-
<cstring>transactionFee</cstring>
55-
</property>
56-
</widget>
57-
</item>
58-
<item>
59-
<widget class="BitcoinAmountField" name="transactionFee"/>
60-
</item>
61-
<item>
62-
<spacer name="horizontalSpacer_1_Main">
63-
<property name="orientation">
64-
<enum>Qt::Horizontal</enum>
65-
</property>
66-
<property name="sizeHint" stdset="0">
67-
<size>
68-
<width>40</width>
69-
<height>20</height>
70-
</size>
71-
</property>
72-
</spacer>
73-
</item>
74-
</layout>
75-
</item>
7630
<item>
7731
<widget class="QCheckBox" name="bitcoinAtStartup">
7832
<property name="toolTip">
@@ -194,6 +148,89 @@
194148
</item>
195149
</layout>
196150
</widget>
151+
<widget class="QWidget" name="tabWallet">
152+
<attribute name="title">
153+
<string>W&amp;allet</string>
154+
</attribute>
155+
<layout class="QVBoxLayout" name="verticalLayout_Network">
156+
<item>
157+
<widget class="QLabel" name="transactionFeeInfoLabel">
158+
<property name="text">
159+
<string>Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB.</string>
160+
</property>
161+
<property name="textFormat">
162+
<enum>Qt::PlainText</enum>
163+
</property>
164+
<property name="wordWrap">
165+
<bool>true</bool>
166+
</property>
167+
</widget>
168+
</item>
169+
<item>
170+
<layout class="QHBoxLayout" name="horizontalLayout_1_Main">
171+
<item>
172+
<widget class="QLabel" name="transactionFeeLabel">
173+
<property name="text">
174+
<string>Pay transaction &amp;fee</string>
175+
</property>
176+
<property name="textFormat">
177+
<enum>Qt::PlainText</enum>
178+
</property>
179+
<property name="buddy">
180+
<cstring>transactionFee</cstring>
181+
</property>
182+
</widget>
183+
</item>
184+
<item>
185+
<widget class="BitcoinAmountField" name="transactionFee"/>
186+
</item>
187+
<item>
188+
<spacer name="horizontalSpacer_1_Main">
189+
<property name="orientation">
190+
<enum>Qt::Horizontal</enum>
191+
</property>
192+
<property name="sizeHint" stdset="0">
193+
<size>
194+
<width>40</width>
195+
<height>20</height>
196+
</size>
197+
</property>
198+
</spacer>
199+
</item>
200+
</layout>
201+
</item>
202+
<item>
203+
<widget class="QLabel" name="label">
204+
<property name="text">
205+
<string>If you disable the spending of unconfirmed change, the change from a transaction cannot be used until that transaction has at least one confirmation. This also affects how your balance is computed.</string>
206+
</property>
207+
<property name="wordWrap">
208+
<bool>true</bool>
209+
</property>
210+
</widget>
211+
</item>
212+
<item>
213+
<widget class="QCheckBox" name="spendZeroConfChange">
214+
<property name="text">
215+
<string>Spend unconfirmed change (experts only)</string>
216+
</property>
217+
</widget>
218+
</item>
219+
<item>
220+
<spacer name="verticalSpacer">
221+
<property name="orientation">
222+
<enum>Qt::Vertical</enum>
223+
</property>
224+
<property name="sizeHint" stdset="0">
225+
<size>
226+
<width>20</width>
227+
<height>40</height>
228+
</size>
229+
</property>
230+
</spacer>
231+
</item>
232+
</layout>
233+
</widget>
197234
<widget class="QWidget" name="tabNetwork">
198235
<attribute name="title">
199236
<string>&amp;Network</string>

src/qt/optionsdialog.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,14 @@ void OptionsDialog::setModel(OptionsModel *model)
148148
void OptionsDialog::setMapper()
149149
{
150150
/* Main */
151-
mapper->addMapping(ui->transactionFee, OptionsModel::Fee);
152151
mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup);
153152
mapper->addMapping(ui->threadsScriptVerif, OptionsModel::ThreadsScriptVerif);
154153
mapper->addMapping(ui->databaseCache, OptionsModel::DatabaseCache);
155154

155+
/* Wallet */
156+
mapper->addMapping(ui->transactionFee, OptionsModel::Fee);
157+
mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange);
158+
156159
/* Network */
157160
mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP);
158161

src/qt/optionsmodel.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ void OptionsModel::Init()
7676
nTransactionFee = settings.value("nTransactionFee").toLongLong(); // if -paytxfee is set, this will be overridden later in init.cpp
7777
if (mapArgs.count("-paytxfee"))
7878
strOverriddenByCommandLine += "-paytxfee ";
79+
80+
if (!settings.contains("bSpendZeroConfChange"))
81+
settings.setValue("bSpendZeroConfChange", true);
82+
if (!SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
83+
strOverriddenByCommandLine += "-spendzeroconfchange ";
7984
#endif
8085

8186
if (!settings.contains("nDatabaseCache"))
@@ -184,6 +189,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
184189
// Todo: Consider to revert back to use just nTransactionFee here, if we don't want
185190
// -paytxfee to update our QSettings!
186191
return settings.value("nTransactionFee");
192+
case SpendZeroConfChange:
193+
return settings.value("bSpendZeroConfChange");
187194
#endif
188195
case DisplayUnit:
189196
return nDisplayUnit;
@@ -274,6 +281,12 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
274281
settings.setValue("nTransactionFee", (qint64)nTransactionFee);
275282
emit transactionFeeChanged(nTransactionFee);
276283
break;
284+
case SpendZeroConfChange:
285+
if (settings.value("bSpendZeroConfChange") != value) {
286+
settings.setValue("bSpendZeroConfChange", value);
287+
setRestartRequired(true);
288+
}
289+
break;
277290
#endif
278291
case DisplayUnit:
279292
nDisplayUnit = value.toInt();

src/qt/optionsmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class OptionsModel : public QAbstractListModel
4040
CoinControlFeatures, // bool
4141
ThreadsScriptVerif, // int
4242
DatabaseCache, // int
43+
SpendZeroConfChange, // bool
4344
OptionIDRowCount,
4445
};
4546

0 commit comments

Comments
 (0)