rpc: display node color in RPC output for LightningNode

This commit is contained in:
Olaoluwa Osuntokun 2017-12-02 18:37:34 -08:00
parent 81283e8b5a
commit a034febde0
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
1 changed files with 7 additions and 1 deletions

View File

@ -2375,11 +2375,14 @@ func (r *rpcServer) DescribeGraph(ctx context.Context,
} }
nodeAddrs = append(nodeAddrs, nodeAddr) nodeAddrs = append(nodeAddrs, nodeAddr)
} }
nodeColor := fmt.Sprintf("#%02x%02x%02x", node.Color.R, node.Color.G, node.Color.B)
resp.Nodes = append(resp.Nodes, &lnrpc.LightningNode{ resp.Nodes = append(resp.Nodes, &lnrpc.LightningNode{
LastUpdate: uint32(node.LastUpdate.Unix()), LastUpdate: uint32(node.LastUpdate.Unix()),
PubKey: hex.EncodeToString(node.PubKey.SerializeCompressed()), PubKey: hex.EncodeToString(node.PubKey.SerializeCompressed()),
Addresses: nodeAddrs, Addresses: nodeAddrs,
Alias: node.Alias, Alias: node.Alias,
Color: nodeColor,
}) })
return nil return nil
@ -2539,12 +2542,15 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context,
nodeAddrs = append(nodeAddrs, nodeAddr) nodeAddrs = append(nodeAddrs, nodeAddr)
} }
// TODO(roasbeef): list channels as well? // TODO(roasbeef): list channels as well?
nodeColor := fmt.Sprintf("#%02x%02x%02x", node.Color.R, node.Color.G, node.Color.B)
return &lnrpc.NodeInfo{ return &lnrpc.NodeInfo{
Node: &lnrpc.LightningNode{ Node: &lnrpc.LightningNode{
LastUpdate: uint32(node.LastUpdate.Unix()), LastUpdate: uint32(node.LastUpdate.Unix()),
PubKey: in.PubKey, PubKey: in.PubKey,
Addresses: nodeAddrs, Addresses: nodeAddrs,
Alias: node.Alias, Alias: node.Alias,
Color: nodeColor,
}, },
NumChannels: numChannels, NumChannels: numChannels,
TotalCapacity: int64(totalCapcity), TotalCapacity: int64(totalCapcity),
@ -2724,7 +2730,7 @@ func (r *rpcServer) GetNetworkInfo(ctx context.Context,
} }
// If we don't have any channels, then reset the minChannelSize to zero // If we don't have any channels, then reset the minChannelSize to zero
// to avoid outputting NaN in encoded JSOn. // to avoid outputting NaN in encoded JSON.
if numChannels == 0 { if numChannels == 0 {
minChannelSize = 0 minChannelSize = 0
} }