Skip to content

Commit

Permalink
feat: Extend GetInfo RPC with LND identity, node alias, block height,…
Browse files Browse the repository at this point in the history
… and block hash

Added additional fields to the GetInfo RPC response to provide richer details about the blockchain and the LND node. This includes the LND node's public key (identity), its alias, the current block height, and the latest block's hash.
  • Loading branch information
ben2077 committed Oct 14, 2023
1 parent b8af77d commit 1a409c7
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 188 deletions.
27 changes: 22 additions & 5 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,30 @@ func (r *rpcServer) DebugLevel(ctx context.Context,

// GetInfo returns general information relating to the active daemon. For
// example: its version, network, and lnd version.
func (r *rpcServer) GetInfo(context.Context,
*taprpc.GetInfoRequest) (*taprpc.GetInfoResponse, error) {
func (r *rpcServer) GetInfo(ctx context.Context,
_ *taprpc.GetInfoRequest) (*taprpc.GetInfoResponse, error) {

// Retrieve the best block hash and height from the chain backend.
blockHash, blockHeight, err := r.cfg.Lnd.ChainKit.GetBestBlock(ctx)
if err != nil {
return nil, err
}

// Retrieve the current lnd node's info.
info, err := r.cfg.Lnd.Client.GetInfo(context.Background())
if err != nil {
return nil, err
}

return &taprpc.GetInfoResponse{
Version: Version(),
LndVersion: r.cfg.Lnd.Version.Version,
Network: r.cfg.ChainParams.Name,
Version: Version(),
LndVersion: r.cfg.Lnd.Version.Version,
Network: r.cfg.ChainParams.Name,
LndIdentityPubkey: r.cfg.Lnd.NodePubkey.String(),
NodeAlias: info.Alias,
BlockHeight: uint32(blockHeight),
BlockHash: blockHash.String(),
SyncToChain: info.SyncedToChain,
}, nil
}

Expand Down
Loading

0 comments on commit 1a409c7

Please sign in to comment.