validate a recipient

This commit is contained in:
Alfred Kamanda 2024-08-21 20:30:59 +03:00
parent 1964623daa
commit cc6cfc8646
Signed by: Alfred-mk
GPG Key ID: 7EA3D01708908703
5 changed files with 31 additions and 31 deletions

View File

@ -24,8 +24,8 @@ const (
USERFLAG_ACCOUNT_PENDING USERFLAG_ACCOUNT_PENDING
USERFLAG_ACCOUNT_SUCCESS USERFLAG_ACCOUNT_SUCCESS
USERFLAG_ACCOUNT_UNLOCKED USERFLAG_ACCOUNT_UNLOCKED
invalidRecipient USERFLAG_INVALID_RECIPIENT
invalidRecipientWithInvite USERFLAG_INVALID_RECIPIENT_WITH_INVITE
) )
const ( const (
@ -317,9 +317,6 @@ func (fsd *fsData) validate_recipient(ctx context.Context, sym string, input []b
res := resource.Result{} res := resource.Result{}
recipient := string(input) recipient := string(input)
res.FlagReset = []uint32{invalidRecipient}
res.FlagReset = []uint32{invalidRecipientWithInvite}
fp := fsd.path + "_data" fp := fsd.path + "_data"
jsonData, err := os.ReadFile(fp) jsonData, err := os.ReadFile(fp)
@ -333,9 +330,10 @@ func (fsd *fsData) validate_recipient(ctx context.Context, sym string, input []b
return res, err return res, err
} }
if recipient != "0" {
// mimic invalid number check // mimic invalid number check
if recipient == "000" { if recipient == "000" {
res.FlagSet = []uint32{invalidRecipient} res.FlagSet = append(res.FlagSet, USERFLAG_INVALID_RECIPIENT)
res.Content = recipient res.Content = recipient
return res, nil return res, nil
@ -352,6 +350,7 @@ func (fsd *fsData) validate_recipient(ctx context.Context, sym string, input []b
if err != nil { if err != nil {
return res, err return res, err
} }
}
return res, nil return res, nil
} }
@ -384,8 +383,8 @@ func (fsd *fsData) transaction_reset(ctx context.Context, sym string, input []by
return res, err return res, err
} }
res.FlagReset = []uint32{invalidRecipient} res.FlagReset = append(res.FlagReset, USERFLAG_INVALID_RECIPIENT, USERFLAG_INVALID_RECIPIENT_WITH_INVITE)
res.FlagReset = []uint32{invalidRecipientWithInvite}
return res, nil return res, nil
} }

View File

@ -1,9 +1,11 @@
LOAD max_amount 0 RELOAD validate_recipient
CATCH invalid_recipient 13 1
LOAD max_amount 10
MAP max_amount MAP max_amount
MOUT back 0 MOUT back 0
HALT HALT
INCMP ^ 0 INCMP _ 0
LOAD validate_amount 0 LOAD validate_amount 64
LOAD get_recipient 12 LOAD get_recipient 12
LOAD get_sender 64 LOAD get_sender 64
MOVE transaction_pin INCMP transaction_pin *

View File

@ -1,5 +1,5 @@
MAP validate_recipient MAP validate_recipient
LOAD transaction_reset 0 RELOAD transaction_reset
MOUT retry 1 MOUT retry 1
MOUT quit 9 MOUT quit 9
HALT HALT

View File

@ -1,7 +1,6 @@
LOAD transaction_reset 0 LOAD transaction_reset 0
MOUT back 0 MOUT back 0
HALT HALT
INCMP ^ 0 LOAD validate_recipient 20
LOAD validate_recipient 0 INCMP _ 0
MAP validate_recipient INCMP amount *
MOVE amount

View File

@ -7,5 +7,5 @@ MAP get_sender
MOUT back 0 MOUT back 0
MOUT quit 9 MOUT quit 9
HALT HALT
INCMP ^ 0 INCMP _ 0
INCMP quit 9 INCMP quit 9