From 1a7d160ae66d80b33eed9f296adf4019a21336b0 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Tue, 3 Mar 2026 10:01:50 +0300 Subject: [PATCH 1/2] return a normal transaction if the recipient isn't registered on the USSD --- handlers/application/send.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/handlers/application/send.go b/handlers/application/send.go index 2213296..6c5344d 100644 --- a/handlers/application/send.go +++ b/handlers/application/send.go @@ -373,13 +373,6 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte) // Format the active balance amount to 2 decimal places formattedBalance, _ := store.TruncateDecimalString(string(activeBal), 2) - // confirm the transaction type - swapToVoucher, err := store.ReadSwapToVoucher(ctx, h.userdataStore, sessionId) - if err != nil { - logg.ErrorCtxf(ctx, "failed on ReadSwapFromVoucher", "error", err) - return res, err - } - // Case for M-Pesa // if the recipient is Mpesa (address), check if the sender's voucher is a stable coin recipientAddress, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_RECIPIENT) @@ -393,6 +386,16 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte) return res, nil } + // confirm the transaction type + swapToVoucher, err := store.ReadSwapToVoucher(ctx, h.userdataStore, sessionId) + if err != nil { + logg.ErrorCtxf(ctx, "failed on ReadSwapFromVoucher", "error", err) + // switch to normal transaction as the recipient isn't registered (pool or alias only on sarafu) + res.FlagReset = append(res.FlagReset, flag_swap_transaction) + res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym)) + return res, nil + } + if string(swapToVoucher.TokenAddress) == string(activeAddress) { // recipient has active token same as selected token → normal transaction transactionType = []byte("normal") -- 2.45.2 From 5b995c9d9c1814a8b1ad4a14774d32e8e7b0312f Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Tue, 3 Mar 2026 11:48:59 +0300 Subject: [PATCH 2/2] log the error for new user cases and return nil --- handlers/application/send.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/handlers/application/send.go b/handlers/application/send.go index 6c5344d..37238d8 100644 --- a/handlers/application/send.go +++ b/handlers/application/send.go @@ -242,7 +242,9 @@ func (h *MenuHandlers) determineAndSaveTransactionType( // fetch data for use (to_voucher data) recipientActiveSym, recipientActiveAddress, recipientActiveDecimal, err := h.getRecipientData(ctx, string(recipientPhoneNumber)) if err != nil { - return err + // missing key (case for new users) + logg.ErrorCtxf(ctx, "failed on getRecipientData", "error", err) + return nil } swapMetadata := &dataserviceapi.TokenHoldings{ TokenAddress: string(recipientActiveAddress), -- 2.45.2