refactor balance check

This commit is contained in:
kiwiidb
2023-09-25 10:04:34 +02:00
parent 501fc7bde0
commit afbbca8b45
6 changed files with 22 additions and 11 deletions

View File

@@ -97,7 +97,7 @@ func (controller *PayInvoiceController) PayInvoice(c echo.Context) error {
}
}
ok, err := controller.svc.BalanceCheck(c.Request().Context(), lnPayReq, userID)
resp, err := controller.svc.CheckPaymentAllowed(c.Request().Context(), lnPayReq, userID)
if err != nil {
c.Logger().Errorj(
log.JSON{
@@ -108,7 +108,7 @@ func (controller *PayInvoiceController) PayInvoice(c echo.Context) error {
)
return c.JSON(http.StatusBadRequest, responses.GeneralServerError)
}
if !ok {
if resp != nil {
c.Logger().Errorf("User does not have enough balance user_id:%v amount:%v", userID, lnPayReq.PayReq.NumSatoshis)
return c.JSON(http.StatusBadRequest, responses.NotEnoughBalanceError)
}