Skip to content

Commit 17b2574

Browse files
ben2077guggero
authored andcommitted
feat: Extend GetInfo RPC with LND identity, node alias, block height, 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.
1 parent ad82870 commit 17b2574

File tree

4 files changed

+280
-190
lines changed

4 files changed

+280
-190
lines changed

rpcserver.go

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,30 @@ func (r *rpcServer) DebugLevel(ctx context.Context,
284284

285285
// GetInfo returns general information relating to the active daemon. For
286286
// example: its version, network, and lnd version.
287-
func (r *rpcServer) GetInfo(context.Context,
288-
*taprpc.GetInfoRequest) (*taprpc.GetInfoResponse, error) {
287+
func (r *rpcServer) GetInfo(ctx context.Context,
288+
_ *taprpc.GetInfoRequest) (*taprpc.GetInfoResponse, error) {
289+
290+
// Retrieve the best block hash and height from the chain backend.
291+
blockHash, blockHeight, err := r.cfg.Lnd.ChainKit.GetBestBlock(ctx)
292+
if err != nil {
293+
return nil, err
294+
}
295+
296+
// Retrieve the current lnd node's info.
297+
info, err := r.cfg.Lnd.Client.GetInfo(context.Background())
298+
if err != nil {
299+
return nil, err
300+
}
289301

290302
return &taprpc.GetInfoResponse{
291-
Version: Version(),
292-
LndVersion: r.cfg.Lnd.Version.Version,
293-
Network: r.cfg.ChainParams.Name,
303+
Version: Version(),
304+
LndVersion: r.cfg.Lnd.Version.Version,
305+
Network: r.cfg.ChainParams.Name,
306+
LndIdentityPubkey: r.cfg.Lnd.NodePubkey.String(),
307+
NodeAlias: info.Alias,
308+
BlockHeight: uint32(blockHeight),
309+
BlockHash: blockHash.String(),
310+
SyncToChain: info.SyncedToChain,
294311
}, nil
295312
}
296313

0 commit comments

Comments
 (0)