lnrpc: add field denoting if channel peer is online in ListChannels

This commit adds a new field to the ListChannels RPC command which
indicates if the peer is currently online or not. This is useful as
UI’s will be able to use this information to communicate the
availability of each channel to an end user.
This commit is contained in:
Olaoluwa Osuntokun
2017-03-08 14:45:58 -08:00
parent addab3273f
commit 1dfda91415
4 changed files with 268 additions and 248 deletions

View File

@ -813,8 +813,8 @@ func (r *rpcServer) ListChannels(ctx context.Context,
continue
}
nodePub := dbChannel.IdentityPub.SerializeCompressed()
nodeID := hex.EncodeToString(nodePub)
nodePub := dbChannel.IdentityPub
nodeID := hex.EncodeToString(nodePub.SerializeCompressed())
chanPoint := dbChannel.ChanID
// With the channel point known, retrieve the network channel
@ -822,7 +822,13 @@ func (r *rpcServer) ListChannels(ctx context.Context,
var chanID uint64
chanID, _ = graph.ChannelID(chanPoint)
var peerOnline bool
if _, err := r.server.findPeer(nodePub); err == nil {
peerOnline = true
}
channel := &lnrpc.ActiveChannel{
Active: peerOnline,
RemotePubkey: nodeID,
ChannelPoint: chanPoint.String(),
ChanId: chanID,