From e51f0eadc9cc6005222336862de02a85fac27f66 Mon Sep 17 00:00:00 2001 From: im-adithya Date: Mon, 22 Jan 2024 17:30:10 +0530 Subject: [PATCH] chore: check if svc lnclient is nil --- echo_handlers.go | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/echo_handlers.go b/echo_handlers.go index 1c237977..0cc8eedb 100644 --- a/echo_handlers.go +++ b/echo_handlers.go @@ -8,7 +8,6 @@ import ( echologrus "github.com/davrux/echo-logrus/v4" "github.com/getAlby/nostr-wallet-connect/frontend" "github.com/getAlby/nostr-wallet-connect/models/api" - "github.com/getAlby/nostr-wallet-connect/models/db" "github.com/gorilla/sessions" "github.com/labstack/echo-contrib/session" "github.com/labstack/echo/v4" @@ -20,31 +19,11 @@ import ( func (svc *Service) ValidateUserMiddleware(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { - dbConfig := db.Config{} - svc.db.First(&dbConfig) - errorMessage := "Configuration not initialized" - - if dbConfig.LNBackendType == "" { + if svc.lnClient == nil { return c.JSON(http.StatusMethodNotAllowed, ErrorResponse{ - Message: errorMessage, + Message: "Lightning Client not initialized", }) } - - switch dbConfig.LNBackendType { - case LNDBackendType: - if dbConfig.LNDAddress == "" || svc.cfg.LNDCertFile == "" || dbConfig.LNDCertHex == "" || svc.cfg.LNDMacaroonFile == "" || dbConfig.LNDMacaroonHex == "" { - return c.JSON(http.StatusMethodNotAllowed, ErrorResponse{ - Message: errorMessage, - }) - } - case BreezBackendType: - if dbConfig.BreezMnemonic == "" || dbConfig.BreezAPIKey == "" || dbConfig.GreenlightInviteCode == "" || svc.cfg.BreezWorkdir == "" { - return c.JSON(http.StatusMethodNotAllowed, ErrorResponse{ - Message: errorMessage, - }) - } - } - return next(c) } }