Skip to content

Commit b0dbbe9

Browse files
terminal: allow lnd GetState RPC on Wallet Ready
1 parent e4c7275 commit b0dbbe9

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

terminal.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,24 @@ func (g *LightningTerminal) Run() error {
238238
return fmt.Errorf("could not create permissions manager")
239239
}
240240

241+
// The litcli status command will call the "/lnrpc.State/GetState" RPC.
242+
// As the status command is available to the user before the macaroons
243+
// have been loaded/created, and before the lnd clients have been
244+
// set up, we need to override the isReady check for this specific
245+
// URI as soon as LND can accept the call, i.e. when the lnd sub-server
246+
// is in the "Wallet Ready" state.
247+
lndOverride := func(uri, manualStatus string) (bool, bool) {
248+
if uri != "/lnrpc.State/GetState" {
249+
return false, false
250+
}
251+
252+
return manualStatus == lndWalletReadyStatus, true
253+
}
254+
241255
// Register LND, LiT and Accounts with the status manager.
242-
g.statusMgr.RegisterAndEnableSubServer(subservers.LND)
256+
g.statusMgr.RegisterAndEnableSubServer(
257+
subservers.LND, status.WithIsReadyOverride(lndOverride),
258+
)
243259
g.statusMgr.RegisterAndEnableSubServer(subservers.LIT)
244260
g.statusMgr.RegisterSubServer(subservers.ACCOUNTS)
245261

@@ -556,6 +572,9 @@ func (g *LightningTerminal) start() error {
556572

557573
// We now set a custom status for the LND sub-server to indicate that
558574
// the wallet is ready.
575+
// This is done _before_ we have set up the lnd clients so that the
576+
// litcli status command won't error before the lnd sub-server has
577+
// been marked as running.
559578
g.statusMgr.SetCustomStatus(subservers.LND, lndWalletReadyStatus)
560579

561580
// Now that we have started the main UI web server, show some useful

0 commit comments

Comments
 (0)