IsAddrCompatible() check can prevent sending non-routable addresses to peers that don’t support addrv2.
p2p: add validation checks for initial self-announcement #34297
pull frankomosh wants to merge 1 commits into bitcoin:master from frankomosh:p2p-self-announcement changing 1 files +7 −5-
frankomosh commented at 8:26 am on January 15, 2026: contributorThis is a follow up to #34146 . Adds validation check to the initial self-announcement code path.
-
DrahtBot added the label P2P on Jan 15, 2026
-
DrahtBot commented at 8:26 am on January 15, 2026: contributor
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Code Coverage & Benchmarks
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34297.
Reviews
See the guideline for information on the review process.
Type Reviewers ACK fjahr, Crypt-iQ, stratospher, sedited Stale ACK 0xB10C If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.
-
0xB10C commented at 12:30 pm on January 15, 2026: contributor
Code Review ACK dea9d502d8c4cfb9fb5c9a3df1940e266b2a0146
Having the same checks as before makes sense.
-
0xB10C commented at 12:31 pm on January 15, 2026: contributorSome additional context for this PR: This change was suggested by reviewers in #34146 (review) but the PR was merged before that review was addressed (probably an oversight).
-
in src/net_processing.cpp:5524 in dea9d502d8
5525- if (peer.m_wants_addrv2) { 5526- MakeAndPushMessage(node, NetMsgType::ADDRV2, CAddress::V2_NETWORK(self_announcement)); 5527- } else { 5528- MakeAndPushMessage(node, NetMsgType::ADDR, CAddress::V1_NETWORK(self_announcement)); 5529- } 5530+ if (local_addr.IsValid() && IsAddrCompatible(peer, local_addr)) {
fjahr commented at 12:54 pm on January 15, 2026:I think checkingIsAddrCompatiblehere is enough becauseGetLocalAddrForPeeronly returns a service whenIsRoutableis true and this includes anIsValidcheck.
frankomosh commented at 1:13 pm on January 15, 2026:Thanks, have updated itfrankomosh force-pushed on Jan 15, 2026in src/net_processing.cpp:5531 in 5392ee0321
5532+ if (peer.m_wants_addrv2) { 5533+ MakeAndPushMessage(node, NetMsgType::ADDRV2, CAddress::V2_NETWORK(self_announcement)); 5534+ } else { 5535+ MakeAndPushMessage(node, NetMsgType::ADDR, CAddress::V1_NETWORK(self_announcement)); 5536+ } 5537+ }
fjahr commented at 1:31 pm on January 15, 2026:nit: The indentation got messed up here it seems
frankomosh commented at 1:46 pm on January 15, 2026:Fixed now. Thanksfjahr commented at 1:31 pm on January 15, 2026: contributorutACK 5392ee03216d45547e62866f2063f6d200662857
Thanks for also fixing the space ;)
DrahtBot requested review from 0xB10C on Jan 15, 20266a8dbf9b93p2p: add validation check for initial self-announcement
The direct send path for the initial self-announcement was bypassing IsAddrCompatible() check that PushAddress() performs
frankomosh force-pushed on Jan 15, 2026DrahtBot added the label CI failed on Jan 15, 2026fjahr commented at 1:46 pm on January 15, 2026: contributorutACK 6a8dbf9b9352db48580cd81c8dac027f3138fedfDrahtBot removed the label CI failed on Jan 15, 2026Crypt-iQ commented at 9:15 pm on January 16, 2026: contributorcrACK 6a8dbf9b9352db48580cd81c8dac027f3138fedf
I haven’t tested, but I think that onion / i2p / cjdns addresses would have been sent as all zero per logic in
SerializeV1Array.stratospher commented at 2:13 pm on January 21, 2026: contributorACK 6a8dbf9. preserves the existing behaviour. also learnt that Addr-fetch ADDR processing logic allows receiving a self-announcement with 1 address without disconnecting and won’t be affected.sedited approvedsedited commented at 10:38 am on January 22, 2026: contributorACK 6a8dbf9b9352db48580cd81c8dac027f3138fedfsedited merged this on Jan 22, 2026sedited closed this on Jan 22, 2026
frankomosh deleted the branch on Jan 22, 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-01-28 06:13 UTC
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-01-28 06:13 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me
More mirrored repositories can be found on mirror.b10c.me