From 031903f275f307df8e3281564653eae3042e3439 Mon Sep 17 00:00:00 2001 From: bitromortac Date: Wed, 26 Nov 2025 16:54:56 +0100 Subject: [PATCH] server: ensure unique addresses for node ann Modifiers of the node announcement may add duplicate addresses, which we remove here after the modifications were applied. This also ensures that any previously added duplicate addresses are removed as well. --- server.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server.go b/server.go index 3c011f8b0..1c2db3d91 100644 --- a/server.go +++ b/server.go @@ -3399,6 +3399,18 @@ func (s *server) genNodeAnnouncement(features *lnwire.RawFeatureVector, modifier(&newNodeAnn) } + // The modifiers may have added duplicate addresses, so we need to + // de-duplicate them here. + uniqueAddrs := map[string]struct{}{} + dedupedAddrs := make([]net.Addr, 0) + for _, addr := range newNodeAnn.Addresses { + if _, ok := uniqueAddrs[addr.String()]; !ok { + uniqueAddrs[addr.String()] = struct{}{} + dedupedAddrs = append(dedupedAddrs, addr) + } + } + newNodeAnn.Addresses = dedupedAddrs + // Sign a new update after applying all of the passed modifiers. err := netann.SignNodeAnnouncement( s.nodeSigner, s.identityKeyLoc, &newNodeAnn,