@@ -145,6 +145,27 @@ var (
145
145
"signrpc" , "walletrpc" , "chainrpc" , "invoicesrpc" ,
146
146
},
147
147
}
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
+ }
148
169
)
149
170
150
171
// LightningTerminal is the main grand unified binary instance. Its task is to
@@ -245,13 +266,21 @@ func (g *LightningTerminal) Run() error {
245
266
// have been loaded/created, and before the lnd clients have been
246
267
// set up, we need to override the isReady check for this specific
247
268
// URI as soon as LND can accept the call, i.e. when the lnd sub-server
248
- // is in the "Wallet Ready" state.
269
+ // is in the "Wallet Ready" state. The same goes for the streaming
270
+ // variant of the status RPC and any calls to the wallet unlocker
271
+ // service.
249
272
lndOverride := func (uri , manualStatus string ) (bool , bool ) {
250
- if uri != "/lnrpc.State/GetState" {
251
- return false , false
273
+ _ , isWalletUnlockerService := walletUnlockerServiceMethods [uri ]
274
+ _ , isStatusService := stateServiceMethods [uri ]
275
+
276
+ // If this is a call to the wallet unlocker or status subserver,
277
+ // we return true for ready if we've set up everything for lnd,
278
+ // and it is just waiting to be unlocked.
279
+ if isWalletUnlockerService || isStatusService {
280
+ return manualStatus == lndWalletReadyStatus , true
252
281
}
253
282
254
- return manualStatus == lndWalletReadyStatus , true
283
+ return false , false
255
284
}
256
285
257
286
// Register LND, LiT and Accounts with the status manager.
0 commit comments