@@ -43,6 +43,8 @@ static const char* SettingName(OptionsModel::OptionID option)
43
43
case OptionsModel::ExternalSignerPath: return " signer" ;
44
44
case OptionsModel::MapPortUPnP: return " upnp" ;
45
45
case OptionsModel::MapPortNatpmp: return " natpmp" ;
46
+ case OptionsModel::Listen: return " listen" ;
47
+ case OptionsModel::Server: return " server" ;
46
48
default : throw std::logic_error (strprintf (" GUI option %i has no corresponding node setting." , option));
47
49
}
48
50
}
@@ -131,7 +133,7 @@ bool OptionsModel::Init(bilingual_str& error)
131
133
// These are shared with the core or have a command-line parameter
132
134
// and we want command-line parameters to overwrite the GUI settings.
133
135
for (OptionID option : {DatabaseCache, ThreadsScriptVerif, SpendZeroConfChange, ExternalSignerPath, MapPortUPnP,
134
- MapPortNatpmp}) {
136
+ MapPortNatpmp, Listen, Server }) {
135
137
std::string setting = SettingName (option);
136
138
if (node ().isSettingIgnored (setting)) addOverriddenOption (" -" + setting);
137
139
try {
@@ -168,37 +170,6 @@ bool OptionsModel::Init(bilingual_str& error)
168
170
#endif
169
171
170
172
// Network
171
- if (!settings.contains (" fListen" ))
172
- settings.setValue (" fListen" , DEFAULT_LISTEN);
173
- const bool listen{settings.value (" fListen" ).toBool ()};
174
- if (!gArgs .SoftSetBoolArg (" -listen" , listen)) {
175
- addOverriddenOption (" -listen" );
176
- } else if (!listen) {
177
- // We successfully set -listen=0, thus mimic the logic from InitParameterInteraction():
178
- // "parameter interaction: -listen=0 -> setting -listenonion=0".
179
- //
180
- // Both -listen and -listenonion default to true.
181
- //
182
- // The call order is:
183
- //
184
- // InitParameterInteraction()
185
- // would set -listenonion=0 if it sees -listen=0, but for bitcoin-qt with
186
- // fListen=false -listen is 1 at this point
187
- //
188
- // OptionsModel::Init()
189
- // (this method) can flip -listen from 1 to 0 if fListen=false
190
- //
191
- // AppInitParameterInteraction()
192
- // raises an error if -listen=0 and -listenonion=1
193
- gArgs .SoftSetBoolArg (" -listenonion" , false );
194
- }
195
-
196
- if (!settings.contains (" server" )) {
197
- settings.setValue (" server" , false );
198
- }
199
- if (!gArgs .SoftSetBoolArg (" -server" , settings.value (" server" ).toBool ())) {
200
- addOverriddenOption (" -server" );
201
- }
202
173
203
174
if (!settings.contains (" fUseProxy" ))
204
175
settings.setValue (" fUseProxy" , false );
@@ -439,9 +410,9 @@ QVariant OptionsModel::getOption(OptionID option) const
439
410
case ThreadsScriptVerif:
440
411
return qlonglong (SettingToInt (setting (), DEFAULT_SCRIPTCHECK_THREADS));
441
412
case Listen:
442
- return settings. value ( " fListen " );
413
+ return SettingToBool ( setting (), DEFAULT_LISTEN );
443
414
case Server:
444
- return settings. value ( " server " );
415
+ return SettingToBool ( setting (), false );
445
416
default :
446
417
return QVariant ();
447
418
}
@@ -610,14 +581,9 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value)
610
581
}
611
582
break ;
612
583
case Listen:
613
- if (settings.value (" fListen" ) != value) {
614
- settings.setValue (" fListen" , value);
615
- setRestartRequired (true );
616
- }
617
- break ;
618
584
case Server:
619
- if (settings. value ( " server " ) != value ) {
620
- settings. setValue ( " server " , value);
585
+ if (changed () ) {
586
+ update ( value. toBool () );
621
587
setRestartRequired (true );
622
588
}
623
589
break ;
@@ -697,4 +663,13 @@ void OptionsModel::checkAndMigrate()
697
663
#endif
698
664
migrate_setting (MapPortUPnP, " fUseUPnP" );
699
665
migrate_setting (MapPortNatpmp, " fUseNatpmp" );
666
+ migrate_setting (Listen, " fListen" );
667
+ migrate_setting (Server, " server" );
668
+
669
+ // In case migrating QSettings caused any settings value to change, rerun
670
+ // parameter interaction code to update other settings. This is particularly
671
+ // important for the -listen setting, which should cause -listenonion, -upnp,
672
+ // and other settings to default to false if it was set to false.
673
+ // (https://github.com/bitcoin-core/gui/issues/567).
674
+ node ().initParameterInteraction ();
700
675
}
0 commit comments