diff --git a/init_lnd.go b/init_lnd.go index b3618ba3..3f038b9e 100644 --- a/init_lnd.go +++ b/init_lnd.go @@ -17,6 +17,8 @@ func InitLNClient(c *service.Config, logger *lecho.Logger, ctx context.Context) return InitSingleLNDClient(c, ctx) case service.LND_CLUSTER_CLIENT_TYPE: return InitLNDCluster(c, logger, ctx) + case service.ECLAIR_CLIENT_TYPE: + return lnd.NewEclairClient(c.LNDAddress, c.EclairPassword, ctx) default: return nil, fmt.Errorf("Did not recognize LN client type %s", c.LNClientType) } diff --git a/lib/service/config.go b/lib/service/config.go index 38ca101a..8163c4d4 100644 --- a/lib/service/config.go +++ b/lib/service/config.go @@ -31,7 +31,6 @@ type Config struct { LNDCertFile string `envconfig:"LND_CERT_FILE"` LNDMacaroonHex string `envconfig:"LND_MACAROON_HEX"` LNDCertHex string `envconfig:"LND_CERT_HEX"` - EclairHost string `envconfig:"ECLAIR_HOST"` EclairPassword string `envconfig:"ECLAIR_PASSWORD"` LNDClusterLivenessPeriod int `envconfig:"LND_CLUSTER_LIVENESS_PERIOD" default:"10"` LNDClusterActiveChannelRatio float64 `envconfig:"LND_CLUSTER_ACTIVE_CHANNEL_RATIO" default:"0.5"` diff --git a/lnd/eclair.go b/lnd/eclair.go index 9a35ab6e..1c4b79f7 100644 --- a/lnd/eclair.go +++ b/lnd/eclair.go @@ -16,8 +16,9 @@ import ( ) type EclairClient struct { - host string - password string + host string + password string + IdentityPubkey string } type EclairInvoicesSubscriber struct { @@ -42,11 +43,17 @@ func (ept *EclairPaymentsTracker) Recv() (*lnrpc.Payment, error) { return nil, fmt.Errorf("context canceled") } -func NewEclairClient(host, password string) *EclairClient { - return &EclairClient{ +func NewEclairClient(host, password string, ctx context.Context) (result *EclairClient, err error) { + result = &EclairClient{ host: host, password: password, } + info, err := result.GetInfo(ctx, &lnrpc.GetInfoRequest{}) + if err != nil { + return nil, err + } + result.IdentityPubkey = info.IdentityPubkey + return result, nil } func (eclair *EclairClient) ListChannels(ctx context.Context, req *lnrpc.ListChannelsRequest, options ...grpc.CallOption) (*lnrpc.ListChannelsResponse, error) { @@ -242,3 +249,11 @@ func (eclair *EclairClient) DecodeBolt11(ctx context.Context, bolt11 string, opt NumMsat: int64(invoice.Amount), }, nil } + +func (eclair *EclairClient) IsIdentityPubkey(pubkey string) (isOurPubkey bool) { + return pubkey == eclair.IdentityPubkey +} + +func (eclair *EclairClient) GetMainPubkey() (pubkey string) { + return eclair.IdentityPubkey +}