mirror of
https://github.com/getAlby/lndhub.go.git
synced 2026-02-23 13:54:25 +01:00
fix eclair init
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user