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

This commit is contained in:
Olaoluwa Osuntokun committed 2016-12-12 15:56:58 -08:00
1 parent a011a3f414
commit f61f3d0b71
1 file changed
+14 -1
+14 -1
View File
@@ -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
}