multi: remove unused error return value

There is no error case left in the lndConnectParams() method so we can
remove the error return type and simplify its use.
This commit is contained in:
Oliver Gugger 2021-02-16 13:39:31 +01:00
parent 680a47c269
commit 6e1803bdee
No known key found for this signature in database
GPG key ID: 8E4256593F177720
3 changed files with 12 additions and 23 deletions

View file

@ -188,8 +188,8 @@ type RemoteDaemonConfig struct {
// lndConnectParams returns the connection parameters to connect to the local
// lnd instance.
func (c *Config) lndConnectParams() (string, lndclient.Network, string, string,
error) {
func (c *Config) lndConnectParams() (string, lndclient.Network, string,
string) {
// In remote lnd mode, we just pass along what was configured in the
// remote section of the lnd config.
@ -211,7 +211,7 @@ func (c *Config) lndConnectParams() (string, lndclient.Network, string, string,
return c.Remote.Lnd.RPCServer,
lndclient.Network(c.network),
lncfg.CleanAndExpandPath(c.Remote.Lnd.TLSCertPath),
macPath, nil
macPath
}
// When we start lnd internally, we take the listen address as
@ -233,7 +233,7 @@ func (c *Config) lndConnectParams() (string, lndclient.Network, string, string,
}
return lndDialAddr, lndclient.Network(c.network),
c.Lnd.TLSCertPath, c.Lnd.AdminMacPath, nil
c.Lnd.TLSCertPath, c.Lnd.AdminMacPath
}
// defaultConfig returns a configuration struct with all default values set.

View file

@ -126,11 +126,10 @@ type rpcProxy struct {
// Start creates initial connection to lnd.
func (p *rpcProxy) Start() error {
var err error
// Setup the connection to lnd.
host, _, tlsPath, _, err := p.cfg.lndConnectParams()
if err != nil {
return err
}
host, _, tlsPath, _ := p.cfg.lndConnectParams()
p.lndConn, err = dialLnd(host, tlsPath)
if err != nil {
return fmt.Errorf("could not dial lnd: %v", err)
@ -308,13 +307,10 @@ func (p *rpcProxy) basicAuthToMacaroon(ctx context.Context,
return ctx, nil
}
var (
macPath string
err error
)
var macPath string
switch {
case isLndURI(requestURI):
_, _, _, macPath, err = p.cfg.lndConnectParams()
_, _, _, macPath = p.cfg.lndConnectParams()
case isLoopURI(requestURI):
macPath = p.cfg.Loop.MacaroonPath
@ -329,9 +325,6 @@ func (p *rpcProxy) basicAuthToMacaroon(ctx context.Context,
return ctx, fmt.Errorf("unknown gRPC web request: %v",
requestURI)
}
if err != nil {
return ctx, fmt.Errorf("error getting macaroon path: %v", err)
}
// Now that we know which macaroon to load, do it and attach it to the
// request context.

View file

@ -250,18 +250,14 @@ func (g *LightningTerminal) Run() error {
// servers that lnd started.
func (g *LightningTerminal) startSubservers() error {
var basicClient lnrpc.LightningClient
host, network, tlsPath, macPath, err := g.cfg.lndConnectParams()
if err != nil {
return err
}
host, network, tlsPath, macPath := g.cfg.lndConnectParams()
// The main RPC listener of lnd might need some time to start, it could
// be that we run into a connection refused a few times. We use the
// basic client connection to find out if the RPC server is started yet
// because that doesn't do anything else than just connect. We'll check
// if lnd is also ready to be used in the next step.
err = wait.NoError(func() error {
err := wait.NoError(func() error {
// Create an lnd client now that we have the full configuration.
// We'll need a basic client and a full client because not all
// subservers have the same requirements.
@ -645,7 +641,7 @@ func (g *LightningTerminal) showStartupInfo() error {
if g.cfg.LndMode == ModeRemote {
// We try to query GetInfo on the remote node to find out the
// alias. But the wallet might be locked.
host, network, tlsPath, macPath, _ := g.cfg.lndConnectParams()
host, network, tlsPath, macPath := g.cfg.lndConnectParams()
basicClient, err := lndclient.NewBasicClient(
host, tlsPath, path.Dir(macPath), string(network),
lndclient.MacFilename(path.Base(macPath)),