@@ -41,6 +41,8 @@ static const char* SettingName(OptionsModel::OptionID option)
41
41
case OptionsModel::ThreadsScriptVerif: return " par" ;
42
42
case OptionsModel::SpendZeroConfChange: return " spendzeroconfchange" ;
43
43
case OptionsModel::ExternalSignerPath: return " signer" ;
44
+ case OptionsModel::MapPortUPnP: return " upnp" ;
45
+ case OptionsModel::MapPortNatpmp: return " natpmp" ;
44
46
default : throw std::logic_error (strprintf (" GUI option %i has no corresponding node setting." , option));
45
47
}
46
48
}
@@ -128,7 +130,8 @@ bool OptionsModel::Init(bilingual_str& error)
128
130
129
131
// These are shared with the core or have a command-line parameter
130
132
// and we want command-line parameters to overwrite the GUI settings.
131
- for (OptionID option : {DatabaseCache, ThreadsScriptVerif, SpendZeroConfChange, ExternalSignerPath}) {
133
+ for (OptionID option : {DatabaseCache, ThreadsScriptVerif, SpendZeroConfChange, ExternalSignerPath, MapPortUPnP,
134
+ MapPortNatpmp}) {
132
135
std::string setting = SettingName (option);
133
136
if (node ().isSettingIgnored (setting)) addOverriddenOption (" -" + setting);
134
137
try {
@@ -164,18 +167,6 @@ bool OptionsModel::Init(bilingual_str& error)
164
167
#endif
165
168
166
169
// Network
167
- if (!settings.contains (" fUseUPnP" ))
168
- settings.setValue (" fUseUPnP" , DEFAULT_UPNP);
169
- if (!gArgs .SoftSetBoolArg (" -upnp" , settings.value (" fUseUPnP" ).toBool ()))
170
- addOverriddenOption (" -upnp" );
171
-
172
- if (!settings.contains (" fUseNatpmp" )) {
173
- settings.setValue (" fUseNatpmp" , DEFAULT_NATPMP);
174
- }
175
- if (!gArgs .SoftSetBoolArg (" -natpmp" , settings.value (" fUseNatpmp" ).toBool ())) {
176
- addOverriddenOption (" -natpmp" );
177
- }
178
-
179
170
if (!settings.contains (" fListen" ))
180
171
settings.setValue (" fListen" , DEFAULT_LISTEN);
181
172
const bool listen{settings.value (" fListen" ).toBool ()};
@@ -389,13 +380,13 @@ QVariant OptionsModel::getOption(OptionID option) const
389
380
return fMinimizeToTray ;
390
381
case MapPortUPnP:
391
382
#ifdef USE_UPNP
392
- return settings. value ( " fUseUPnP " );
383
+ return SettingToBool ( setting (), DEFAULT_UPNP );
393
384
#else
394
385
return false ;
395
386
#endif // USE_UPNP
396
387
case MapPortNatpmp:
397
388
#ifdef USE_NATPMP
398
- return settings. value ( " fUseNatpmp " );
389
+ return SettingToBool ( setting (), DEFAULT_NATPMP );
399
390
#else
400
391
return false ;
401
392
#endif // USE_NATPMP
@@ -477,10 +468,16 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value)
477
468
settings.setValue (" fMinimizeToTray" , fMinimizeToTray );
478
469
break ;
479
470
case MapPortUPnP: // core option - can be changed on-the-fly
480
- settings.setValue (" fUseUPnP" , value.toBool ());
471
+ if (changed ()) {
472
+ update (value.toBool ());
473
+ node ().mapPort (value.toBool (), getOption (MapPortNatpmp).toBool ());
474
+ }
481
475
break ;
482
476
case MapPortNatpmp: // core option - can be changed on-the-fly
483
- settings.setValue (" fUseNatpmp" , value.toBool ());
477
+ if (changed ()) {
478
+ update (value.toBool ());
479
+ node ().mapPort (getOption (MapPortUPnP).toBool (), value.toBool ());
480
+ }
484
481
break ;
485
482
case MinimizeOnClose:
486
483
fMinimizeOnClose = value.toBool ();
@@ -697,4 +694,6 @@ void OptionsModel::checkAndMigrate()
697
694
migrate_setting (SpendZeroConfChange, " bSpendZeroConfChange" );
698
695
migrate_setting (ExternalSignerPath, " external_signer_path" );
699
696
#endif
697
+ migrate_setting (MapPortUPnP, " fUseUPnP" );
698
+ migrate_setting (MapPortNatpmp, " fUseNatpmp" );
700
699
}
0 commit comments