aboutsummaryrefslogtreecommitdiff
path: root/src/qt/optionsmodel.cpp
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2022-03-24 18:32:22 +0100
committerVasil Dimov <vd@FreeBSD.org>2022-03-31 15:29:38 +0200
commit3b82608dd11d35fa393ee0501c206d74c748248a (patch)
treeb6cc9462657b7dd721e10f0d80d13b0588aa0027 /src/qt/optionsmodel.cpp
parent0a14a16efe0f4a26f3f5dc8eeba2a2c11093b320 (diff)
options: add a comment for -listenonion and dedup a long expression
A followup to https://github.com/bitcoin-core/gui/pull/568 Co-authored-by: Jon Atack <jon@atack.com>
Diffstat (limited to 'src/qt/optionsmodel.cpp')
-rw-r--r--src/qt/optionsmodel.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 057767eb26..52bda59748 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -151,9 +151,26 @@ void OptionsModel::Init(bool resetSettings)
if (!settings.contains("fListen"))
settings.setValue("fListen", DEFAULT_LISTEN);
- if (!gArgs.SoftSetBoolArg("-listen", settings.value("fListen").toBool())) {
+ const bool listen{settings.value("fListen").toBool()};
+ if (!gArgs.SoftSetBoolArg("-listen", listen)) {
addOverriddenOption("-listen");
- } else if (!settings.value("fListen").toBool()) {
+ } else if (!listen) {
+ // We successfully set -listen=0, thus mimic the logic from InitParameterInteraction():
+ // "parameter interaction: -listen=0 -> setting -listenonion=0".
+ //
+ // Both -listen and -listenonion default to true.
+ //
+ // The call order is:
+ //
+ // InitParameterInteraction()
+ // would set -listenonion=0 if it sees -listen=0, but for bitcoin-qt with
+ // fListen=false -listen is 1 at this point
+ //
+ // OptionsModel::Init()
+ // (this method) can flip -listen from 1 to 0 if fListen=false
+ //
+ // AppInitParameterInteraction()
+ // raises an error if -listen=0 and -listenonion=1
gArgs.SoftSetBoolArg("-listenonion", false);
}