dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 2ebd3b9aab966440c292925b3c3f2d2d7c5bdcfb
parent b15d8918bf301e0c4bba7925997946dad3d0d7d1
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed, 13 Dec 2023 22:50:26 -0500

check new balance

Diffstat:
Mpkg/web/handlers/handlers.go | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -832,6 +832,13 @@ func PokerHomeHandler(c echo.Context) error { tx := db.Begin() err = tx.DB().Exec(`UPDATE users SET xmr_balance_stagenet = xmr_balance_stagenet - ? WHERE id = ?`, withdrawAmount+houseFee+transactionFee, authUser.ID).Error + var tmp struct{ XmrBalanceStagenet uint64 } + tx.DB().Debug().Table("users").Select("xmr_balance_stagenet").First(&tmp, "id = ?", authUser.ID) + if tmp.XmrBalanceStagenet < 0 { + data.Error = "negative balance" + tx.Rollback() + return c.Render(http.StatusOK, "poker", data) + } if _, err := config.Xmr().RelayTx(&wallet1.RequestRelayTx{Hex: res.TxMetadata}); err != nil { logrus.Error(err) data.Error = err.Error()