From 65fe75d7cefa189f902adeb3268001dc2173888a Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Wed, 19 Jan 2022 17:56:33 +0100 Subject: [PATCH] Introduce a Blank controller for unsported endpoints --- controllers/blank.ctrl.go | 31 +++++++++++++++++++++++++++++++ controllers/getbtc.ctrl.go | 24 ------------------------ main.go | 4 +++- 3 files changed, 34 insertions(+), 25 deletions(-) create mode 100644 controllers/blank.ctrl.go delete mode 100644 controllers/getbtc.ctrl.go 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/controllers/getbtc.ctrl.go b/controllers/getbtc.ctrl.go deleted file mode 100644 index ffa901d..0000000 --- a/controllers/getbtc.ctrl.go +++ /dev/null @@ -1,24 +0,0 @@ -package controllers - -import ( - "net/http" - - "github.com/getAlby/lndhub.go/lib/service" - "github.com/labstack/echo/v4" -) - -// GetBtcController : GetBtcController struct -type GetBtcController struct{} - -func NewGetBtcController(svc *service.LndhubService) *GetBtcController { - return &GetBtcController{} -} - -// GetBtc : Get Btc handler -// -// We do NOT support onchain transactions thus we only return an empty array for backwards compatibility -func (controller *GetBtcController) GetBtc(c echo.Context) error { - addresses := []string{} - - return c.JSON(http.StatusOK, &addresses) -} diff --git a/main.go b/main.go index 9140e6f..1d6f2ba 100644 --- a/main.go +++ b/main.go @@ -118,7 +118,9 @@ func main() { secured.GET("/checkpayment/:payment_hash", controllers.NewCheckPaymentController(svc).CheckPayment) secured.GET("/balance", controllers.NewBalanceController(svc).Balance) - secured.GET("/getbtc", controllers.NewGetBtcController(svc).GetBtc) + blankController := controllers.NewBlankController(svc) + secured.GET("/getbtc", blankController.GetBtc) + secured.GET("/getpending", blankController.GetPending) // Start server go func() {