diff --git a/config.go b/config.go index 1c478b75..b547e6c4 100644 --- a/config.go +++ b/config.go @@ -189,8 +189,9 @@ type Config struct { // friendly. Because then we can reference the explicit modes in the // help descriptions of the section headers. We'll parse the mode into // a bool for internal use for better code readability. - LndMode string `long:"lnd-mode" description:"The mode to run lnd in, either 'remote' (default) or 'integrated'. 'integrated' means lnd is started alongside the UI and everything is stored in lnd's main data directory, configure everything by using the --lnd.* flags. 'remote' means the UI connects to an existing lnd node and acts as a proxy for gRPC calls to it. In the remote node LiT creates its own directory for log and configuration files, configure everything using the --remote.* flags." choice:"integrated" choice:"remote"` - Lnd *lnd.Config `group:"Integrated lnd (use when lnd-mode=integrated)" namespace:"lnd"` + LndMode string `long:"lnd-mode" description:"The mode to run lnd in, either 'remote' (default) or 'integrated'. 'integrated' means lnd is started alongside the UI and everything is stored in lnd's main data directory, configure everything by using the --lnd.* flags. 'remote' means the UI connects to an existing lnd node and acts as a proxy for gRPC calls to it. In the remote node LiT creates its own directory for log and configuration files, configure everything using the --remote.* flags." choice:"integrated" choice:"remote"` + Lnd *lnd.Config `group:"Integrated lnd (use when lnd-mode=integrated)" namespace:"lnd"` + LndRPCTimeout time.Duration `long:"lndrpctimeout" description:"The timeout for RPC calls to lnd from other sub servers. This can be adjusted for slow lnd instances to give loop/pool/faraday/taproot-assets more time when querying into lnd's RPC methods."` FaradayMode string `long:"faraday-mode" description:"The mode to run faraday in, either 'integrated' (default), 'remote' or 'disable'. 'integrated' means faraday is started alongside the UI and everything is stored in faraday's main data directory, configure everything by using the --faraday.* flags. 'remote' means the UI connects to an existing faraday node and acts as a proxy for gRPC calls to it. 'disable' means that LiT is started without faraday." choice:"integrated" choice:"remote" choice:"disable"` Faraday *faraday.Config `group:"Integrated faraday options (use when faraday-mode=integrated)" namespace:"faraday"` @@ -311,6 +312,7 @@ func defaultConfig() *Config { Network: DefaultNetwork, LndMode: DefaultLndMode, Lnd: &lndDefaultConfig, + LndRPCTimeout: defaultRPCTimeout, LitDir: DefaultLitDir, LetsEncryptListen: defaultLetsEncryptListen, LetsEncryptDir: defaultLetsEncryptDir, @@ -411,6 +413,13 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) { cfg.Lnd.RPCMiddleware.Enable = true } + // We want to make sure the users don't shoot themselves in the foot by + // using a too low value for the lnd RPC timeout. + if cfg.LndRPCTimeout < minimumRPCTimeout { + return nil, fmt.Errorf("lnd RPC timeout must be at least %v "+ + "to avoid problems", minimumRPCTimeout) + } + // Validate the lightning-terminal config options. litDir := lnd.CleanAndExpandPath(preCfg.LitDir) cfg.LetsEncryptDir = lncfg.CleanAndExpandPath(cfg.LetsEncryptDir) diff --git a/terminal.go b/terminal.go index c7b5deef..88a7d3f1 100644 --- a/terminal.go +++ b/terminal.go @@ -74,6 +74,8 @@ const ( defaultServerTimeout = 10 * time.Second defaultConnectTimeout = 15 * time.Second + defaultRPCTimeout = 3 * time.Minute + minimumRPCTimeout = 30 * time.Second defaultStartupTimeout = 5 * time.Second ) @@ -873,6 +875,7 @@ func (g *LightningTerminal) setUpLNDClients(lndQuit chan struct{}) error { BlockUntilUnlocked: true, CallerCtx: ctxc, CheckVersion: minimalCompatibleVersion, + RPCTimeout: g.cfg.LndRPCTimeout, }, ) if err == nil {