multi: rename server's identityPriv to identityECDH

This commit is contained in:
Oliver Gugger 2020-04-28 10:06:21 +02:00
parent cf0380ac81
commit 7f1b865b53
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
4 changed files with 20 additions and 20 deletions

@ -555,7 +555,7 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) (
// particular channel. // particular channel.
var selfPolicy *channeldb.ChannelEdgePolicy var selfPolicy *channeldb.ChannelEdgePolicy
if info != nil && bytes.Equal(info.NodeKey1Bytes[:], if info != nil && bytes.Equal(info.NodeKey1Bytes[:],
p.server.identityPriv.PubKey().SerializeCompressed()) { p.server.identityECDH.PubKey().SerializeCompressed()) {
selfPolicy = p1 selfPolicy = p1
} else { } else {

@ -170,7 +170,7 @@ func initAutoPilot(svr *server, cfg *lncfg.AutoPilot,
// With the heuristic itself created, we can now populate the remainder // With the heuristic itself created, we can now populate the remainder
// of the items that the autopilot agent needs to perform its duties. // of the items that the autopilot agent needs to perform its duties.
self := svr.identityPriv.PubKey() self := svr.identityECDH.PubKey()
pilotCfg := autopilot.Config{ pilotCfg := autopilot.Config{
Self: self, Self: self,
Heuristic: weightedAttachment, Heuristic: weightedAttachment,

@ -1433,7 +1433,7 @@ func (r *rpcServer) ConnectPeer(ctx context.Context,
} }
// Connections to ourselves are disallowed for obvious reasons. // Connections to ourselves are disallowed for obvious reasons.
if pubKey.IsEqual(r.server.identityPriv.PubKey()) { if pubKey.IsEqual(r.server.identityECDH.PubKey()) {
return nil, fmt.Errorf("cannot make connection to self") return nil, fmt.Errorf("cannot make connection to self")
} }
@ -1781,7 +1781,7 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
// Making a channel to ourselves wouldn't be of any use, so we // Making a channel to ourselves wouldn't be of any use, so we
// explicitly disallow them. // explicitly disallow them.
if nodePubKey.IsEqual(r.server.identityPriv.PubKey()) { if nodePubKey.IsEqual(r.server.identityECDH.PubKey()) {
return nil, fmt.Errorf("cannot open channel to self") return nil, fmt.Errorf("cannot open channel to self")
} }
@ -2406,7 +2406,7 @@ func (r *rpcServer) GetInfo(ctx context.Context,
} }
nPendingChannels := uint32(len(pendingChannels)) nPendingChannels := uint32(len(pendingChannels))
idPub := r.server.identityPriv.PubKey().SerializeCompressed() idPub := r.server.identityECDH.PubKey().SerializeCompressed()
encodedIDPub := hex.EncodeToString(idPub) encodedIDPub := hex.EncodeToString(idPub)
bestHash, bestHeight, err := r.server.cc.chainIO.GetBestBlock() bestHash, bestHeight, err := r.server.cc.chainIO.GetBestBlock()

@ -135,9 +135,9 @@ type server struct {
cfg *Config cfg *Config
// identityPriv is the private key used to authenticate any incoming // identityECDH is an ECDH capable wrapper for the private key used
// connections. // to authenticate any incoming connections.
identityPriv *btcec.PrivateKey identityECDH *btcec.PrivateKey
// nodeSigner is an implementation of the MessageSigner implementation // nodeSigner is an implementation of the MessageSigner implementation
// that's backed by the identity private key of the running lnd node. // that's backed by the identity private key of the running lnd node.
@ -425,7 +425,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr, chanDB *channeldb.DB,
channelNotifier: channelnotifier.New(chanDB), channelNotifier: channelnotifier.New(chanDB),
identityPriv: privKey, identityECDH: privKey,
nodeSigner: netann.NewNodeSigner(privKey), nodeSigner: netann.NewNodeSigner(privKey),
listenAddrs: listenAddrs, listenAddrs: listenAddrs,
@ -651,7 +651,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr, chanDB *channeldb.DB,
// With the announcement generated, we'll sign it to properly // With the announcement generated, we'll sign it to properly
// authenticate the message on the network. // authenticate the message on the network.
authSig, err := netann.SignAnnouncement( authSig, err := netann.SignAnnouncement(
s.nodeSigner, s.identityPriv.PubKey(), nodeAnn, s.nodeSigner, s.identityECDH.PubKey(), nodeAnn,
) )
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to generate signature for "+ return nil, fmt.Errorf("unable to generate signature for "+
@ -799,7 +799,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr, chanDB *channeldb.DB,
SubBatchDelay: time.Second * 5, SubBatchDelay: time.Second * 5,
IgnoreHistoricalFilters: cfg.IgnoreHistoricalGossipFilters, IgnoreHistoricalFilters: cfg.IgnoreHistoricalGossipFilters,
}, },
s.identityPriv.PubKey(), s.identityECDH.PubKey(),
) )
s.localChanMgr = &localchans.Manager{ s.localChanMgr = &localchans.Manager{
@ -1227,7 +1227,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr, chanDB *channeldb.DB,
OnAccept: s.InboundPeerConnected, OnAccept: s.InboundPeerConnected,
RetryDuration: time.Second * 5, RetryDuration: time.Second * 5,
TargetOutbound: 100, TargetOutbound: 100,
Dial: noiseDial(s.identityPriv, s.cfg.net), Dial: noiseDial(s.identityECDH, s.cfg.net),
OnConnection: s.OutboundPeerConnected, OnConnection: s.OutboundPeerConnected,
}) })
if err != nil { if err != nil {
@ -2020,7 +2020,7 @@ func (s *server) createNewHiddenService() error {
Color: newNodeAnn.RGBColor, Color: newNodeAnn.RGBColor,
AuthSigBytes: newNodeAnn.Signature.ToSignatureBytes(), AuthSigBytes: newNodeAnn.Signature.ToSignatureBytes(),
} }
copy(selfNode.PubKeyBytes[:], s.identityPriv.PubKey().SerializeCompressed()) copy(selfNode.PubKeyBytes[:], s.identityECDH.PubKey().SerializeCompressed())
if err := s.chanDB.ChannelGraph().SetSourceNode(selfNode); err != nil { if err := s.chanDB.ChannelGraph().SetSourceNode(selfNode); err != nil {
return fmt.Errorf("can't set self node: %v", err) return fmt.Errorf("can't set self node: %v", err)
} }
@ -2050,7 +2050,7 @@ func (s *server) genNodeAnnouncement(refresh bool,
// Otherwise, we'll sign a new update after applying all of the passed // Otherwise, we'll sign a new update after applying all of the passed
// modifiers. // modifiers.
err := netann.SignNodeAnnouncement( err := netann.SignNodeAnnouncement(
s.nodeSigner, s.identityPriv.PubKey(), s.currentNodeAnn, s.nodeSigner, s.identityECDH.PubKey(), s.currentNodeAnn,
modifiers..., modifiers...,
) )
if err != nil { if err != nil {
@ -2102,7 +2102,7 @@ func (s *server) establishPersistentConnections() error {
// TODO(roasbeef): instead iterate over link nodes and query graph for // TODO(roasbeef): instead iterate over link nodes and query graph for
// each of the nodes. // each of the nodes.
selfPub := s.identityPriv.PubKey().SerializeCompressed() selfPub := s.identityECDH.PubKey().SerializeCompressed()
err = sourceNode.ForEachChannel(nil, func( err = sourceNode.ForEachChannel(nil, func(
tx kvdb.ReadTx, tx kvdb.ReadTx,
chanInfo *channeldb.ChannelEdgeInfo, chanInfo *channeldb.ChannelEdgeInfo,
@ -2552,7 +2552,7 @@ func (s *server) InboundPeerConnected(conn net.Conn) {
// not of the same type of the new connection (inbound), then // not of the same type of the new connection (inbound), then
// we'll close out the new connection s.t there's only a single // we'll close out the new connection s.t there's only a single
// connection between us. // connection between us.
localPub := s.identityPriv.PubKey() localPub := s.identityECDH.PubKey()
if !connectedPeer.inbound && if !connectedPeer.inbound &&
!shouldDropLocalConnection(localPub, nodePub) { !shouldDropLocalConnection(localPub, nodePub) {
@ -2663,7 +2663,7 @@ func (s *server) OutboundPeerConnected(connReq *connmgr.ConnReq, conn net.Conn)
// not of the same type of the new connection (outbound), then // not of the same type of the new connection (outbound), then
// we'll close out the new connection s.t there's only a single // we'll close out the new connection s.t there's only a single
// connection between us. // connection between us.
localPub := s.identityPriv.PubKey() localPub := s.identityECDH.PubKey()
if connectedPeer.inbound && if connectedPeer.inbound &&
shouldDropLocalConnection(localPub, nodePub) { shouldDropLocalConnection(localPub, nodePub) {
@ -3264,7 +3264,7 @@ func (s *server) ConnectToPeer(addr *lnwire.NetAddress, perm bool) error {
// notify the caller if the connection attempt has failed. Otherwise, it will be // notify the caller if the connection attempt has failed. Otherwise, it will be
// closed. // closed.
func (s *server) connectToPeer(addr *lnwire.NetAddress, errChan chan<- error) { func (s *server) connectToPeer(addr *lnwire.NetAddress, errChan chan<- error) {
conn, err := brontide.Dial(s.identityPriv, addr, s.cfg.net.Dial) conn, err := brontide.Dial(s.identityECDH, addr, s.cfg.net.Dial)
if err != nil { if err != nil {
srvrLog.Errorf("Unable to connect to %v: %v", addr, err) srvrLog.Errorf("Unable to connect to %v: %v", addr, err)
select { select {
@ -3467,7 +3467,7 @@ func (s *server) fetchNodeAdvertisedAddr(pub *btcec.PublicKey) (net.Addr, error)
func (s *server) fetchLastChanUpdate() func(lnwire.ShortChannelID) ( func (s *server) fetchLastChanUpdate() func(lnwire.ShortChannelID) (
*lnwire.ChannelUpdate, error) { *lnwire.ChannelUpdate, error) {
ourPubKey := s.identityPriv.PubKey().SerializeCompressed() ourPubKey := s.identityECDH.PubKey().SerializeCompressed()
return func(cid lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error) { return func(cid lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error) {
info, edge1, edge2, err := s.chanRouter.GetChannelByID(cid) info, edge1, edge2, err := s.chanRouter.GetChannelByID(cid)
if err != nil { if err != nil {
@ -3483,7 +3483,7 @@ func (s *server) fetchLastChanUpdate() func(lnwire.ShortChannelID) (
// applyChannelUpdate applies the channel update to the different sub-systems of // applyChannelUpdate applies the channel update to the different sub-systems of
// the server. // the server.
func (s *server) applyChannelUpdate(update *lnwire.ChannelUpdate) error { func (s *server) applyChannelUpdate(update *lnwire.ChannelUpdate) error {
pubKey := s.identityPriv.PubKey() pubKey := s.identityECDH.PubKey()
errChan := s.authGossiper.ProcessLocalAnnouncement(update, pubKey) errChan := s.authGossiper.ProcessLocalAnnouncement(update, pubKey)
select { select {
case err := <-errChan: case err := <-errChan: