Skip to content

Commit d4046a6

Browse files
authored
Merge pull request #235 from joostjager/basic-conn
lndclient: extract basic connection
2 parents 40cb964 + db69720 commit d4046a6

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

lndclient/basic_client.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,29 @@ func (bc *basicClientOptions) applyBasicClientOptions(options ...BasicClientOpti
5252
// NewBasicClient creates a new basic gRPC client to lnd. We call this client
5353
// "basic" as it falls back to expected defaults if the arguments aren't
5454
// provided.
55-
func NewBasicClient(lndHost, tlsPath, macDir, network string, basicOptions ...BasicClientOption) (
55+
func NewBasicClient(lndHost, tlsPath, macDir, network string,
56+
basicOptions ...BasicClientOption) (
57+
5658
lnrpc.LightningClient, error) {
5759

60+
conn, err := NewBasicConn(
61+
lndHost, tlsPath, macDir, network, basicOptions...,
62+
)
63+
if err != nil {
64+
return nil, err
65+
}
66+
67+
return lnrpc.NewLightningClient(conn), nil
68+
}
69+
70+
// NewBasicConn creates a new basic gRPC connection to lnd. We call this
71+
// connection "basic" as it falls back to expected defaults if the arguments
72+
// aren't provided.
73+
func NewBasicConn(lndHost, tlsPath, macDir, network string,
74+
basicOptions ...BasicClientOption) (
75+
76+
*grpc.ClientConn, error) {
77+
5878
if tlsPath == "" {
5979
tlsPath = defaultTLSCertPath
6080
}
@@ -112,5 +132,5 @@ func NewBasicClient(lndHost, tlsPath, macDir, network string, basicOptions ...Ba
112132
return nil, fmt.Errorf("unable to connect to RPC server: %v", err)
113133
}
114134

115-
return lnrpc.NewLightningClient(conn), nil
135+
return conn, nil
116136
}

0 commit comments

Comments
 (0)