@@ -234,8 +234,24 @@ func (g *LightningTerminal) Run() error {
234234 return fmt .Errorf ("could not create permissions manager" )
235235 }
236236
237+ // The litcli status command will call the "/lnrpc.State/GetState" RPC.
238+ // As the status command is available to the user before the macaroons
239+ // have been loaded/created, and before the lnd clients have been
240+ // set up, we need to override the isReady check for this specific
241+ // URI as soon as LND can accept the call, i.e. when the lnd sub-server
242+ // is in the "Wallet Ready" state.
243+ lndOverride := func (uri , manualStatus string ) (bool , bool ) {
244+ if uri != "/lnrpc.State/GetState" {
245+ return false , false
246+ }
247+
248+ return manualStatus == lndWalletReadyStatus , true
249+ }
250+
237251 // Register LND, LiT and Accounts with the status manager.
238- g .statusMgr .RegisterAndEnableSubServer (subservers .LND )
252+ g .statusMgr .RegisterAndEnableSubServer (
253+ subservers .LND , status .WithIsReadyOverride (lndOverride ),
254+ )
239255 g .statusMgr .RegisterAndEnableSubServer (subservers .LIT )
240256 g .statusMgr .RegisterSubServer (subservers .ACCOUNTS )
241257
@@ -552,6 +568,9 @@ func (g *LightningTerminal) start() error {
552568
553569 // We now set a custom status for the LND sub-server to indicate that
554570 // the wallet is ready.
571+ // This is done _before_ we have set up the lnd clients so that the
572+ // litcli status command won't error before the lnd sub-server has
573+ // been marked as running.
555574 g .statusMgr .SetCustomStatus (subservers .LND , lndWalletReadyStatus )
556575
557576 // Now that we have started the main UI web server, show some useful
0 commit comments