@@ -145,6 +145,27 @@ var (
145145 "signrpc" , "walletrpc" , "chainrpc" , "invoicesrpc" ,
146146 },
147147 }
148+
149+ // walletUnlockerServiceMethods defines methods of the wallet unlocker
150+ // service that we don't require macaroons to access. We also allow
151+ // these methods to be called even if lnd is not yet fully marked as
152+ // started up (because it cannot start if it's still locked or no wallet
153+ // exists).
154+ walletUnlockerServiceMethods = map [string ]struct {}{
155+ "/lnrpc.WalletUnlocker/GenSeed" : {},
156+ "/lnrpc.WalletUnlocker/InitWallet" : {},
157+ "/lnrpc.WalletUnlocker/UnlockWallet" : {},
158+ "/lnrpc.WalletUnlocker/ChangePassword" : {},
159+ }
160+
161+ // stateServiceMethods defines status methods that we don't require
162+ // macaroons to access.
163+ stateServiceMethods = map [string ]struct {}{
164+ // The State service must be available at all times, even
165+ // before we can check macaroons, so we whitelist it.
166+ "/lnrpc.State/SubscribeState" : {},
167+ "/lnrpc.State/GetState" : {},
168+ }
148169)
149170
150171// LightningTerminal is the main grand unified binary instance. Its task is to
@@ -244,13 +265,21 @@ func (g *LightningTerminal) Run() error {
244265 // have been loaded/created, and before the lnd clients have been
245266 // set up, we need to override the isReady check for this specific
246267 // URI as soon as LND can accept the call, i.e. when the lnd sub-server
247- // is in the "Wallet Ready" state.
268+ // is in the "Wallet Ready" state. The same goes for the streaming
269+ // variant of the status RPC and any calls to the wallet unlocker
270+ // service.
248271 lndOverride := func (uri , manualStatus string ) (bool , bool ) {
249- if uri != "/lnrpc.State/GetState" {
250- return false , false
272+ _ , isWalletUnlockerService := walletUnlockerServiceMethods [uri ]
273+ _ , isStatusService := stateServiceMethods [uri ]
274+
275+ // If this is a call to the wallet unlocker or status subserver,
276+ // we return true for ready if we've set up everything for lnd,
277+ // and it is just waiting to be unlocked.
278+ if isWalletUnlockerService || isStatusService {
279+ return manualStatus == lndWalletReadyStatus , true
251280 }
252281
253- return manualStatus == lndWalletReadyStatus , true
282+ return false , false
254283 }
255284
256285 // Register LND, LiT and Accounts with the status manager.
0 commit comments