discovery: use correct channel ID for MarkEdgeLive

In processZombieUpdate, the SCID passed to MarkEdgeLive should _not_ be
derived from the ChannelEdgeInfo ChannelID field since this field will
not be populated when GetChannelByID returns a ChannelEdgeInfo along
with an ErrZombieEdge error. So this commit ensures that a usable
SCID is provided to processZombieUpdate.
This commit is contained in:
Elle Mouton
2023-11-13 12:21:30 +02:00
parent 0193274c10
commit 7ff4a8b157

View File

@@ -2022,8 +2022,12 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
// processZombieUpdate determines whether the provided channel update should
// resurrect a given zombie edge.
//
// NOTE: only the NodeKey1Bytes and NodeKey2Bytes members of the ChannelEdgeInfo
// should be inspected.
func (d *AuthenticatedGossiper) processZombieUpdate(
chanInfo *models.ChannelEdgeInfo, msg *lnwire.ChannelUpdate) error {
chanInfo *models.ChannelEdgeInfo, scid lnwire.ShortChannelID,
msg *lnwire.ChannelUpdate) error {
// The least-significant bit in the flag on the channel update tells us
// which edge is being updated.
@@ -2031,7 +2035,7 @@ func (d *AuthenticatedGossiper) processZombieUpdate(
// Since we've deemed the update as not stale above, before marking it
// live, we'll make sure it has been signed by the correct party. If we
// have both pubkeys, either party can resurect the channel. If we've
// have both pubkeys, either party can resurrect the channel. If we've
// already marked this with the stricter, single-sided resurrection we
// will only have the pubkey of the node with the oldest timestamp.
var pubKey *btcec.PublicKey
@@ -2055,8 +2059,7 @@ func (d *AuthenticatedGossiper) processZombieUpdate(
// With the signature valid, we'll proceed to mark the
// edge as live and wait for the channel announcement to
// come through again.
baseScid := lnwire.NewShortChanIDFromInt(chanInfo.ChannelID)
err = d.cfg.Router.MarkEdgeLive(baseScid)
err = d.cfg.Router.MarkEdgeLive(scid)
switch {
case errors.Is(err, channeldb.ErrZombieEdgeNotFound):
log.Errorf("edge with chan_id=%v was not found in the "+
@@ -2740,7 +2743,7 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
break
case channeldb.ErrZombieEdge:
err = d.processZombieUpdate(chanInfo, upd)
err = d.processZombieUpdate(chanInfo, graphScid, upd)
if err != nil {
log.Debug(err)
nMsg.err <- err