Skip to content

Commit a04004d

Browse files
committed
terminal: allow lnd GetState RPC on Wallet Ready
1 parent 06864b5 commit a04004d

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
@@ -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

Comments
 (0)