rpcserver: add uris to getinfo response
This commit is contained in:
parent
a61b6428e8
commit
f4a649b30a
17
rpcserver.go
17
rpcserver.go
@ -1096,6 +1096,7 @@ func (r *rpcServer) GetInfo(ctx context.Context,
|
|||||||
nPendingChannels := uint32(len(pendingChannels))
|
nPendingChannels := uint32(len(pendingChannels))
|
||||||
|
|
||||||
idPub := r.server.identityPriv.PubKey().SerializeCompressed()
|
idPub := r.server.identityPriv.PubKey().SerializeCompressed()
|
||||||
|
encodedIDPub := hex.EncodeToString(idPub)
|
||||||
|
|
||||||
bestHash, bestHeight, err := r.server.cc.chainIO.GetBestBlock()
|
bestHash, bestHeight, err := r.server.cc.chainIO.GetBestBlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1113,9 +1114,22 @@ func (r *rpcServer) GetInfo(ctx context.Context,
|
|||||||
activeChains[i] = chain.String()
|
activeChains[i] = chain.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if external IP addresses were provided to lnd and use them
|
||||||
|
// to set the URIs.
|
||||||
|
nodeAnn, err := r.server.genNodeAnnouncement(false)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("unable to retrieve current fully signed "+
|
||||||
|
"node announcement: %v", err)
|
||||||
|
}
|
||||||
|
addrs := nodeAnn.Addresses
|
||||||
|
uris := make([]string, len(addrs))
|
||||||
|
for i, addr := range addrs {
|
||||||
|
uris[i] = fmt.Sprintf("%s@%s", encodedIDPub, addr.String())
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(roasbeef): add synced height n stuff
|
// TODO(roasbeef): add synced height n stuff
|
||||||
return &lnrpc.GetInfoResponse{
|
return &lnrpc.GetInfoResponse{
|
||||||
IdentityPubkey: hex.EncodeToString(idPub),
|
IdentityPubkey: encodedIDPub,
|
||||||
NumPendingChannels: nPendingChannels,
|
NumPendingChannels: nPendingChannels,
|
||||||
NumActiveChannels: activeChannels,
|
NumActiveChannels: activeChannels,
|
||||||
NumPeers: uint32(len(serverPeers)),
|
NumPeers: uint32(len(serverPeers)),
|
||||||
@ -1124,6 +1138,7 @@ func (r *rpcServer) GetInfo(ctx context.Context,
|
|||||||
SyncedToChain: isSynced,
|
SyncedToChain: isSynced,
|
||||||
Testnet: activeNetParams.Params == &chaincfg.TestNet3Params,
|
Testnet: activeNetParams.Params == &chaincfg.TestNet3Params,
|
||||||
Chains: activeChains,
|
Chains: activeChains,
|
||||||
|
Uris: uris,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user