test: cover -externalip/onlynet interaction in functional test
What changed, and why it matters
This commit only adds a new automated test to Bitcoin Core. It checks that a user-configured onion address still gets advertised even when the node is told to only use IPv4. There is no code change to the actual Bitcoin node behavior, so this commit does not introduce or fix a security vulnerability on its own.
No security action needed. Reviewers may optionally confirm the tested behavior (-externalip bypassing -onlynet for local address advertisement) is intentional and documented, but that is a product-design question, not a vulnerability introduced by this commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff extends the functional test p2p_addr_selfannouncement.py with test_externalip_bypasses_onlynet(). The test restarts a node with -onlynet=ipv4 plus -externalip=
Changed components
test/functional/p2p_addr_selfannouncement.pyInspect captured patch +14 / −0
diff --git a/test/functional/p2p_addr_selfannouncement.py b/test/functional/p2p_addr_selfannouncement.py
index 631ecb4c..01221332 100755
--- a/test/functional/p2p_addr_selfannouncement.py
+++ b/test/functional/p2p_addr_selfannouncement.py
@@ -23,6 +23,7 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_greater_than
IP_TO_ANNOUNCE = "42.42.42.42"
+ONION_ADDR = "pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion"
ONE_DAY = 60 * 60 * 24
@@ -77,6 +78,7 @@ class AddrSelfAnnouncementTest(BitcoinTestFramework):
self.self_announcement_test(outbound=False, addrv2=True)
self.self_announcement_test(outbound=True, addrv2=False)
self.self_announcement_test(outbound=True, addrv2=True)
+ self.test_externalip_bypasses_onlynet()
@staticmethod
def inbound_connection_open_assertions(addr_receiver):
@@ -150,5 +152,17 @@ class AddrSelfAnnouncementTest(BitcoinTestFramework):
self.nodes[0].disconnect_p2ps()
+ def test_externalip_bypasses_onlynet(self):
+ self.log.info("Test that -externalip onion is advertised despite -onlynet=ipv4")
+ self.restart_node(0, extra_args=["-onlynet=ipv4", f"-externalip={ONION_ADDR}"])
+
+ netinfo = self.nodes[0].getnetworkinfo()
+
+ onion_net = next(n for n in netinfo["networks"] if n["name"] == "onion")
+ assert not onion_net["reachable"], "onion should not be reachable under -onlynet=ipv4"
+
+ addrs = [a["address"] for a in netinfo["localaddresses"]]
+ assert ONION_ADDR in addrs, f"onion address missing from localaddresses: {addrs}"
+
if __name__ == '__main__':
AddrSelfAnnouncementTest(__file__).main()
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.