From 65badc4ccceba08cc58c24b278259619cc2cd0f1 Mon Sep 17 00:00:00 2001 From: Alfred Kamanda Date: Tue, 13 Jan 2026 11:09:13 +0300 Subject: [PATCH 1/9] ignore the generated vise-asm file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 69e9a58..aee3707 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ id_* *.gdbm *.log user-data +**/*/vise-asm From a447f230ca4b3059d571e290a7bc96479c2e3389 Mon Sep 17 00:00:00 2001 From: Alfred Kamanda Date: Tue, 13 Jan 2026 12:45:27 +0300 Subject: [PATCH 2/9] refactor the code to handle credit send or normal transactions --- handlers/application/send.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/handlers/application/send.go b/handlers/application/send.go index 538f977..08e83c5 100644 --- a/handlers/application/send.go +++ b/handlers/application/send.go @@ -258,6 +258,7 @@ func (h *MenuHandlers) TransactionReset(ctx context.Context, sym string, input [ flag_invalid_recipient, _ := h.flagManager.GetFlag("flag_invalid_recipient") flag_invalid_recipient_with_invite, _ := h.flagManager.GetFlag("flag_invalid_recipient_with_invite") + store := h.userdataStore err = store.WriteEntry(ctx, sessionId, storedb.DATA_AMOUNT, []byte("")) if err != nil { @@ -336,28 +337,15 @@ 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) - // If normal transaction, or if the sym is send_max_amount, return balance - if string(transactionType) == "normal" || sym == "send_max_amount" { + // If normal transaction return balance + if string(transactionType) == "normal" { res.FlagReset = append(res.FlagReset, flag_swap_transaction) - res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym)) - return res, nil } res.FlagSet = append(res.FlagSet, flag_swap_transaction) - // Get the recipient's phone number to read other data items - recipientPhoneNumber, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_RECIPIENT_PHONE_NUMBER) - if err != nil { - // invalid state - return res, err - } - recipientActiveSym, recipientActiveAddress, recipientActiveDecimal, err := h.getRecipientData(ctx, string(recipientPhoneNumber)) - if err != nil { - return res, err - } - // Resolve active pool address activePoolAddress, err := h.resolveActivePoolAddress(ctx, sessionId) if err != nil { @@ -372,11 +360,23 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte) logg.ErrorCtxf(ctx, "failed on CheckTokenInPool", "error", err) return res, nil } + res.FlagReset = append(res.FlagReset, flag_swap_transaction) res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym)) return res, nil } + // Get the recipient's phone number to read other data items + recipientPhoneNumber, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_RECIPIENT_PHONE_NUMBER) + if err != nil { + // invalid state + return res, err + } + recipientActiveSym, recipientActiveAddress, recipientActiveDecimal, err := h.getRecipientData(ctx, string(recipientPhoneNumber)) + if err != nil { + return res, err + } + // retrieve the max credit send amounts maxSAT, maxRAT, err := h.calculateSendCreditLimits(ctx, activePoolAddress, activeAddress, recipientActiveAddress, publicKey, activeDecimal, recipientActiveDecimal) if err != nil { From a56f94896d06450e7f498178289e7d3d99723eff Mon Sep 17 00:00:00 2001 From: Alfred Kamanda Date: Tue, 13 Jan 2026 12:46:13 +0300 Subject: [PATCH 3/9] add a RELOAD for the reset_transaction_amount --- services/registration/credit_amount.vis | 1 + 1 file changed, 1 insertion(+) diff --git a/services/registration/credit_amount.vis b/services/registration/credit_amount.vis index f0f716f..cb9854a 100644 --- a/services/registration/credit_amount.vis +++ b/services/registration/credit_amount.vis @@ -1,4 +1,5 @@ LOAD reset_transaction_amount 10 +RELOAD reset_transaction_amount LOAD credit_max_amount 160 RELOAD credit_max_amount CATCH api_failure flag_api_call_error 1 From 4edcdfa9876079aa2df0101d9f30703127c919c1 Mon Sep 17 00:00:00 2001 From: Alfred Kamanda Date: Tue, 13 Jan 2026 12:46:34 +0300 Subject: [PATCH 4/9] change the order to only have Send --- services/registration/main.vis | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/services/registration/main.vis b/services/registration/main.vis index b585d2f..f210214 100644 --- a/services/registration/main.vis +++ b/services/registration/main.vis @@ -7,22 +7,20 @@ LOAD check_balance 128 RELOAD check_balance MAP check_balance MOUT send 1 -MOUT credit_send 2 -MOUT swap 3 -MOUT vouchers 4 -MOUT select_pool 5 -MOUT mpesa 6 -MOUT account 7 -MOUT help 8 +MOUT swap 2 +MOUT vouchers 3 +MOUT select_pool 4 +MOUT mpesa 5 +MOUT account 6 +MOUT help 7 MOUT quit 9 HALT -INCMP send 1 -INCMP credit_send 2 -INCMP swap_to_list 3 -INCMP my_vouchers 4 -INCMP select_pool 5 -INCMP mpesa 6 -INCMP my_account 7 -INCMP help 8 +INCMP credit_send 1 +INCMP swap_to_list 2 +INCMP my_vouchers 3 +INCMP select_pool 4 +INCMP mpesa 5 +INCMP my_account 6 +INCMP help 7 INCMP quit 9 INCMP . * From 40292ebcdda617024796bcbeec9ff7cc01e1b3b2 Mon Sep 17 00:00:00 2001 From: Alfred Kamanda Date: Tue, 13 Jan 2026 12:52:10 +0300 Subject: [PATCH 5/9] removed unused send node specific files --- services/registration/credit_send_menu | 1 - services/registration/credit_send_menu_swa | 1 - services/registration/send | 1 - services/registration/send.vis | 12 ------------ services/registration/send_swa | 1 - 5 files changed, 16 deletions(-) delete mode 100644 services/registration/credit_send_menu delete mode 100644 services/registration/credit_send_menu_swa delete mode 100644 services/registration/send delete mode 100644 services/registration/send.vis delete mode 100644 services/registration/send_swa diff --git a/services/registration/credit_send_menu b/services/registration/credit_send_menu deleted file mode 100644 index 4362df7..0000000 --- a/services/registration/credit_send_menu +++ /dev/null @@ -1 +0,0 @@ -Credit-Send \ No newline at end of file diff --git a/services/registration/credit_send_menu_swa b/services/registration/credit_send_menu_swa deleted file mode 100644 index 2d8f3c2..0000000 --- a/services/registration/credit_send_menu_swa +++ /dev/null @@ -1 +0,0 @@ -Tuma-Mkopo \ No newline at end of file diff --git a/services/registration/send b/services/registration/send deleted file mode 100644 index 306466c..0000000 --- a/services/registration/send +++ /dev/null @@ -1 +0,0 @@ -Enter recipient's phone number/address/alias: \ No newline at end of file diff --git a/services/registration/send.vis b/services/registration/send.vis deleted file mode 100644 index dfdcd70..0000000 --- a/services/registration/send.vis +++ /dev/null @@ -1,12 +0,0 @@ -LOAD transaction_reset 0 -RELOAD transaction_reset -CATCH no_voucher flag_no_active_voucher 1 -MOUT back 0 -HALT -LOAD validate_recipient 50 -RELOAD validate_recipient -CATCH api_failure flag_api_call_error 1 -CATCH invalid_recipient flag_invalid_recipient 1 -CATCH invite_recipient flag_invalid_recipient_with_invite 1 -INCMP _ 0 -INCMP amount * diff --git a/services/registration/send_swa b/services/registration/send_swa deleted file mode 100644 index 5deea97..0000000 --- a/services/registration/send_swa +++ /dev/null @@ -1 +0,0 @@ -Weka nambari ya simu/Anwani/Lakabu: \ No newline at end of file From 7d8fd065f0276c4f14d2a5a55c7517c830ca55c6 Mon Sep 17 00:00:00 2001 From: Alfred Kamanda Date: Thu, 15 Jan 2026 10:56:20 +0300 Subject: [PATCH 6/9] default to a normal send if an error occurs on calculateSendCreditLimits --- 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 08e83c5..53aa36a 100644 --- a/handlers/application/send.go +++ b/handlers/application/send.go @@ -380,8 +380,10 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte) // retrieve the max credit send amounts maxSAT, maxRAT, err := h.calculateSendCreditLimits(ctx, activePoolAddress, activeAddress, recipientActiveAddress, publicKey, activeDecimal, recipientActiveDecimal) if err != nil { - res.FlagSet = append(res.FlagSet, flag_api_call_error) + // if an error (such as Swap rates not found for the speficied pool and tokens), fall back to a normal transaction logg.ErrorCtxf(ctx, "failed on calculateSendCreditLimits", "error", err) + res.FlagReset = append(res.FlagReset, flag_swap_transaction) + res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym)) return res, nil } From c380915100dd169525c0f28284b49481aeb9e04a Mon Sep 17 00:00:00 2001 From: Alfred Kamanda Date: Thu, 15 Jan 2026 10:56:52 +0300 Subject: [PATCH 7/9] remove misplaced CATCH on the api_error flag --- services/registration/credit_amount.vis | 1 - 1 file changed, 1 deletion(-) diff --git a/services/registration/credit_amount.vis b/services/registration/credit_amount.vis index cb9854a..1e402b3 100644 --- a/services/registration/credit_amount.vis +++ b/services/registration/credit_amount.vis @@ -11,7 +11,6 @@ RELOAD clear_trans_type_flag CATCH transaction_swap flag_swap_transaction 1 LOAD validate_amount 64 RELOAD validate_amount -CATCH api_failure flag_api_call_error 1 CATCH invalid_amount flag_invalid_amount 1 INCMP _ 0 LOAD get_recipient 0 From b337c9260be3ffa229f8e89920802a057b8209db Mon Sep 17 00:00:00 2001 From: Alfred Kamanda Date: Thu, 15 Jan 2026 11:17:41 +0300 Subject: [PATCH 8/9] add a debug statement --- handlers/application/send.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/handlers/application/send.go b/handlers/application/send.go index 53aa36a..7b09eea 100644 --- a/handlers/application/send.go +++ b/handlers/application/send.go @@ -384,6 +384,8 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte) logg.ErrorCtxf(ctx, "failed on calculateSendCreditLimits", "error", err) res.FlagReset = append(res.FlagReset, flag_swap_transaction) res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym)) + + fmt.Println("the FlagReset:", res.FlagReset, "the FlagSet:", res.FlagSet) return res, nil } From 523f6802762bcc7edb1aa15429a225a6eb3eddc1 Mon Sep 17 00:00:00 2001 From: Alfred Kamanda Date: Thu, 15 Jan 2026 11:25:02 +0300 Subject: [PATCH 9/9] append the flag_swap_transaction once all checks pass --- handlers/application/send.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/handlers/application/send.go b/handlers/application/send.go index 7b09eea..bbcea64 100644 --- a/handlers/application/send.go +++ b/handlers/application/send.go @@ -344,8 +344,6 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte) return res, nil } - res.FlagSet = append(res.FlagSet, flag_swap_transaction) - // Resolve active pool address activePoolAddress, err := h.resolveActivePoolAddress(ctx, sessionId) if err != nil { @@ -385,7 +383,6 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte) res.FlagReset = append(res.FlagReset, flag_swap_transaction) res.Content = l.Get("Maximum amount: %s %s\nEnter amount:", formattedBalance, string(activeSym)) - fmt.Println("the FlagReset:", res.FlagReset, "the FlagSet:", res.FlagSet) return res, nil } @@ -417,6 +414,9 @@ func (h *MenuHandlers) MaxAmount(ctx context.Context, sym string, input []byte) return res, err } + // only set the flag once all checks pass + res.FlagSet = append(res.FlagSet, flag_swap_transaction) + res.Content = l.Get( "Credit Available: %s %s\n(You can swap up to %s %s -> %s %s).\nEnter %s amount:", maxRAT,