Obtain node name and pubkey from the node itself if not found in env

This commit is contained in:
Yaacov Akiba Slama
2020-08-18 17:03:18 +03:00
parent a6c770462d
commit a8d226abb8

View File

@@ -47,12 +47,14 @@ var (
openChannelReqGroup singleflight.Group openChannelReqGroup singleflight.Group
privateKey *btcec.PrivateKey privateKey *btcec.PrivateKey
publicKey *btcec.PublicKey publicKey *btcec.PublicKey
nodeName = os.Getenv("NODE_NAME")
nodePubkey = os.Getenv("NODE_PUBKEY")
) )
func (s *server) ChannelInformation(ctx context.Context, in *lspdrpc.ChannelInformationRequest) (*lspdrpc.ChannelInformationReply, error) { func (s *server) ChannelInformation(ctx context.Context, in *lspdrpc.ChannelInformationRequest) (*lspdrpc.ChannelInformationReply, error) {
return &lspdrpc.ChannelInformationReply{ return &lspdrpc.ChannelInformationReply{
Name: os.Getenv("NODE_NAME"), Name: nodeName,
Pubkey: os.Getenv("NODE_PUBKEY"), Pubkey: nodePubkey,
Host: os.Getenv("NODE_HOST"), Host: os.Getenv("NODE_HOST"),
ChannelCapacity: channelAmount, ChannelCapacity: channelAmount,
TargetConf: targetConf, TargetConf: targetConf,
@@ -220,6 +222,19 @@ func main() {
defer conn.Close() defer conn.Close()
client = lnrpc.NewLightningClient(conn) client = lnrpc.NewLightningClient(conn)
routerClient = routerrpc.NewRouterClient(conn) routerClient = routerrpc.NewRouterClient(conn)
clientCtx := metadata.AppendToOutgoingContext(context.Background(), "macaroon", os.Getenv("LND_MACAROON_HEX"))
info, err := client.GetInfo(clientCtx, &lnrpc.GetInfoRequest{})
if err != nil {
log.Fatalf("client.GetInfo() error: %v", err)
}
if nodeName == "" {
nodeName = info.Alias
}
if nodePubkey == "" {
nodePubkey = info.IdentityPubkey
}
go intercept() go intercept()
s := grpc.NewServer( s := grpc.NewServer(