diff --git a/controllers/addinvoice.ctrl.go b/controllers/addinvoice.ctrl.go index d191ab2d..52017aa1 100644 --- a/controllers/addinvoice.ctrl.go +++ b/controllers/addinvoice.ctrl.go @@ -61,7 +61,7 @@ func AddInvoice(c echo.Context, svc *service.LndhubService, userID int64) error } amount, err := svc.ParseInt(body.Amount) - if err != nil { + if err != nil || amount < 0 { return c.JSON(http.StatusBadRequest, responses.BadArgumentsError) } c.Logger().Infof("Adding invoice: user_id:%v memo:%s value:%v description_hash:%s", userID, body.Memo, amount, body.DescriptionHash) diff --git a/controllers/keysend.ctrl.go b/controllers/keysend.ctrl.go index 3d3e85f6..f0d80fa4 100644 --- a/controllers/keysend.ctrl.go +++ b/controllers/keysend.ctrl.go @@ -24,7 +24,7 @@ func NewKeySendController(svc *service.LndhubService) *KeySendController { } type KeySendRequestBody struct { - Amount int64 `json:"amount" validate:"required"` + Amount int64 `json:"amount" validate:"required,gt=0"` Destination string `json:"destination" validate:"required"` Memo string `json:"memo" validate:"omitempty"` CustomRecords map[string]string `json:"customRecords" validate:"omitempty"`