validate a recipient
This commit is contained in:
parent
1964623daa
commit
cc6cfc8646
41
cmd/main.go
41
cmd/main.go
@ -24,8 +24,8 @@ const (
|
||||
USERFLAG_ACCOUNT_PENDING
|
||||
USERFLAG_ACCOUNT_SUCCESS
|
||||
USERFLAG_ACCOUNT_UNLOCKED
|
||||
invalidRecipient
|
||||
invalidRecipientWithInvite
|
||||
USERFLAG_INVALID_RECIPIENT
|
||||
USERFLAG_INVALID_RECIPIENT_WITH_INVITE
|
||||
)
|
||||
|
||||
const (
|
||||
@ -317,9 +317,6 @@ func (fsd *fsData) validate_recipient(ctx context.Context, sym string, input []b
|
||||
res := resource.Result{}
|
||||
recipient := string(input)
|
||||
|
||||
res.FlagReset = []uint32{invalidRecipient}
|
||||
res.FlagReset = []uint32{invalidRecipientWithInvite}
|
||||
|
||||
fp := fsd.path + "_data"
|
||||
|
||||
jsonData, err := os.ReadFile(fp)
|
||||
@ -333,24 +330,26 @@ func (fsd *fsData) validate_recipient(ctx context.Context, sym string, input []b
|
||||
return res, err
|
||||
}
|
||||
|
||||
// mimic invalid number check
|
||||
if recipient == "000" {
|
||||
res.FlagSet = []uint32{invalidRecipient}
|
||||
res.Content = recipient
|
||||
if recipient != "0" {
|
||||
// mimic invalid number check
|
||||
if recipient == "000" {
|
||||
res.FlagSet = append(res.FlagSet, USERFLAG_INVALID_RECIPIENT)
|
||||
res.Content = recipient
|
||||
|
||||
return res, nil
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
accountData["Recipient"] = recipient
|
||||
accountData["Recipient"] = recipient
|
||||
|
||||
updatedJsonData, err := json.Marshal(accountData)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
updatedJsonData, err := json.Marshal(accountData)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
err = os.WriteFile(fp, updatedJsonData, 0644)
|
||||
if err != nil {
|
||||
return res, err
|
||||
err = os.WriteFile(fp, updatedJsonData, 0644)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
|
||||
return res, nil
|
||||
@ -384,8 +383,8 @@ func (fsd *fsData) transaction_reset(ctx context.Context, sym string, input []by
|
||||
return res, err
|
||||
}
|
||||
|
||||
res.FlagReset = []uint32{invalidRecipient}
|
||||
res.FlagReset = []uint32{invalidRecipientWithInvite}
|
||||
res.FlagReset = append(res.FlagReset, USERFLAG_INVALID_RECIPIENT, USERFLAG_INVALID_RECIPIENT_WITH_INVITE)
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
LOAD max_amount 0
|
||||
RELOAD validate_recipient
|
||||
CATCH invalid_recipient 13 1
|
||||
LOAD max_amount 10
|
||||
MAP max_amount
|
||||
MOUT back 0
|
||||
HALT
|
||||
INCMP ^ 0
|
||||
LOAD validate_amount 0
|
||||
INCMP _ 0
|
||||
LOAD validate_amount 64
|
||||
LOAD get_recipient 12
|
||||
LOAD get_sender 64
|
||||
MOVE transaction_pin
|
||||
INCMP transaction_pin *
|
||||
|
@ -1,5 +1,5 @@
|
||||
MAP validate_recipient
|
||||
LOAD transaction_reset 0
|
||||
RELOAD transaction_reset
|
||||
MOUT retry 1
|
||||
MOUT quit 9
|
||||
HALT
|
||||
|
@ -1,7 +1,6 @@
|
||||
LOAD transaction_reset 0
|
||||
MOUT back 0
|
||||
HALT
|
||||
INCMP ^ 0
|
||||
LOAD validate_recipient 0
|
||||
MAP validate_recipient
|
||||
MOVE amount
|
||||
LOAD validate_recipient 20
|
||||
INCMP _ 0
|
||||
INCMP amount *
|
||||
|
@ -7,5 +7,5 @@ MAP get_sender
|
||||
MOUT back 0
|
||||
MOUT quit 9
|
||||
HALT
|
||||
INCMP ^ 0
|
||||
INCMP _ 0
|
||||
INCMP quit 9
|
||||
|
Loading…
Reference in New Issue
Block a user