Skip to content

Commit 272409d

Browse files
authored
Merge pull request #806 from lightninglabs/lnd-readiness
terminal: allow wallet unlocker services REST calls
2 parents 00b2f7e + 1a23d34 commit 272409d

File tree

2 files changed

+57
-4
lines changed

2 files changed

+57
-4
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Release Notes
2+
3+
# Integrated Binary Updates
4+
5+
### Lightning Terminal
6+
7+
- [Fixed a bug where REST calls for the `WalletUnlocker` service weren't allowed
8+
on startup](https://github.com/lightninglabs/lightning-terminal/pull/806).
9+
10+
### LND
11+
12+
### Loop
13+
14+
### Pool
15+
16+
### Faraday
17+
18+
### Taproot Assets
19+
20+
# Autopilot
21+
22+
# Contributors (Alphabetical Order)
23+
24+
* Oliver Gugger

terminal.go

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -245,13 +266,21 @@ func (g *LightningTerminal) Run() error {
245266
// have been loaded/created, and before the lnd clients have been
246267
// set up, we need to override the isReady check for this specific
247268
// 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.
249272
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
252281
}
253282

254-
return manualStatus == lndWalletReadyStatus, true
283+
return false, false
255284
}
256285

257286
// Register LND, LiT and Accounts with the status manager.

0 commit comments

Comments
 (0)