mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopd: make lnd conn configurable
This commit is contained in:
parent
34c2e71f9e
commit
0a51bf4d2d
1 changed files with 20 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package loopd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
|
|
@ -36,6 +37,10 @@ type RPCConfig struct {
|
|||
// listener.
|
||||
// Note that setting this will also disable REST.
|
||||
RPCListener net.Listener
|
||||
|
||||
// LndConn is an optional connection to an lnd instance. If set it will
|
||||
// override the TCP connection created from daemon's config.
|
||||
LndConn net.Conn
|
||||
}
|
||||
|
||||
// newListenerCfg creates and returns a new listenerCfg from the passed config
|
||||
|
|
@ -62,6 +67,21 @@ func newListenerCfg(config *config, rpcCfg RPCConfig) *listenerCfg {
|
|||
getLnd: func(network string, cfg *lndConfig) (
|
||||
*lndclient.GrpcLndServices, error) {
|
||||
|
||||
// If a custom lnd connection is specified we use that
|
||||
// directly.
|
||||
if rpcCfg.LndConn != nil {
|
||||
dialer := func(context.Context, string) (
|
||||
net.Conn, error) {
|
||||
return rpcCfg.LndConn, nil
|
||||
}
|
||||
|
||||
return lndclient.NewLndServicesWithDialer(
|
||||
dialer,
|
||||
rpcCfg.LndConn.RemoteAddr().String(),
|
||||
network, cfg.MacaroonDir, cfg.TLSPath,
|
||||
)
|
||||
}
|
||||
|
||||
return lndclient.NewLndServices(
|
||||
cfg.Host, network, cfg.MacaroonDir, cfg.TLSPath,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue