@@ -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 {
@@ -167,37 +169,6 @@ bool OptionsModel::Init(bilingual_str& error)
167
169
#endif
168
170
169
171
// Network
170
- if (!settings.contains (" fListen" ))
171
- settings.setValue (" fListen" , DEFAULT_LISTEN);
172
- const bool listen{settings.value (" fListen" ).toBool ()};
173
- if (!gArgs .SoftSetBoolArg (" -listen" , listen)) {
174
- addOverriddenOption (" -listen" );
175
- } else if (!listen) {
176
- // We successfully set -listen=0, thus mimic the logic from InitParameterInteraction():
177
- // "parameter interaction: -listen=0 -> setting -listenonion=0".
178
- //
179
- // Both -listen and -listenonion default to true.
180
- //
181
- // The call order is:
182
- //
183
- // InitParameterInteraction()
184
- // would set -listenonion=0 if it sees -listen=0, but for bitcoin-qt with
185
- // fListen=false -listen is 1 at this point
186
- //
187
- // OptionsModel::Init()
188
- // (this method) can flip -listen from 1 to 0 if fListen=false
189
- //
190
- // AppInitParameterInteraction()
191
- // raises an error if -listen=0 and -listenonion=1
192
- gArgs .SoftSetBoolArg (" -listenonion" , false );
193
- }
194
-
195
- if (!settings.contains (" server" )) {
196
- settings.setValue (" server" , false );
197
- }
198
- if (!gArgs .SoftSetBoolArg (" -server" , settings.value (" server" ).toBool ())) {
199
- addOverriddenOption (" -server" );
200
- }
201
172
202
173
if (!settings.contains (" fUseProxy" ))
203
174
settings.setValue (" fUseProxy" , false );
@@ -438,9 +409,9 @@ QVariant OptionsModel::getOption(OptionID option) const
438
409
case ThreadsScriptVerif:
439
410
return qlonglong (SettingToInt (setting (), DEFAULT_SCRIPTCHECK_THREADS));
440
411
case Listen:
441
- return settings. value ( " fListen " );
412
+ return SettingToBool ( setting (), DEFAULT_LISTEN );
442
413
case Server:
443
- return settings. value ( " server " );
414
+ return SettingToBool ( setting (), false );
444
415
default :
445
416
return QVariant ();
446
417
}
@@ -609,14 +580,14 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value)
609
580
}
610
581
break ;
611
582
case Listen:
612
- if (settings. value ( " fListen " ) != value ) {
613
- settings. setValue ( " fListen " , value);
583
+ if (changed () ) {
584
+ update ( value. toBool () );
614
585
setRestartRequired (true );
615
586
}
616
587
break ;
617
588
case Server:
618
- if (settings. value ( " server " ) != value ) {
619
- settings. setValue ( " server " , value);
589
+ if (changed () ) {
590
+ update ( value. toBool () );
620
591
setRestartRequired (true );
621
592
}
622
593
break ;
@@ -696,4 +667,13 @@ void OptionsModel::checkAndMigrate()
696
667
#endif
697
668
migrate_setting (MapPortUPnP, " fUseUPnP" );
698
669
migrate_setting (MapPortNatpmp, " fUseNatpmp" );
670
+ migrate_setting (Listen, " fListen" );
671
+ migrate_setting (Server, " server" );
672
+
673
+ // In case migrating QSettings caused any settings value to change, rerun
674
+ // parameter interaction code to update other settings. This is particularly
675
+ // important for the -listen setting, which should cause -listenonion, -upnp,
676
+ // and other settings to default to false if it was set to false.
677
+ // (https://github.com/bitcoin-core/gui/issues/567).
678
+ node ().initParameterInteraction ();
699
679
}
0 commit comments