this makes the InitError go away in some cases where it would be useful … ./bitcoind -onlynet=onion
That is exactly the case where we do not want an init error – the problem described in #24980 which this PR aims to fix. Because it could as well work out of the box, giving an init error is too strict and is relaxed by this PR.
Now, it is true that we do not know for sure, at this stage, at startup, whether we would be able to connect to torcontrol and retrieve the proxy address from it. I think it is proper to allow startup and later, if the tor control thread fails to retrieve the proxy it will log the relevant error. That is similar (but not identical) to the case where -proxy=
is given and at startup we do not know if it will work and actually proxy connections. Maybe later we would find out that nobody is listening on the given proxy address and will log an error then.
That is, we give init errors only if we are sure, guaranteed that it will not work.
I wonder if it might be more helpful to change the InitError to a info/warning
I am a bit confused. Do you mean to keep the init error as it is in this PR, but in the case where we silently allow startup (the new relaxation in this PR) to log a warning? I think it would not be necessary because it could be annoying for the cases when all is ok. For the cases when it is not, then the tor control thread will log a proper message if/when the problem occurs. Also, “Disregard this if you use torcontrol” – -torcontrol
is irrelevant here – even if not specified it has a reasonable default. The relevant setting is -listenonion=1
.
Off topic rant: I find the name listenonion
confusing, it should be something like -auto_create_tor_listening_service_via_torcontrol
because -listenonion
does not control whether or not we listen on 127.0.0.1:8334
and the tor service could be setup in tor.conf
(the “static” way in which we should have -listenonion=0
, but would still be listening and accepting incoming tor connections).