init: torcontrol argument should be validated#23589
issuelaanwj
opened this issue on
November 25, 2021
laanwj
commented at 10:11 AM on November 25, 2021:
member
I accidentally -torcontrol=1 today (instead of -listenonion=1) and was confused that it was accepted, as the argument needs to be host:port.
Expected outcome would be an error message and exiting.
Useful skills:
C++
Understanding of bitcoin core's initialization sequence
Want to work on this issue?
For guidance on contributing, please read CONTRIBUTING.md before opening your pull request.
laanwj added the label P2P on Nov 25, 2021
laanwj added the label good first issue on Nov 25, 2021
shaavan
commented at 12:37 PM on November 25, 2021:
contributor
Let me try tackling this!
shaavan
commented at 1:21 PM on November 25, 2021:
contributor
Ok, so I was able to add a function successfully that can check if the given string is a valid <host>:<port> pair or not. The issue is that I cannot raise an error when the argument is wrongly passed when initializing bitcoind.
In fact, bitcoind is not raising an error for any invalid argument passed at initialization.
Expected outcome would be an error message and exiting.
Just a confirmation. When the ./src/bitcoind command is initially run with invalid parameters, do we expect an error message and exit? Or is it expected to occur later in the runtime of bitcoind?
amovfx
commented at 6:19 PM on November 25, 2021:
none
Is the Args Manager flags supposed to help with this?
ityodadev
commented at 5:18 AM on November 26, 2021:
none
common sense would suggest there should be a message and some exit status, other than 0
shaavan
commented at 11:34 AM on November 26, 2021:
contributor
A gentle ping, @laanwj. Would you please take a look at this comment?
maflcko
commented at 11:47 AM on November 26, 2021:
member
git grep InitError might help you.
bitcoin deleted a comment on Nov 27, 2021
bitcoin deleted a comment on Nov 28, 2021
bitcoin deleted a comment on Jan 5, 2022
dakshp07
commented at 1:43 PM on March 4, 2022:
none
hey folks, I'm very new to the codebase and wanted to try my hands around this issue. Also, I saw a PR that is targeting this issue so what's the update on that, is the issue still open?
bitcoin deleted a comment on Mar 10, 2022
amadeuszpawlik referenced this in commit b8cb03f143 on May 14, 2022
amadeuszpawlik referenced this in commit 79befd6484 on May 14, 2022
amadeuszpawlik referenced this in commit 69d4d7679d on May 14, 2022
amadeuszpawlik referenced this in commit f48c207c99 on May 26, 2022
bitcoin deleted a comment on May 31, 2022
amadeuszpawlik referenced this in commit 8695e9ac03 on Oct 13, 2022
amadeuszpawlik referenced this in commit e0a81da7ee on Oct 13, 2022
amadeuszpawlik referenced this in commit 7ac9da5807 on Oct 13, 2022
amadeuszpawlik referenced this in commit 5be4336fc5 on Oct 16, 2022
vstoyanov referenced this in commit 88168de9db on Apr 11, 2023
vstoyanov referenced this in commit 6fb9b723a1 on Apr 11, 2023
kevkevinpal
commented at 8:27 PM on June 30, 2023:
contributor
I see it not throwing the error because it is returning true here if it has no :
bufo24 referenced this in commit fd09b3ee65 on Oct 27, 2023
bufo24 referenced this in commit 2d15e76df4 on Oct 27, 2023
tdb3
commented at 9:12 PM on July 7, 2024:
contributor
Looks like we currently allow lookups for the -torcontrol host based on the state of -dns (default 1) (see below). If we don't want to change that (e.g. to disallow allow hostnames, and allow only IP addresses), we're somewhat limited in what would be considered invalid for -torcontrol. I'm thinking this gets clarified first.
tor control will always attempt to start with the default port no matter the host argument.
I tested this using torcontrol=127.0.0.1 in my bitcoin.conf file
When I logged tor_control_center and control_service.value() at this line,
I got the following output:
2025-06-18T19:32:53Z tor: Resolved control center '127.0.0.1' to service: 127.0.0.1:9051
The suggestion made here — raising an error if the port is missing — would technically work, but it defeats the purpose of having a default port in the first place.
maflcko removed the label good first issue on Jun 23, 2025
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2026-05-02 12:14 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me