Skip to content

Commit 8790d3b

Browse files
committed
config+terminal: allow configuring of lnd RPC timeout
1 parent 2150446 commit 8790d3b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

config.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,9 @@ type Config struct {
189189
// friendly. Because then we can reference the explicit modes in the
190190
// help descriptions of the section headers. We'll parse the mode into
191191
// a bool for internal use for better code readability.
192-
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"`
193-
Lnd *lnd.Config `group:"Integrated lnd (use when lnd-mode=integrated)" namespace:"lnd"`
192+
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"`
193+
Lnd *lnd.Config `group:"Integrated lnd (use when lnd-mode=integrated)" namespace:"lnd"`
194+
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."`
194195

195196
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"`
196197
Faraday *faraday.Config `group:"Integrated faraday options (use when faraday-mode=integrated)" namespace:"faraday"`
@@ -311,6 +312,7 @@ func defaultConfig() *Config {
311312
Network: DefaultNetwork,
312313
LndMode: DefaultLndMode,
313314
Lnd: &lndDefaultConfig,
315+
LndRPCTimeout: defaultRPCTimeout,
314316
LitDir: DefaultLitDir,
315317
LetsEncryptListen: defaultLetsEncryptListen,
316318
LetsEncryptDir: defaultLetsEncryptDir,
@@ -411,6 +413,13 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
411413
cfg.Lnd.RPCMiddleware.Enable = true
412414
}
413415

416+
// We want to make sure the users don't shoot themselves in the foot by
417+
// using a too low value for the lnd RPC timeout.
418+
if cfg.LndRPCTimeout < minimumRPCTimeout {
419+
return nil, fmt.Errorf("lnd RPC timeout must be at least %v "+
420+
"to avoid problems", minimumRPCTimeout)
421+
}
422+
414423
// Validate the lightning-terminal config options.
415424
litDir := lnd.CleanAndExpandPath(preCfg.LitDir)
416425
cfg.LetsEncryptDir = lncfg.CleanAndExpandPath(cfg.LetsEncryptDir)

terminal.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ const (
7474

7575
defaultServerTimeout = 10 * time.Second
7676
defaultConnectTimeout = 15 * time.Second
77+
defaultRPCTimeout = 3 * time.Minute
78+
minimumRPCTimeout = 30 * time.Second
7779
defaultStartupTimeout = 5 * time.Second
7880
)
7981

@@ -873,6 +875,7 @@ func (g *LightningTerminal) setUpLNDClients(lndQuit chan struct{}) error {
873875
BlockUntilUnlocked: true,
874876
CallerCtx: ctxc,
875877
CheckVersion: minimalCompatibleVersion,
878+
RPCTimeout: g.cfg.LndRPCTimeout,
876879
},
877880
)
878881
if err == nil {

0 commit comments

Comments
 (0)