init, rpc: ignore empty addnode values #35787

pull w0xlt wants to merge 2 commits into bitcoin:master from w0xlt:fix/empty-addnode changing 4 files +40 −2
  1. w0xlt commented at 7:37 PM on July 23, 2026: contributor

    An empty addnode= entry currently creates an empty added-node record. The node then repeatedly attempts to connect to the empty destination:

    2026-07-23T19:22:33Z [net] trying v2 connection (manual) to , lastseen=0.0hrs
    2026-07-23T19:23:33Z [net] trying v2 connection (manual) to , lastseen=0.0hrs
    2026-07-23T19:24:34Z [net] trying v2 connection (manual) to , lastseen=0.0hrs
    

    With this change, the node ignores empty -addnode values when initializing the connection manager. This preserves the existing startup behavior while avoiding useless connection attempts. Non-empty values are unaffected. Values consisting only of whitespace are ignored as well, and every ignored value is logged.

    The addnode RPC has the same issue, so it now returns Error: Node address cannot be empty instead of adding such a record.

    Functional tests verify that the node starts with addnode=, that no added-node record is created while non-empty values are still added, and that the RPC rejects empty values.

  2. DrahtBot commented at 7:37 PM on July 23, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35787.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK pablomartin4btc, furszy, l0rinc, achow101

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. in src/init.cpp:2137 in abb2a7cce4
    2132 | @@ -2133,7 +2133,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
    2133 |      connOptions.m_msgproc = node.peerman.get();
    2134 |      connOptions.nSendBufferMaxSize = 1000 * args.GetIntArg("-maxsendbuffer", DEFAULT_MAXSENDBUFFER);
    2135 |      connOptions.nReceiveFloodSize = 1000 * args.GetIntArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER);
    2136 | -    connOptions.m_added_nodes = args.GetArgs("-addnode");
    2137 | +    for (const std::string& added_node : args.GetArgs("-addnode")) {
    2138 | +        if (added_node.empty()) continue;
    


    furszy commented at 7:56 PM on July 23, 2026:

    nit: could log a warning about it.


    sedited commented at 8:15 PM on July 23, 2026:

    Yeah, I think we should log here.


    pablomartin4btc commented at 4:13 AM on July 24, 2026:

    nit: what about whitespaces... ?

            if (TrimString(added_node).empty()) continue;
    

    w0xlt commented at 7:23 AM on July 27, 2026:

    Done. Thanks.


    w0xlt commented at 7:23 AM on July 27, 2026:

    Done. Thanks.

  4. furszy commented at 7:59 PM on July 23, 2026: member

    utACK abb2a7cce4a53b2fc4dfa8d1d0d5183a85b68fc3

  5. pablomartin4btc commented at 4:17 AM on July 24, 2026: member

    ACK abb2a7cce4a53b2fc4dfa8d1d0d5183a85b68fc3

  6. init: ignore empty addnode values
    An empty -addnode currently creates an unresolvable added-node record
    that is retried indefinitely. Ignore empty values instead, retaining
    startup compatibility while avoiding useless records and connection
    attempts.
    
    Values consisting of whitespace only are ignored as well. They can only
    be passed on the command line, as the config file parser trims them
    away, and are just as unresolvable.
    
    The ignored values are logged, so that the option not taking effect is
    not silent.
    69465de447
  7. w0xlt force-pushed on Jul 27, 2026
  8. rpc: reject empty node argument in addnode
    An empty (or whitespace only) node address cannot be resolved, but would
    be added to the added nodes list and retried indefinitely, the same way
    that an empty -addnode value was before the previous commits.
    
    Reject it for all commands instead. Returning false from AddNode() would
    report the misleading "Node already added" error, so check it here.
    90ce21e21d
  9. w0xlt renamed this:
    init: ignore empty addnode values
    init, rpc: ignore empty addnode values
    on Jul 27, 2026
  10. w0xlt commented at 9:16 AM on July 27, 2026: contributor

    CI error unrelated: ERROR: failed to build: failed to solve: mirror.gcr.io/ubuntu:26.04: failed to resolve source metadata for mirror.gcr.io/ubuntu:26.04: failed to copy: httpReadSeeker: failed open: could not fetch content descriptor sha256:de7345b16e942e22044c6ba053020ec85ae879984860a9918517d54eb6cef851 (application/vnd.oci.image.config.v1+json) from remote: not found

  11. w0xlt commented at 9:17 AM on July 27, 2026: contributor

    PR tile and description updated. addnode RPC has been fixed too.

  12. DrahtBot added the label CI failed on Jul 27, 2026
  13. pablomartin4btc commented at 1:06 PM on July 27, 2026: member

    ACK 90ce21e21d09e27c9a02b187e795e03052e12dd3

  14. DrahtBot requested review from furszy on Jul 27, 2026
  15. furszy commented at 2:01 PM on July 27, 2026: member

    utACK 90ce21e21d09e27c9a02b187e795e03052e12dd3

  16. DrahtBot requested review from furszy on Jul 27, 2026
  17. l0rinc commented at 7:06 PM on July 27, 2026: contributor

    lightly tested ACK 90ce21e21d09e27c9a02b187e795e03052e12dd3

  18. achow101 commented at 8:29 PM on July 29, 2026: member

    ACK 90ce21e21d09e27c9a02b187e795e03052e12dd3

  19. achow101 merged this on Jul 29, 2026
  20. achow101 closed this on Jul 29, 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-07-31 20:50 UTC

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