Merge pull request #1330 from ViktorT-11/2026-06-stop-lnd-on-mig-prompt-abort

[sql-77] terminal: shut down LiT when declining the SQL migration prompt
This commit is contained in:
Viktor Torstensson 2026-06-17 00:44:44 +02:00 committed by GitHub
commit edbd4f51b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 3 deletions

View file

@ -17,6 +17,10 @@ import (
const autoMigrateKVDBEnvVar = "LIT_AUTO_MIGRATE_TO_SQL"
var errKVDBToSQLMigrationDeclined = errors.New(
"manual confirmation declined",
)
var kvdbToSQLMigrationPromptLines = []string{
"",
"CAUTION: litd is about to migrate your existing data to a new SQL " +
@ -175,8 +179,8 @@ func promptForKVDBToSQLMigrationConfirmation(input io.Reader,
}
if strings.TrimSpace(answer) != "yes" {
return errors.New("manual confirmation declined; refusing to " +
"continue kvdb-to-SQL migration")
return fmt.Errorf("%w; refusing to continue kvdb-to-SQL "+
"migration", errKVDBToSQLMigrationDeclined)
}
return nil

View file

@ -58,7 +58,7 @@ func TestConfirmPendingKVDBToSQLMigration(t *testing.T) {
createActiveAccountsKVDB(t, dbDir)
},
input: "no\n",
expectErr: "manual confirmation declined",
expectErr: errKVDBToSQLMigrationDeclined.Error(),
},
{
name: "skips prompt on auto migration config",

View file

@ -405,6 +405,19 @@ func (g *LightningTerminal) Run(ctx context.Context) error {
g.statusMgr.SetErrored(
subservers.LIT, "could not start Lit: %v", startErr,
)
// If the user has declined the migration prompt, we shut down
// Lit fully, and do not keep the status server up and running.
// The motivation for this is that the error occurs prior to
// Lit being able to accept a `litcli stop` call. Users running
// in an env that can't easily kill the daemon therefore need to
// be able to shut it down by just declining the migration.
// Note that no sub-servers, including `lnd`, have been
// started/connected to when the migration prompt is shown. We
// can therefore safely shut Lit down without affecting them.
if errors.Is(startErr, errKVDBToSQLMigrationDeclined) {
shutdownInterceptor.RequestShutdown()
}
}
// Now block until we receive an error or the main shutdown