mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-12 22:19:06 +02:00
Merge pull request #4899 from halseth/ignore-local-ann-from-remote
[gossiper] Ignore received ChannelAnnouncements for own channels
This commit is contained in:
commit
b52e872878
@ -542,6 +542,22 @@ func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(msg lnwire.Message,
|
||||
|
||||
errChan <- nil
|
||||
return errChan
|
||||
|
||||
// To avoid inserting edges in the graph for our own channels that we
|
||||
// have already closed, we ignore such channel announcements coming
|
||||
// from the remote.
|
||||
case *lnwire.ChannelAnnouncement:
|
||||
ownKey := d.selfKey.SerializeCompressed()
|
||||
ownErr := fmt.Errorf("ignoring remote ChannelAnnouncement " +
|
||||
"for own channel")
|
||||
|
||||
if bytes.Equal(m.NodeID1[:], ownKey) ||
|
||||
bytes.Equal(m.NodeID2[:], ownKey) {
|
||||
|
||||
log.Warn(ownErr)
|
||||
errChan <- ownErr
|
||||
return errChan
|
||||
}
|
||||
}
|
||||
|
||||
nMsg := &networkMsg{
|
||||
@ -574,7 +590,7 @@ func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(msg lnwire.Message,
|
||||
// entire channel announcement and update messages will be re-constructed and
|
||||
// broadcast to the rest of the network.
|
||||
func (d *AuthenticatedGossiper) ProcessLocalAnnouncement(msg lnwire.Message,
|
||||
source *btcec.PublicKey, optionalFields ...OptionalMsgField) chan error {
|
||||
optionalFields ...OptionalMsgField) chan error {
|
||||
|
||||
optionalMsgFields := &optionalMsgFields{}
|
||||
optionalMsgFields.apply(optionalFields...)
|
||||
@ -583,7 +599,7 @@ func (d *AuthenticatedGossiper) ProcessLocalAnnouncement(msg lnwire.Message,
|
||||
msg: msg,
|
||||
optionalMsgFields: optionalMsgFields,
|
||||
isRemote: false,
|
||||
source: source,
|
||||
source: d.selfKey,
|
||||
err: make(chan error, 1),
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
17
server.go
17
server.go
@ -670,7 +670,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
// With the announcement generated, we'll sign it to properly
|
||||
// authenticate the message on the network.
|
||||
authSig, err := netann.SignAnnouncement(
|
||||
s.nodeSigner, s.identityECDH.PubKey(), nodeAnn,
|
||||
s.nodeSigner, nodeKeyECDH.PubKey(), nodeAnn,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to generate signature for "+
|
||||
@ -824,7 +824,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
IgnoreHistoricalFilters: cfg.IgnoreHistoricalGossipFilters,
|
||||
PinnedSyncers: cfg.Gossip.PinnedSyncers,
|
||||
},
|
||||
s.identityECDH.PubKey(),
|
||||
nodeKeyECDH.PubKey(),
|
||||
)
|
||||
|
||||
s.localChanMgr = &localchans.Manager{
|
||||
@ -1026,13 +1026,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
CurrentNodeAnnouncement: func() (lnwire.NodeAnnouncement, error) {
|
||||
return s.genNodeAnnouncement(true)
|
||||
},
|
||||
SendAnnouncement: func(msg lnwire.Message,
|
||||
optionalFields ...discovery.OptionalMsgField) chan error {
|
||||
|
||||
return s.authGossiper.ProcessLocalAnnouncement(
|
||||
msg, nodeKeyECDH.PubKey(), optionalFields...,
|
||||
)
|
||||
},
|
||||
SendAnnouncement: s.authGossiper.ProcessLocalAnnouncement,
|
||||
NotifyWhenOnline: s.NotifyWhenOnline,
|
||||
TempChanIDSeed: chanIDSeed,
|
||||
FindChannel: func(chanID lnwire.ChannelID) (
|
||||
@ -1415,7 +1409,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
RetryDuration: time.Second * 5,
|
||||
TargetOutbound: 100,
|
||||
Dial: noiseDial(
|
||||
s.identityECDH, s.cfg.net, s.cfg.ConnectionTimeout,
|
||||
nodeKeyECDH, s.cfg.net, s.cfg.ConnectionTimeout,
|
||||
),
|
||||
OnConnection: s.OutboundPeerConnected,
|
||||
})
|
||||
@ -3792,8 +3786,7 @@ func (s *server) fetchLastChanUpdate() func(lnwire.ShortChannelID) (
|
||||
// applyChannelUpdate applies the channel update to the different sub-systems of
|
||||
// the server.
|
||||
func (s *server) applyChannelUpdate(update *lnwire.ChannelUpdate) error {
|
||||
pubKey := s.identityECDH.PubKey()
|
||||
errChan := s.authGossiper.ProcessLocalAnnouncement(update, pubKey)
|
||||
errChan := s.authGossiper.ProcessLocalAnnouncement(update)
|
||||
select {
|
||||
case err := <-errChan:
|
||||
return err
|
||||
|
Loading…
x
Reference in New Issue
Block a user