discovery+routing: move validation logic to routing package
Previously, gossiper was the only object that validated channel updates. Because updates can also be received as part of a failed payment session in the routing package, validation logic needs to be available there too. Gossiper already depends on routing and having routing call the validation logic inside gossiper would be a circular dependency. Therefore the validation was moved to routing.
This commit is contained in:
parent
ac8a3af84c
commit
b5fd32ff77
@ -1520,7 +1520,7 @@ func (d *AuthenticatedGossiper) processRejectedEdge(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = ValidateChannelAnn(chanAnn)
|
err = routing.ValidateChannelAnn(chanAnn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("assembled channel announcement proof "+
|
err := fmt.Errorf("assembled channel announcement proof "+
|
||||||
"for shortChanID=%v isn't valid: %v",
|
"for shortChanID=%v isn't valid: %v",
|
||||||
@ -1598,7 +1598,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ValidateNodeAnn(msg); err != nil {
|
if err := routing.ValidateNodeAnn(msg); err != nil {
|
||||||
err := fmt.Errorf("unable to validate "+
|
err := fmt.Errorf("unable to validate "+
|
||||||
"node announcement: %v", err)
|
"node announcement: %v", err)
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
@ -1701,7 +1701,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
|||||||
// formed.
|
// formed.
|
||||||
var proof *channeldb.ChannelAuthProof
|
var proof *channeldb.ChannelAuthProof
|
||||||
if nMsg.isRemote {
|
if nMsg.isRemote {
|
||||||
if err := ValidateChannelAnn(msg); err != nil {
|
if err := routing.ValidateChannelAnn(msg); err != nil {
|
||||||
err := fmt.Errorf("unable to validate "+
|
err := fmt.Errorf("unable to validate "+
|
||||||
"announcement: %v", err)
|
"announcement: %v", err)
|
||||||
d.rejectMtx.Lock()
|
d.rejectMtx.Lock()
|
||||||
@ -1993,7 +1993,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
|||||||
// Validate the channel announcement with the expected public
|
// Validate the channel announcement with the expected public
|
||||||
// key, In the case of an invalid channel , we'll return an
|
// key, In the case of an invalid channel , we'll return an
|
||||||
// error to the caller and exit early.
|
// error to the caller and exit early.
|
||||||
if err := ValidateChannelUpdateAnn(pubKey, msg); err != nil {
|
if err := routing.ValidateChannelUpdateAnn(pubKey, msg); err != nil {
|
||||||
rErr := fmt.Errorf("unable to validate channel "+
|
rErr := fmt.Errorf("unable to validate channel "+
|
||||||
"update announcement for short_chan_id=%v: %v",
|
"update announcement for short_chan_id=%v: %v",
|
||||||
spew.Sdump(msg.ShortChannelID), err)
|
spew.Sdump(msg.ShortChannelID), err)
|
||||||
@ -2297,7 +2297,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
|||||||
|
|
||||||
// With all the necessary components assembled validate the
|
// With all the necessary components assembled validate the
|
||||||
// full channel announcement proof.
|
// full channel announcement proof.
|
||||||
if err := ValidateChannelAnn(chanAnn); err != nil {
|
if err := routing.ValidateChannelAnn(chanAnn); err != nil {
|
||||||
err := fmt.Errorf("channel announcement proof "+
|
err := fmt.Errorf("channel announcement proof "+
|
||||||
"for short_chan_id=%v isn't valid: %v",
|
"for short_chan_id=%v isn't valid: %v",
|
||||||
shortChanID, err)
|
shortChanID, err)
|
||||||
@ -2505,7 +2505,7 @@ func (d *AuthenticatedGossiper) updateChannel(info *channeldb.ChannelEdgeInfo,
|
|||||||
|
|
||||||
// To ensure that our signature is valid, we'll verify it ourself
|
// To ensure that our signature is valid, we'll verify it ourself
|
||||||
// before committing it to the slice returned.
|
// before committing it to the slice returned.
|
||||||
err = ValidateChannelUpdateAnn(d.selfKey, chanUpdate)
|
err = routing.ValidateChannelUpdateAnn(d.selfKey, chanUpdate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("generated invalid channel "+
|
return nil, nil, fmt.Errorf("generated invalid channel "+
|
||||||
"update sig: %v", err)
|
"update sig: %v", err)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package discovery
|
package routing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
Loading…
Reference in New Issue
Block a user