diff --git a/controllers/blank.ctrl.go b/controllers/blank.ctrl.go new file mode 100644 index 0000000..57f3b83 --- /dev/null +++ b/controllers/blank.ctrl.go @@ -0,0 +1,31 @@ +package controllers + +import ( + "net/http" + + "github.com/getAlby/lndhub.go/lib/service" + "github.com/labstack/echo/v4" +) + +// BlankController : Controller for endpoints that we do not support and simply return +// a blank response for compatibility + +// GetBtcController : GetBtcController struct +type BlankController struct{} + +func NewBlankController(svc *service.LndhubService) *BlankController { + return &BlankController{} +} + +// We do NOT support onchain transactions thus we only return an empty array for backwards compatibility +func (controller *BlankController) GetBtc(c echo.Context) error { + addresses := []string{} + + return c.JSON(http.StatusOK, &addresses) +} + +func (controller *BlankController) GetPending(c echo.Context) error { + addresses := []string{} + + return c.JSON(http.StatusOK, &addresses) +} diff --git a/main.go b/main.go index 774be15..306150e 100644 --- a/main.go +++ b/main.go @@ -108,9 +108,11 @@ func main() { LndClient: &lndClient, } + // Public endpoints for account creation and authentication e.POST("/auth", controllers.NewAuthController(svc).Auth) e.POST("/create", controllers.NewCreateUserController(svc).CreateUser) + // Secured endpoints which require a Authorization token (JWT) secured := e.Group("", tokens.Middleware(c.JWTSecret)) secured.POST("/addinvoice", controllers.NewAddInvoiceController(svc).AddInvoice) secured.POST("/payinvoice", controllers.NewPayInvoiceController(svc).PayInvoice) @@ -119,6 +121,11 @@ func main() { secured.GET("/balance", controllers.NewBalanceController(svc).Balance) secured.GET("/getinfo", controllers.NewGetInfoController(svc).GetInfo) + // These endpoints are not supported and we return a blank response for backwards compatibility + blankController := controllers.NewBlankController(svc) + secured.GET("/getbtc", blankController.GetBtc) + secured.GET("/getpending", blankController.GetPending) + // Start server go func() { if err := e.Start(":3000"); err != nil && err != http.ErrServerClosed {