From 2b10f6023f0efb91852d03568b6f4ced95a9835c Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Tue, 27 Aug 2024 16:10:43 +0300 Subject: [PATCH] Use the balance as the max_amount --- internal/handlers/ussd/menuhandler.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/handlers/ussd/menuhandler.go b/internal/handlers/ussd/menuhandler.go index df83592..de2e383 100644 --- a/internal/handlers/ussd/menuhandler.go +++ b/internal/handlers/ussd/menuhandler.go @@ -499,8 +499,17 @@ func (h *Handlers) ResetTransactionAmount(ctx context.Context, sym string, input func (h *Handlers) MaxAmount(ctx context.Context, sym string, input []byte) (resource.Result, error) { res := resource.Result{} - // mimic a max amount - res.Content = "10.00" + accountData, err := h.accountFileHandler.ReadAccountData() + if err != nil { + return res, err + } + + balance, err := server.CheckBalance(accountData["PublicKey"]) + if err != nil { + return res, nil + } + + res.Content = balance return res, nil }