init: reject -port=65535 when the onion port has to be derived from it #36717

pull Snan0M wants to merge 1 commits into bitcoin:master from Snan0M:onion-port-overflow changing 2 files +25 −4
  1. Snan0M commented at 2:34 PM on October 31, 2026: none

    The default onion bind uses -port + 1. With -port=65535 this wraps to 0, so the node binds 127.0.0.1 to a random port and the automatic onion service points there.

    Now startup fails with a clear error when that port is needed. An explicit -bind=<addr>:<port>=onion still works, and so does -listen=0.

    Added cases to feature_port.py.

  2. init: reject -port=65535 when the onion port has to be derived from it
    The default onion bind uses -port + 1. For -port=65535 that wraps to 0,
    so the node binds 127.0.0.1 to a random port and points the automatic
    Tor onion service at it.
    
    Return an init error instead when that port is actually needed (no
    explicit onion bind port and listening is enabled). An explicit
    -bind=<addr>:<port>=onion keeps working.
    8ce077866d
  3. DrahtBot commented at 2:34 PM on October 31, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #36170 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36170.svg"></sub> (net: require a dedicated bind for automatic Tor by l0rinc)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

    LLM Linter (✨ experimental)

    Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

    • src/init.cpp: Lookup(truncated_bind_arg, default_bind_port_onion.value_or(0), false)

    <sup>2026-10-31 14:34:29</sup>

  4. sedited commented at 8:38 PM on November 6, 2026: contributor

    This seems like another case of #36763 . I don't think this case should warrant all this extra code, so closing this again for now.

  5. sedited closed this on Nov 6, 2026


github-metadata-mirror

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-11-21 11:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me