routing: reject channel announcement if connected vertexes are unknown

This commit modifies the processing in the routing package eo new
announcements. Previously,  if we cgot a cnew channel announcement but
didn’t yet know of the verses that the chanell connected, the
cnnounacment would be accepted. This behavior was eronoues as if the
channel were to be queried for, the DB query would fail as we would be
unable to retrieve the two nodes involved int he channel.

To avoid such an error case, we will now _reject_ any channel
announcements in which we don’t yet have a valid node announcement for
the connected nodes. This case has been inserted into the handling of
channel announcement, a new test has been added, and finally older
tests have also been updated to ensure that nodes are added to the
database _before_ the edge is.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-05-14 19:27:24 -07:00
1 parent 34959e4648
commit cc19695dad
4 files changed
+80 -10

No files matched your search

+19 -3
View File
@@ -560,6 +560,22 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
"chan_id=%v", msg.ChannelID)
}
// If we don't yet know about this edge, then we'll do an
// additional check to ensure that we have information about
// the two nodes that this edge connects.
_, exists, _ = r.cfg.Graph.HasLightningNode(msg.NodeKey1)
if !exists {
return errors.Errorf("unable to add channel edge, info "+
"for node %x is missing",
msg.NodeKey1.SerializeCompressed())
}
_, exists, _ = r.cfg.Graph.HasLightningNode(msg.NodeKey2)
if !exists {
return errors.Errorf("unable to add channel edge, info "+
"for node %x is missing",
msg.NodeKey1.SerializeCompressed())
}
// Before we can add the channel to the channel graph, we need
// to obtain the full funding outpoint that's encoded within
// the channel ID.
@@ -580,9 +596,9 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
"chan_id=%v: %v", msg.ChannelID, err)
}
// Recreate witness output to be sure that declared in
// channel edge bitcoin keys and channel value corresponds to
// the reality.
// Recreate witness output to be sure that declared in channel
// edge bitcoin keys and channel value corresponds to the
// reality.
_, witnessOutput, err := lnwallet.GenFundingPkScript(
msg.BitcoinKey1.SerializeCompressed(),
msg.BitcoinKey2.SerializeCompressed(),