This is a follow up to #34146 . Adds validation check to the initial self-announcement code path. 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: contributor
- DrahtBot added the label P2P on Jan 15, 2026
-
DrahtBot commented at 8:26 AM on January 15, 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/34297.
<!--021abf342d371248e50ceaed478a90ca-->
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 <code><!--meta-tag:bot-skip--></code> into the comment that the bot should ignore.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
-
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: contributor
Some 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 checking
IsAddrCompatiblehere 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 it
frankomosh 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. Thanks
fjahr 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 6a8dbf9b9352db48580cd81c8dac027f3138fedf
DrahtBot 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 6a8dbf9b9352db48580cd81c8dac027f3138fedf
sedited merged this on Jan 22, 2026sedited closed this on Jan 22, 2026frankomosh deleted the branch on Jan 22, 2026
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-04-22 18:12 UTC
More mirrored repositories can be found on mirror.b10c.me