I’m probably missing something here but CNetAddr::scopeId
seems unused. It isn’t covered by tests. It was added in eda3d9248971a1c3df6e6c4b23ba89be30508b51 and potentially caused an uninitialized read fixed in b7b36decaf878a8c1dcfdb4a27196c730043474b. Am running master on mainnet with the following asserts as a sanity check.
0--- a/src/netaddress.cpp
1+++ b/src/netaddress.cpp
2@@ -132,6 +132,7 @@ CNetAddr::CNetAddr(const struct in_addr& ipv4Addr)
3 CNetAddr::CNetAddr(const struct in6_addr& ipv6Addr, const uint32_t scope)
4 {
5 SetLegacyIPv6(Span<const uint8_t>(reinterpret_cast<const uint8_t*>(&ipv6Addr), sizeof(ipv6Addr)));
6+ assert(scope == 0);
7 scopeId = scope;
8 }
9
10@@ -716,6 +717,7 @@ bool CService::GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const
11+ assert(scopeId == 0);
12 paddrin6->sin6_scope_id = scopeId;
13--- a/src/netbase.cpp
14+++ b/src/netbase.cpp
15@@ -120,6 +120,7 @@ bool static LookupIntern(const std::string& name, std::vector<CNetAddr>& vIP, un
16 struct sockaddr_in6* s6 = (struct sockaddr_in6*) aiTrav->ai_addr;
17+ assert(s6->sin6_scope_id == 0);
18 resolved = CNetAddr(s6->sin6_addr, s6->sin6_scope_id);
19 }