@@ -42,6 +42,8 @@ const char* SettingName(OptionsModel::OptionID option)
42
42
case OptionsModel::ExternalSignerPath: return " signer" ;
43
43
case OptionsModel::MapPortUPnP: return " upnp" ;
44
44
case OptionsModel::MapPortNatpmp: return " natpmp" ;
45
+ case OptionsModel::Listen: return " listen" ;
46
+ case OptionsModel::Server: return " server" ;
45
47
default : throw std::logic_error (strprintf (" GUI option %i has no corresponding node setting." , option));
46
48
};
47
49
}
@@ -126,7 +128,7 @@ bool OptionsModel::Init(bilingual_str& error)
126
128
// These are shared with the core or have a command-line parameter
127
129
// and we want command-line parameters to overwrite the GUI settings.
128
130
for (OptionID option : {DatabaseCache, ThreadsScriptVerif, SpendZeroConfChange, ExternalSignerPath, MapPortUPnP,
129
- MapPortNatpmp}) {
131
+ MapPortNatpmp, Listen, Server }) {
130
132
std::string setting = SettingName (option);
131
133
if (node ().isSettingIgnored (setting)) addOverriddenOption (" -" + setting);
132
134
try {
@@ -162,37 +164,6 @@ bool OptionsModel::Init(bilingual_str& error)
162
164
#endif
163
165
164
166
// Network
165
- if (!settings.contains (" fListen" ))
166
- settings.setValue (" fListen" , DEFAULT_LISTEN);
167
- const bool listen{settings.value (" fListen" ).toBool ()};
168
- if (!gArgs .SoftSetBoolArg (" -listen" , listen)) {
169
- addOverriddenOption (" -listen" );
170
- } else if (!listen) {
171
- // We successfully set -listen=0, thus mimic the logic from InitParameterInteraction():
172
- // "parameter interaction: -listen=0 -> setting -listenonion=0".
173
- //
174
- // Both -listen and -listenonion default to true.
175
- //
176
- // The call order is:
177
- //
178
- // InitParameterInteraction()
179
- // would set -listenonion=0 if it sees -listen=0, but for bitcoin-qt with
180
- // fListen=false -listen is 1 at this point
181
- //
182
- // OptionsModel::Init()
183
- // (this method) can flip -listen from 1 to 0 if fListen=false
184
- //
185
- // AppInitParameterInteraction()
186
- // raises an error if -listen=0 and -listenonion=1
187
- gArgs .SoftSetBoolArg (" -listenonion" , false );
188
- }
189
-
190
- if (!settings.contains (" server" )) {
191
- settings.setValue (" server" , false );
192
- }
193
- if (!gArgs .SoftSetBoolArg (" -server" , settings.value (" server" ).toBool ())) {
194
- addOverriddenOption (" -server" );
195
- }
196
167
197
168
if (!settings.contains (" fUseProxy" ))
198
169
settings.setValue (" fUseProxy" , false );
@@ -433,9 +404,9 @@ QVariant OptionsModel::getOption(OptionID option) const
433
404
case ThreadsScriptVerif:
434
405
return qlonglong (SettingToInt (setting (), DEFAULT_SCRIPTCHECK_THREADS));
435
406
case Listen:
436
- return settings. value ( " fListen " );
407
+ return SettingToBool ( setting (), DEFAULT_LISTEN );
437
408
case Server:
438
- return settings. value ( " server " );
409
+ return SettingToBool ( setting (), false );
439
410
default :
440
411
return QVariant ();
441
412
}
@@ -604,14 +575,14 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value)
604
575
}
605
576
break ;
606
577
case Listen:
607
- if (settings. value ( " fListen " ) != value ) {
608
- settings. setValue ( " fListen " , value);
578
+ if (changed () ) {
579
+ update ( value. toBool () );
609
580
setRestartRequired (true );
610
581
}
611
582
break ;
612
583
case Server:
613
- if (settings. value ( " server " ) != value ) {
614
- settings. setValue ( " server " , value);
584
+ if (changed () ) {
585
+ update ( value. toBool () );
615
586
setRestartRequired (true );
616
587
}
617
588
break ;
@@ -691,4 +662,13 @@ void OptionsModel::checkAndMigrate()
691
662
#endif
692
663
migrate_setting (MapPortUPnP, " fUseUPnP" );
693
664
migrate_setting (MapPortNatpmp, " fUseNatpmp" );
665
+ migrate_setting (Listen, " fListen" );
666
+ migrate_setting (Server, " server" );
667
+
668
+ // In case migrating QSettings caused any settings value to change, rerun
669
+ // parameter interaction code to update other settings. This is particularly
670
+ // important for the -listen setting, which should cause -listenonion, -upnp,
671
+ // and other settings to default to false if it was set to false.
672
+ // (https://github.com/bitcoin-core/gui/issues/567).
673
+ node ().initParameterInteraction ();
694
674
}
0 commit comments