diff --git a/cmd/lncli/main.go b/cmd/lncli/main.go index d114226b..9a62f973 100644 --- a/cmd/lncli/main.go +++ b/cmd/lncli/main.go @@ -14,6 +14,7 @@ import ( macaroon "gopkg.in/macaroon.v2" + "github.com/lightningnetwork/lnd/lncfg" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/macaroons" "github.com/roasbeef/btcutil" @@ -26,6 +27,8 @@ import ( const ( defaultTLSCertFilename = "tls.cert" defaultMacaroonFilename = "admin.macaroon" + defaultRpcPort = "10009" + defaultRpcHostPort = "localhost:" + defaultRpcPort ) var ( @@ -143,6 +146,13 @@ func getClientConn(ctx *cli.Context, skipMacaroons bool) *grpc.ClientConn { opts = append(opts, grpc.WithPerRPCCredentials(cred)) } + // We need to use a custom dialer so we can also connect to unix sockets + // and not just TCP addresses. + opts = append( + opts, grpc.WithDialer( + lncfg.ClientAddressDialer(defaultRpcPort), + ), + ) conn, err := grpc.Dial(ctx.GlobalString("rpcserver"), opts...) if err != nil { fatal(err) @@ -159,7 +169,7 @@ func main() { app.Flags = []cli.Flag{ cli.StringFlag{ Name: "rpcserver", - Value: "localhost:10009", + Value: defaultRpcHostPort, Usage: "host:port of ln daemon", }, cli.StringFlag{