Skip to content

Commit

Permalink
fix eclair init
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwiidb committed Aug 11, 2023
1 parent e3d1a75 commit a8fe18a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions init_lnd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 0 additions & 1 deletion lib/service/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
23 changes: 19 additions & 4 deletions lnd/eclair.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import (
)

type EclairClient struct {
host string
password string
host string
password string
IdentityPubkey string
}

type EclairInvoicesSubscriber struct {
Expand All @@ -42,11 +43,17 @@ func (ept *EclairPaymentsTracker) Recv() (*lnrpc.Payment, error) {
return nil, fmt.Errorf("context canceled")

Check warning on line 43 in lnd/eclair.go

View check run for this annotation

Codecov / codecov/patch

lnd/eclair.go#L39-L43

Added lines #L39 - L43 were not covered by tests
}

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

Check warning on line 56 in lnd/eclair.go

View check run for this annotation

Codecov / codecov/patch

lnd/eclair.go#L46-L56

Added lines #L46 - L56 were not covered by tests
}

func (eclair *EclairClient) ListChannels(ctx context.Context, req *lnrpc.ListChannelsRequest, options ...grpc.CallOption) (*lnrpc.ListChannelsResponse, error) {
Expand Down Expand Up @@ -242,3 +249,11 @@ func (eclair *EclairClient) DecodeBolt11(ctx context.Context, bolt11 string, opt
NumMsat: int64(invoice.Amount),
}, nil

Check warning on line 250 in lnd/eclair.go

View check run for this annotation

Codecov / codecov/patch

lnd/eclair.go#L233-L250

Added lines #L233 - L250 were not covered by tests
}

func (eclair *EclairClient) IsIdentityPubkey(pubkey string) (isOurPubkey bool) {
return pubkey == eclair.IdentityPubkey

Check warning on line 254 in lnd/eclair.go

View check run for this annotation

Codecov / codecov/patch

lnd/eclair.go#L253-L254

Added lines #L253 - L254 were not covered by tests
}

func (eclair *EclairClient) GetMainPubkey() (pubkey string) {
return eclair.IdentityPubkey

Check warning on line 258 in lnd/eclair.go

View check run for this annotation

Codecov / codecov/patch

lnd/eclair.go#L257-L258

Added lines #L257 - L258 were not covered by tests
}

0 comments on commit a8fe18a

Please sign in to comment.