init: don't wrap the default onion port to 0 for -port=65535 #36762

pull Ravan002 wants to merge 1 commits into bitcoin:master from Ravan002:onion-port-wrap changing 2 files +20 −1
  1. Ravan002 commented at 6:54 PM on November 4, 2026: none

    The default onion port is -port + 1, computed in uint16_t. With -port=65535 it wrapped to 0, so the default onion listener bound to 127.0.0.1:0 (an ephemeral port nobody can reach) and the same port 0 was used for -bind=<addr>=onion without a port and as the onion service target.

    Fail at startup with an error that asks for a lower -port or an explicit onion port instead. -bind=<addr>:<port>=onion with an explicit port keeps working.

    feature_port.py gets a case for both paths; it fails on master (the node starts and binds port 0).

    This patch was prepared with AI assistance (Claude) and reviewed and tested by me.

  2. init: don't wrap the default onion port to 0 for -port=65535
    The default onion port is `-port` + 1, computed in `uint16_t`. With `-port=65535` it wrapped to 0, so the default onion listener bound to `127.0.0.1:0` (an ephemeral port nobody can reach) and the same port 0 was used for `-bind=<addr>=onion` without a port and as the onion service target.
    
    Fail at startup with an error that asks for a lower `-port` or an explicit onion port instead. `-bind=<addr>:<port>=onion` with an explicit port keeps working.
    
    feature_port.py gets a case for both paths; it fails on master (the node starts and binds port 0).
    
    This patch was prepared with AI assistance (Claude) and reviewed and tested by me.
    ae015303c6
  3. maflcko commented at 7:19 PM on November 4, 2026: member
  4. maflcko closed this on Nov 4, 2026

Contributors

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-17 15:51 UTC

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