From 6459385dfdc8d9e4a4aafa6ce58bc42823531851 Mon Sep 17 00:00:00 2001 From: bitromortac Date: Thu, 16 Feb 2023 14:41:49 +0100 Subject: [PATCH] discovery: skip non-maxHTLC updates in gossip sync We skip syncing channel updates that don't conform to the spec. --- discovery/chan_series.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/discovery/chan_series.go b/discovery/chan_series.go index 42ebe8889..0fe819d4e 100644 --- a/discovery/chan_series.go +++ b/discovery/chan_series.go @@ -7,6 +7,7 @@ import ( "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/netann" + "github.com/lightningnetwork/lnd/routing" "github.com/lightningnetwork/lnd/routing/route" ) @@ -131,10 +132,24 @@ func (c *ChanSeries) UpdatesInHorizon(chain chainhash.Hash, updates = append(updates, chanAnn) if edge1 != nil { - updates = append(updates, edge1) + // We don't want to send channel updates that don't + // conform to the spec (anymore). + err := routing.ValidateChannelUpdateFields(0, edge1) + if err != nil { + log.Errorf("not sending invalid channel "+ + "update %v: %v", edge1, err) + } else { + updates = append(updates, edge1) + } } if edge2 != nil { - updates = append(updates, edge2) + err := routing.ValidateChannelUpdateFields(0, edge2) + if err != nil { + log.Errorf("not sending invalid channel "+ + "update %v: %v", edge2, err) + } else { + updates = append(updates, edge2) + } } }