mirror of
https://github.com/aljazceru/lspd.git
synced 2025-12-19 06:44:23 +01:00
Obtain node name and pubkey from the node itself if not found in env
This commit is contained in:
19
server.go
19
server.go
@@ -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(
|
||||||
|
|||||||
Reference in New Issue
Block a user