Quit with the transaction confirmation

This commit is contained in:
Alfred Kamanda 2024-08-28 14:54:39 +03:00
parent 3501a79aea
commit 768535b540
Signed by: Alfred-mk
GPG Key ID: 7EA3D01708908703
4 changed files with 21 additions and 5 deletions

View File

@ -706,9 +706,30 @@ func (h *Handlers) QuitWithBalance(ctx context.Context, sym string, input []byte
func (h *Handlers) InitiateTransaction(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{}
accountData, err := h.accountFileHandler.ReadAccountData()
if err != nil {
return res, err
}
// TODO
// Use the amount, recipient and sender to call the API and initialize the transaction
switch codeFromCtx(ctx) {
case "swa":
res.Content = fmt.Sprintf("Ombi lako limetumwa. %s atapokea %s kutoka kwa %s.", accountData["Recipient"], accountData["Amount"], accountData["PublicKey"])
default:
res.Content = fmt.Sprintf("Your request has been sent. %s will receive %s from %s.", accountData["Recipient"], accountData["Amount"], accountData["PublicKey"])
}
// reset the transaction
accountData["Recipient"] = ""
accountData["Amount"] = ""
err = h.accountFileHandler.WriteAccountData(accountData)
if err != nil {
return res, err
}
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_UNLOCKED)
return res, nil
}

View File

@ -1 +0,0 @@
Your request has been sent. {{.get_recipient}} will receive {{.get_amount}} from {{.get_sender}}.

View File

@ -6,7 +6,4 @@ MAP get_recipient
RELOAD get_sender
MAP get_sender
LOAD initiate_transaction 0
RELOAD transaction_reset
MOUT quit 9
HALT
INCMP quit 9

View File

@ -1 +0,0 @@
Ombi lako limetumwa. {{.get_recipient}} atapokea {{.get_amount}} kutoka kwa {{.get_sender}}.