routing/router: don't apply channel policy updates for unknown channels
This commit is contained in:
parent
e10fe91f10
commit
23ce82f4e3
@ -1125,8 +1125,6 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
|
|||||||
}
|
}
|
||||||
r.rejectMtx.RUnlock()
|
r.rejectMtx.RUnlock()
|
||||||
|
|
||||||
channelID := lnwire.NewShortChanIDFromInt(msg.ChannelID)
|
|
||||||
|
|
||||||
// We make sure to hold the mutex for this channel ID,
|
// We make sure to hold the mutex for this channel ID,
|
||||||
// such that no other goroutine is concurrently doing
|
// such that no other goroutine is concurrently doing
|
||||||
// database accesses for the same channel ID.
|
// database accesses for the same channel ID.
|
||||||
@ -1142,6 +1140,15 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the channel doesn't exist in our database, we cannot
|
||||||
|
// apply the updated policy.
|
||||||
|
if !exists {
|
||||||
|
return newErrf(ErrIgnored, "Ignoring update "+
|
||||||
|
"(flags=%v|%v) for unknown chan_id=%v",
|
||||||
|
msg.MessageFlags, msg.ChannelFlags,
|
||||||
|
msg.ChannelID)
|
||||||
|
}
|
||||||
|
|
||||||
// As edges are directional edge node has a unique policy for
|
// As edges are directional edge node has a unique policy for
|
||||||
// the direction of the edge they control. Therefore we first
|
// the direction of the edge they control. Therefore we first
|
||||||
// check if we already have the most up to date information for
|
// check if we already have the most up to date information for
|
||||||
@ -1174,36 +1181,6 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !exists && !r.cfg.AssumeChannelValid {
|
|
||||||
// Before we can update the channel information, we'll
|
|
||||||
// ensure that the target channel is still open by
|
|
||||||
// querying the utxo-set for its existence.
|
|
||||||
chanPoint, fundingTxOut, err := r.fetchChanPoint(
|
|
||||||
&channelID,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
r.rejectMtx.Lock()
|
|
||||||
r.rejectCache[msg.ChannelID] = struct{}{}
|
|
||||||
r.rejectMtx.Unlock()
|
|
||||||
|
|
||||||
return errors.Errorf("unable to fetch chan "+
|
|
||||||
"point for chan_id=%v: %v",
|
|
||||||
msg.ChannelID, err)
|
|
||||||
}
|
|
||||||
_, err = r.cfg.Chain.GetUtxo(
|
|
||||||
chanPoint, fundingTxOut.PkScript,
|
|
||||||
channelID.BlockHeight,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
r.rejectMtx.Lock()
|
|
||||||
r.rejectCache[msg.ChannelID] = struct{}{}
|
|
||||||
r.rejectMtx.Unlock()
|
|
||||||
|
|
||||||
return errors.Errorf("unable to fetch utxo for "+
|
|
||||||
"chan_id=%v: %v", msg.ChannelID, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now that we know this isn't a stale update, we'll apply the
|
// Now that we know this isn't a stale update, we'll apply the
|
||||||
// new edge policy to the proper directional edge within the
|
// new edge policy to the proper directional edge within the
|
||||||
// channel graph.
|
// channel graph.
|
||||||
|
Loading…
Reference in New Issue
Block a user