ekzyis c66e96bf3f refactor: fix init and use DI
* fix init misuse which makes running tests impossible since tests are run inside a temporary test directory which breaks env loading

* use dependency injection pattern for server creation and global server context in route handlers
2023-11-03 20:34:21 +01:00

28 lines
578 B
Go

package lnd
import (
"log"
"github.com/lightninglabs/lndclient"
)
type LNDClient struct {
*lndclient.GrpcLndServices
}
type LNDConfig = lndclient.LndServicesConfig
func New(config *LNDConfig) (*LNDClient, error) {
var (
rcpLndServices *lndclient.GrpcLndServices
lnd *LNDClient
err error
)
if rcpLndServices, err = lndclient.NewLndServices(config); err != nil {
return nil, err
}
lnd = &LNDClient{GrpcLndServices: rcpLndServices}
log.Printf("Connected to %s running LND v%s", config.LndAddress, lnd.Version.Version)
return lnd, nil
}