rpcserver: populate block height, chain synced, and testnet in GetInfo

This commit is contained in:
Olaoluwa Osuntokun 2016-12-12 15:34:47 -08:00
parent a011a3f414
commit f61f3d0b71
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -21,6 +21,7 @@ import (
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/rt/graph"
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/chaincfg"
"github.com/roasbeef/btcd/txscript"
"github.com/roasbeef/btcd/wire"
"github.com/roasbeef/btcutil"
@ -427,12 +428,24 @@ func (r *rpcServer) GetInfo(ctx context.Context,
pendingChannels := r.server.fundingMgr.NumPendingChannels()
idPub := r.server.identityPriv.PubKey().SerializeCompressed()
currentHeight, err := r.server.bio.GetCurrentHeight()
if err != nil {
return nil, err
}
isSynced, err := r.server.lnwallet.IsSynced()
if err != nil {
return nil, err
}
return &lnrpc.GetInfoResponse{
LightningId: hex.EncodeToString(r.server.lightningID[:]),
IdentityPubkey: hex.EncodeToString(idPub),
NumPendingChannels: pendingChannels,
NumActiveChannels: activeChannels,
NumPeers: uint32(len(serverPeers)),
BlockHeight: uint32(currentHeight),
SyncedToChain: isSynced,
Testnet: activeNetParams.Params == &chaincfg.TestNet3Params,
}, nil
}