verify currency

This commit is contained in:
MaysWind
2021-04-04 18:13:32 +08:00
parent c0206b943d
commit 5c59c64e0a
6 changed files with 50 additions and 22 deletions
+10
View File
@@ -141,6 +141,11 @@ func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] account cannot have any sub accounts")
return nil, errs.ErrAccountCannotHaveSubAccounts
}
if accountCreateReq.Currency == validators.ParentAccountCurrencyPlaceholder {
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] account cannot set currency placeholder")
return nil, errs.ErrAccountCurrencyInvalid
}
} else if accountCreateReq.Type == models.ACCOUNT_TYPE_MULTI_SUB_ACCOUNTS {
if len(accountCreateReq.SubAccounts) < 1 {
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] account does not have any sub accounts")
@@ -169,6 +174,11 @@ func (a *AccountsApi) AccountCreateHandler(c *core.Context) (interface{}, *errs.
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] sub account type invalid")
return nil, errs.ErrSubAccountTypeInvalid
}
if subAccount.Currency == validators.ParentAccountCurrencyPlaceholder {
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] sub account cannot set currency placeholder")
return nil, errs.ErrAccountCurrencyInvalid
}
}
} else {
log.WarnfWithRequestId(c, "[accounts.AccountCreateHandler] account type invalid, type is %d", accountCreateReq.Type)