lnrpc/peers: handle color changes in updateNodeAnnouncement

This commit is contained in:
positiveblue committed 2022-04-01 18:36:26 -07:00
1 parent ce4813940d
commit aacb2565f5
4 files changed
+37 -1

No files matched your search

+20 -1
View File
@@ -9,6 +9,7 @@ import (
"sync/atomic"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/lightningnetwork/lnd/lncfg"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/netann"
@@ -177,7 +178,25 @@ func (s *Server) UpdateNodeAnnouncement(_ context.Context,
// TODO(positiveblue): apply feature bit modifications
// TODO(positiveblue): apply color modifications
if req.Color != "" {
color, err := lncfg.ParseHexColor(req.Color)
if err != nil {
return nil, fmt.Errorf("unable to parse color: %v", err)
}
if color != currentNodeAnn.RGBColor {
resp.Ops = append(resp.Ops, &lnrpc.Op{
Entity: "color",
Actions: []string{
fmt.Sprintf("changed to %v", color),
},
})
nodeModifiers = append(
nodeModifiers,
netann.NodeAnnSetColor(color),
)
}
}
if req.Alias != "" {
alias, err := lnwire.NewNodeAlias(req.Alias)