Skip to content

Commit f9a606d

Browse files
terminal: setup LND prior to stores
In the upcoming actions migration, we need fetch LNDs macaroons prior to initializing the stores, as the macaroons will be required during the migration. This requires that we setup the connection to LND before we initialize the stores, as we can only fetch the macaroons after the LND connection is established. This commit refactors the litd startup process, so that the stores are initialized after the LND connection is established.
1 parent 7dafaed commit f9a606d

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

terminal.go

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -447,22 +447,6 @@ func (g *LightningTerminal) start(ctx context.Context) error {
447447
return fmt.Errorf("could not create network directory: %v", err)
448448
}
449449

450-
g.stores, err = NewStores(g.cfg, clock.NewDefaultClock())
451-
if err != nil {
452-
return fmt.Errorf("could not create stores: %v", err)
453-
}
454-
455-
if err := g.stores.firewall.Start(ctx); err != nil {
456-
return fmt.Errorf("could not start firewall DB: %v", err)
457-
}
458-
459-
g.accountService, err = accounts.NewService(
460-
g.stores.accounts, accountServiceErrCallback,
461-
)
462-
if err != nil {
463-
return fmt.Errorf("error creating account service: %v", err)
464-
}
465-
466450
// We create a reference to the `accountRpcServer` here before starting
467451
// it and prior to setting up the LND connection. This is because when
468452
// the LND connection is set up for an integrated LND instance, LND will
@@ -750,6 +734,27 @@ func (g *LightningTerminal) start(ctx context.Context) error {
750734
// lnd clients.
751735
g.statusMgr.SetRunning(subservers.LND)
752736

737+
g.stores, err = NewStores(g.cfg, clock.NewDefaultClock())
738+
if err != nil {
739+
return fmt.Errorf("could not create stores: %v", err)
740+
}
741+
742+
if err := g.stores.firewall.Start(ctx); err != nil {
743+
return fmt.Errorf("could not start firewall DB: %v", err)
744+
}
745+
746+
g.accountService, err = accounts.NewService(
747+
g.stores.accounts, accountServiceErrCallback,
748+
)
749+
if err != nil {
750+
return fmt.Errorf("error creating account service: %v", err)
751+
}
752+
753+
if err != nil {
754+
return fmt.Errorf("could not create new session rpc "+
755+
"server: %v", err)
756+
}
757+
753758
// Both connection types are ready now, let's start our sub-servers if
754759
// they should be started locally as an integrated service.
755760
createDefaultMacaroons := !g.cfg.statelessInitMode

0 commit comments

Comments
 (0)