diff --git a/lnd/config.go b/lnd/config.go index 381ba361..41cabceb 100644 --- a/lnd/config.go +++ b/lnd/config.go @@ -19,6 +19,7 @@ type Config struct { LNDCertHex string `envconfig:"LND_CERT_HEX"` LNDClusterLivenessPeriod int `envconfig:"LND_CLUSTER_LIVENESS_PERIOD" default:"10"` LNDClusterActiveChannelRatio float64 `envconfig:"LND_CLUSTER_ACTIVE_CHANNEL_RATIO" default:"0.5"` + LNDClusterPubkeys string `envconfig:"LND_CLUSTER_PUBKEYS"` //comma-seperated list of public keys of the cluster } func LoadConfig() (c *Config, err error) { diff --git a/lnd/ln_client.go b/lnd/ln_client.go index 41b3853b..ccf05776 100644 --- a/lnd/ln_client.go +++ b/lnd/ln_client.go @@ -61,12 +61,16 @@ func InitSingleLNDClient(c *Config, ctx context.Context) (result LightningClient } func InitLNDCluster(c *Config, logger *lecho.Logger, ctx context.Context) (result LightningClientWrapper, err error) { nodes := []LightningClientWrapper{} - //interpret lnd address, macaroon file & cert file as comma seperated values + //interpret lnd address, macaroon file, cert file, pubkeys as comma seperated values addresses := strings.Split(c.LNDAddress, ",") macaroons := strings.Split(c.LNDMacaroonFile, ",") + pubkeys := strings.Split(c.LNDClusterPubkeys, ",") certs := strings.Split(c.LNDCertFile, ",") - if len(addresses) != len(macaroons) || len(addresses) != len(certs) || len(certs) != len(macaroons) { - return nil, fmt.Errorf("Error parsing LND cluster config: addresses, macaroons or certs array length mismatch") + if len(addresses) != len(macaroons) || + len(addresses) != len(certs) || + len(certs) != len(macaroons) || + len(pubkeys) != len(macaroons) { + return nil, fmt.Errorf("Error parsing LND cluster config: addresses, macaroons, certs or pubkeys array length mismatch") } for i := 0; i < len(addresses); i++ { n, err := NewLNDclient(LNDoptions{ @@ -77,11 +81,7 @@ func InitLNDCluster(c *Config, logger *lecho.Logger, ctx context.Context) (resul if err != nil { return nil, err } - getInfo, err := n.GetInfo(ctx, &lnrpc.GetInfoRequest{}) - if err != nil { - return nil, err - } - n.IdentityPubkey = getInfo.IdentityPubkey + n.IdentityPubkey = pubkeys[i] nodes = append(nodes, n) } logger.Infof("Initialized LND cluster with %d nodes", len(nodes))