當前位置: 首頁>>代碼示例>>Golang>>正文


Golang utils.CheckInputData函數代碼示例

本文整理匯總了Golang中github.com/c-darwin/dcoin-go/packages/utils.CheckInputData函數的典型用法代碼示例。如果您正苦於以下問題:Golang CheckInputData函數的具體用法?Golang CheckInputData怎麽用?Golang CheckInputData使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CheckInputData函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ChangePrimaryKeyFront

func (p *Parser) ChangePrimaryKeyFront() error {

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	if !utils.CheckInputData(p.newPublicKeysHex[0], "public_key") {
		return p.ErrInfo("public_key")
	}
	if len(p.newPublicKeysHex[1]) > 0 && !utils.CheckInputData(p.newPublicKeysHex[1], "public_key") {
		return p.ErrInfo("public_key 1")
	}
	if len(p.newPublicKeysHex[2]) > 0 && !utils.CheckInputData(p.newPublicKeysHex[2], "public_key") {
		return p.ErrInfo("public_key 2")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.newPublicKeysHex[0], p.newPublicKeysHex[1], p.newPublicKeysHex[2])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	err = p.limitRequest(p.Variables.Int64["limit_primary_key"], "primary_key", p.Variables.Int64["limit_primary_key_period"])
	if err != nil {
		return p.ErrInfo(err)
	}
	return nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:32,代碼來源:change_primary_key.go

示例2: ChangeCaFront

func (p *Parser) ChangeCaFront() error {

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	if !utils.CheckInputData(p.TxMaps.String["ca1"], "ca_url") && p.TxMaps.String["ca1"] != "0" {
		return fmt.Errorf("incorrect ca1")
	}
	if !utils.CheckInputData(p.TxMaps.String["ca2"], "ca_url") && p.TxMaps.String["ca2"] != "0" {
		return fmt.Errorf("incorrect ca2")
	}
	if !utils.CheckInputData(p.TxMaps.String["ca3"], "ca_url") && p.TxMaps.String["ca3"] != "0" {
		return fmt.Errorf("incorrect ca3")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["ca1"], p.TxMap["ca2"], p.TxMap["ca3"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	err = p.limitRequest(consts.LIMIT_CHANGE_CA, "change_ca", consts.LIMIT_CHANGE_CA_PERIOD)
	if err != nil {
		return p.ErrInfo(err)
	}
	return nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:32,代碼來源:change_ca.go

示例3: SaveHost

func (c *Controller) SaveHost() (string, error) {

	if c.SessRestricted != 0 {
		return "", utils.ErrInfo(errors.New("Permission denied"))
	}

	c.r.ParseForm()
	http_host := c.r.FormValue("http_host")
	if len(http_host) > 0 && http_host[len(http_host)-1:] != "/" {
		http_host += "/"
	}
	tcp_host := c.r.FormValue("tcp_host")

	if !utils.CheckInputData(http_host, "http_host") {
		return `{"error":"1"}`, nil
	}
	if !utils.CheckInputData(tcp_host, "tcp_host") {
		return `{"error":"1"}`, nil
	}

	err := c.ExecSql("UPDATE "+c.MyPrefix+"my_table SET http_host = ?, tcp_host = ?", http_host, tcp_host)
	if err != nil {
		return "", utils.ErrInfo(err)
	}

	return `{"error":"0"}`, nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:27,代碼來源:save_host.go

示例4: VotesNodeNewMinerFront

func (p *Parser) VotesNodeNewMinerFront() error {
	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}
	// является ли данный юзер майнером
	err = p.checkMiner(p.TxUserID)
	if err != nil {
		return err
	}

	if !utils.CheckInputData(p.TxMap["result"], "vote") {
		return utils.ErrInfoFmt("incorrect vote")
	}
	// получим public_key
	p.nodePublicKey, err = p.GetNodePublicKey(p.TxUserID)
	if len(p.nodePublicKey) == 0 {
		return utils.ErrInfoFmt("incorrect user_id len(nodePublicKey) = 0")
	}

	if !utils.CheckInputData(p.TxMap["vote_id"], "bigint") {
		return utils.ErrInfoFmt("incorrect bigint")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["vote_id"], p.TxMap["result"])
	CheckSignResult, err := utils.CheckSign([][]byte{p.nodePublicKey}, forSign, p.TxMap["sign"], true)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return utils.ErrInfoFmt("incorrect sign")
	}

	// проверим, верно ли указан ID и не закончилось ли голосование
	id, err := p.Single("SELECT id FROM votes_miners WHERE id = ? AND type = 'node_voting' AND votes_end = 0", p.TxMaps.Int64["vote_id"]).Int64()
	if err != nil {
		return p.ErrInfo(err)
	}
	if id == 0 {
		return p.ErrInfo(fmt.Errorf("voting is over"))
	}

	// проверим, не повторное ли это голосование данного юзера
	num, err := p.Single("SELECT count(user_id) FROM log_votes WHERE user_id = ? AND voting_id = ? AND type = 'votes_miners'", p.TxMaps.Int64["user_id"], p.TxMaps.Int64["vote_id"]).Int64()
	if err != nil {
		return p.ErrInfo(err)
	}
	if num > 0 {
		return utils.ErrInfoFmt("double voting")
	}

	// нод не должен голосовать более X раз за сутки, чтобы не было доса
	err = p.limitRequest(p.Variables.Int64["node_voting"], "votes_nodes", p.Variables.Int64["node_voting_period"])
	if err != nil {
		return p.ErrInfo(err)
	}

	return nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:59,代碼來源:votes_node_new_miner.go

示例5: VotesMinerFront

func (p *Parser) VotesMinerFront() error {
	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	if !utils.CheckInputData(p.TxMap["vote_id"], "bigint") {
		return p.ErrInfo("incorrect vote_id")
	}
	if !utils.CheckInputData(p.TxMap["result"], "vote") {
		return p.ErrInfo("incorrect vote_id")
	}
	if !utils.CheckInputData(p.TxMap["comment"], "votes_comment") {
		return p.ErrInfo("incorrect comment")
	}

	// является ли данный юзер майнером
	err = p.checkMiner(p.TxUserID)
	if err != nil {
		return p.ErrInfo(err)
	}

	// проверим, верно ли указан ID и не закончилось ли голосование
	id, err := p.Single("SELECT id FROM votes_miners WHERE id = ? AND type = 'user_voting' AND votes_end = 0", p.TxMaps.Int64["vote_id"]).Int()
	if err != nil {
		return p.ErrInfo(err)
	}
	if id == 0 {
		return p.ErrInfo("voting is over")
	}

	// проверим, не повторное ли это голосование данного юзера
	num, err := p.Single("SELECT count(user_id) FROM log_votes WHERE user_id = ? AND voting_id = ? AND type = 'votes_miners'", p.TxMaps.Int64["user_id"], p.TxMaps.Int64["vote_id"]).Int()
	if err != nil {
		return p.ErrInfo("double voting")
	}
	if num > 0 {
		return p.ErrInfo("double voting")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["vote_id"], p.TxMap["result"], p.TxMap["comment"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	// защита от доса
	err = p.maxDayVotes()
	if err != nil {
		return p.ErrInfo(err)
	}

	return nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:57,代碼來源:votes_miner.go

示例6: RewritePrimaryKeySave

func (c *Controller) RewritePrimaryKeySave() (string, error) {

	if !c.NodeAdmin || c.SessRestricted != 0 {
		return "", utils.ErrInfo(errors.New("Permission denied"))
	}

	if len(c.r.FormValue("n")) > 0 {

		c.r.ParseForm()
		n := []byte(c.r.FormValue("n"))
		e := []byte(c.r.FormValue("e"))
		if !utils.CheckInputData(n, "hex") {
			return "", utils.ErrInfo(errors.New("incorrect n"))
		}
		if !utils.CheckInputData(e, "hex") {
			return "", utils.ErrInfo(errors.New("incorrect e"))
		}
		publicKey := utils.MakeAsn1(n, e)

		// проверим, есть ли вообще такой публичный ключ
		userId, err := c.Single("SELECT user_id FROM users WHERE hex(public_key_0) = ?", publicKey).Int64()
		if err != nil {
			return "", utils.ErrInfo(err)
		}
		if userId == 0 {
			return "", utils.ErrInfo(errors.New("incorrect public_key"))
		}

		// может быть юзер уже майнер?
		minerId, err := c.GetMinerId(userId)
		if err != nil {
			return "", utils.ErrInfo(err)
		}
		status := ""
		if minerId > 0 {
			status = "miner"
		} else {
			status = "user"
		}

		err = c.ExecSql(`DELETE FROM my_keys`)
		if err != nil {
			return "", utils.ErrInfo(err)
		}

		err = c.ExecSql(`INSERT INTO `+c.MyPrefix+`my_keys (public_key, status) VALUES ([hex], ?)`, publicKey, "approved")
		if err != nil {
			return "", utils.ErrInfo(err)
		}

		err = c.ExecSql(`UPDATE `+c.MyPrefix+`my_table SET user_id = ?, miner_id = ?, status = ?`, userId, minerId, status)
		if err != nil {
			return "", utils.ErrInfo(err)
		}
	}
	return `{"success":"success"}`, nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:57,代碼來源:rewrite_primary_key_save.go

示例7: EWithdraw

func (c *Controller) EWithdraw() (string, error) {

	if c.SessUserId == 0 {
		return "", errors.New(c.Lang["sign_up_please"])
	}

	c.r.ParseForm()
	currencyId := utils.StrToInt64(c.r.FormValue("currency_id"))
	if !utils.CheckInputData(c.r.FormValue("amount"), "amount") {
		return "", fmt.Errorf("incorrect amount")
	}
	method := c.r.FormValue("method")
	if !utils.CheckInputData(method, "method") {
		return "", fmt.Errorf("incorrect method")
	}
	account := c.r.FormValue("account")
	if !utils.CheckInputData(account, "account") {
		return "", fmt.Errorf("incorrect account")
	}
	amount := utils.StrToFloat64(c.r.FormValue("amount"))

	curTime := utils.Time()

	// нужно проверить, есть ли нужная сумма на счету юзера
	userAmount := utils.EUserAmountAndProfit(c.SessUserId, currencyId)
	if userAmount < amount {
		return "", fmt.Errorf("%s (%f<%f)", c.Lang["not_enough_money"], userAmount, amount)
	}
	if method != "Dcoin" && currencyId < 1000 {
		return "", fmt.Errorf("incorrect method")
	}

	err := userLock(c.SessUserId)
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	err = c.ExecSql(`UPDATE e_wallets SET amount = ?, last_update = ? WHERE user_id = ? AND currency_id = ?`, userAmount-amount, curTime, c.SessUserId, currencyId)
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	var commission float64
	if method == "Dcoin" {
		commission = utils.StrToFloat64(c.EConfig["dc_commission"])
	} else if method == "Perfect-money" {
		commission = utils.StrToFloat64(c.EConfig["pm_commission"])
	}
	wdAmount := utils.ClearNull(utils.Float64ToStr(amount*(1-commission/100)), 2)

	err = c.ExecSql(`INSERT INTO e_withdraw (open_time, user_id, currency_id, account, amount, wd_amount, method) VALUES (?, ?, ?, ?, ?, ?, ?)`, curTime, c.SessUserId, currencyId, account, amount, wdAmount, method)
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	userUnlock(c.SessUserId)

	return utils.JsonAnswer(c.Lang["request_is_created"], "success").String(), nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:56,代碼來源:e_withdraw.go

示例8: EPages

func (c *Controller) EPages() (string, error) {

	var err error

	var title, text string
	if len(c.Parameters["page"]) > 0 {
		if !utils.CheckInputData(c.Parameters["page"], "string") {
			return "", utils.ErrInfo(err)
		}
		data, err := c.OneRow(`SELECT title, text from e_pages WHERE name = ? AND lang = ?`, c.Parameters["page"], c.LangInt).String()
		if err != nil {
			return "", utils.ErrInfo(err)
		}
		title = data["title"]
		text = data["text"]
	}

	TemplateStr, err := makeTemplate("e_pages", "ePages", &ePages{
		Lang:  c.Lang,
		Title: title,
		Text:  text})
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	return TemplateStr, nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:26,代碼來源:e_pages.go

示例9: ERedirect

func (c *Controller) ERedirect() (string, error) {

	c.r.ParseForm()
	token := c.r.FormValue("FormToken")
	amount := c.r.FormValue("FormExAmount")
	buyCurrencyId := utils.StrToInt64(c.r.FormValue("FormDC"))

	if !utils.CheckInputData(token, "string") {
		return "", errors.New("incorrect data")
	}

	// order_id занесем когда поуступят деньги в платежной системе
	err := c.ExecSql(`UPDATE e_tokens SET buy_currency_id = ?, amount_fiat = ? WHERE token = ?`, buyCurrencyId, utils.StrToFloat64(c.r.FormValue("FormExAmount")), token)
	if err != nil {
		return "", utils.ErrInfo(err)
	}

	tokenId, err := c.Single(`SELECT id FROM e_tokens WHERE token = ?`, token).String()
	if err != nil {
		return "", utils.ErrInfo(err)
	}

	TemplateStr, err := makeTemplate("e_redirect", "eRedirect", &ERedirectPage{
		Lang:    c.Lang,
		EConfig: c.EConfig,
		TokenId: tokenId,
		EURL:    c.EURL,
		MDesc:   base64.StdEncoding.EncodeToString([]byte("token-" + tokenId)),
		Amount:  amount})
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	return TemplateStr, nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:34,代碼來源:e_redirect.go

示例10: UserAvatarFront

func (p *Parser) UserAvatarFront() error {

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	verifyData := map[string]string{"name": "user_name"}
	err = p.CheckInputData(verifyData)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !utils.CheckInputData(p.TxMaps.String["avatar"], "img_url") && p.TxMaps.String["avatar"] != "0" {
		return fmt.Errorf("incorrect avatar")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["name"], p.TxMap["avatar"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	err = p.limitRequest(consts.LIMIT_USER_AVATAR, "user_avatar", consts.LIMIT_USER_AVATAR_PERIOD)
	if err != nil {
		return p.ErrInfo(err)
	}
	return nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:31,代碼來源:user_avatar.go

示例11: CheckCfCurrency

func (c *Controller) CheckCfCurrency() (string, error) {

	if c.SessRestricted != 0 {
		return "", utils.ErrInfo(errors.New("Permission denied"))
	}

	c.r.ParseForm()
	projectCurrencyName := c.r.FormValue("project_currency_name")
	if !utils.CheckInputData(projectCurrencyName, "cf_currency_name") {
		return "", errors.New("incorrect project_currency_name")
	}

	// проверим, не занято ли имя валюты
	currency, err := c.Single("SELECT id FROM cf_projects WHERE project_currency_name = ? AND close_block_id = 0 AND del_block_id = 0", projectCurrencyName).Int64()
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	if currency > 0 {
		return `{"error":"` + c.Lang["currency_name_busy"] + `"}`, nil
	}

	// проверим, не занято ли имя валюты
	currency, err = c.Single("SELECT id FROM cf_currency WHERE name = ?", projectCurrencyName).Int64()
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	if currency > 0 {
		return `{"error":"` + c.Lang["currency_name_busy"] + `"}`, nil
	}

	return `{"success":"` + c.Lang["name_is_not_occupied"] + `"}`, nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:32,代碼來源:check_cf_currency.go

示例12: NewUserFront

func (p *Parser) NewUserFront() error {

	log.Debug("NewUserFront")

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	// является ли данный юзер майнером
	err = p.checkMiner(p.TxUserID)
	if err != nil {
		return p.ErrInfo(err)
	}

	// прошло ли 30 дней с момента регистрации майнера
	err = p.checkMinerNewbie()
	if err != nil {
		return p.ErrInfo(err)
	}

	// чтобы не записали слишком мелкий или слишком крупный ключ
	if !utils.CheckInputData(p.TxMap["public_key_hex"], "public_key") {
		return utils.ErrInfo(fmt.Errorf("incorrect public_key %s", p.TxMap["public_key_hex"]))
	}

	// публичный ключ должен быть без паролей
	if ok, _ := regexp.MatchString("DEK-Info: (.+),(.+)", string(p.TxMap["public_key"])); ok {
		return p.ErrInfo("incorrect public_key")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["public_key_hex"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	// один ключ не может быть у двух юзеров
	num, err := p.DCDB.Single("SELECT count(user_id) FROM users WHERE hex(public_key_0) = ? OR hex(public_key_1) = ? OR hex(public_key_2) = ?",
		p.TxMap["public_key_hex"], p.TxMap["public_key_hex"], p.TxMap["public_key_hex"]).Int()
	if num > 0 {
		return p.ErrInfo("exists public_key")
	}
	err = p.getAdminUserId()
	if err != nil {
		return p.ErrInfo(err)
	}
	if utils.BytesToInt64(p.TxMap["user_id"]) == p.AdminUserId {
		err = p.limitRequest(1000, "new_user", 86400)
	} else {
		err = p.limitRequest(p.Variables.Int64["limit_new_user"], "new_user", p.Variables.Int64["limit_new_user_period"])
	}
	if err != nil {
		return p.ErrInfo(err)
	}
	return nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:60,代碼來源:new_user.go

示例13: AbusesFront

func (p *Parser) AbusesFront() error {

	err := p.generalCheck()
	if err != nil {
		return p.ErrInfo(err)
	}

	var abuses map[string]string
	err = json.Unmarshal(p.TxMap["abuses"], &abuses)
	if err != nil {
		return p.ErrInfo(err)
	}
	if len(abuses) > 100 {
		return fmt.Errorf(">100")
	}
	for userId, comment := range abuses {
		if !utils.CheckInputData(userId, "user_id") {
			return fmt.Errorf("incorrect abuses user_id")
		}
		if !utils.CheckInputData(comment, "abuse_comment") {
			return fmt.Errorf("incorrect abuse_comment")
		}
		// является ли данный юзер майнером
		err = p.checkMiner(utils.StrToInt64(userId))
		if err != nil {
			return p.ErrInfo(err)
		}
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["abuses"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}

	err = p.limitRequest(p.Variables.Int64["limit_abuses"], "abuses", p.Variables.Int64["limit_abuses_period"])
	if err != nil {
		return p.ErrInfo(err)
	}
	return nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:44,代碼來源:abuses.go

示例14: AdminSpotsFront

func (p *Parser) AdminSpotsFront() error {
	err := p.generalCheckAdmin()
	if err != nil {
		return p.ErrInfo(err)
	}

	if !utils.CheckInputData(p.TxMap["compatibility"], "compatibility") {
		return p.ErrInfo("incorrect compatibility")
	}
	exampleSpots := new(exampleSpotsType)
	if err := json.Unmarshal([]byte(p.TxMap["example_spots"]), &exampleSpots); err != nil {
		return p.ErrInfo("incorrect example_spots")
	}
	if exampleSpots.Face == nil || exampleSpots.Profile == nil {
		return p.ErrInfo("incorrect example_spots")
	}

	segments := new(exampleSpotsType)
	if err := json.Unmarshal([]byte(p.TxMap["segments"]), &segments); err != nil {
		return p.ErrInfo("incorrect segments")
	}
	if segments.Face == nil || segments.Profile == nil {
		return p.ErrInfo("incorrect segments")
	}
	tolerances := new(tolerancesType)
	if err := json.Unmarshal([]byte(p.TxMap["tolerances"]), &tolerances); err != nil {
		return p.ErrInfo("incorrect tolerances")
	}
	if tolerances.Face == nil || tolerances.Profile == nil {
		return p.ErrInfo("incorrect tolerances")
	}
	forSign := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["example_spots"], p.TxMap["segments"], p.TxMap["tolerances"], p.TxMap["compatibility"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}
	return nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:41,代碼來源:admin_spots.go

示例15: EInfo

func (c *Controller) EInfo() (string, error) {

	c.w.Header().Set("Access-Control-Allow-Origin", "*")

	c.r.ParseForm()
	token := c.r.FormValue("token")
	if !utils.CheckInputData(token, "string") {
		return "", errors.New("incorrect token")
	}
	tokenMap, err := c.OneRow(`SELECT * FROM e_tokens WHERE token = ?`, token).String()
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	wallets, err := c.GetAll(`SELECT * FROM e_wallets WHERE user_id = ?`, 100, tokenMap["user_id"])
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	orders, err := c.GetAll(`SELECT * FROM e_orders WHERE user_id = ? ORDER BY time DESC LIMIT 10`, 100, tokenMap["user_id"])
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	withdraw, err := c.GetAll(`SELECT * FROM e_withdraw WHERE user_id = ? ORDER BY open_time DESC LIMIT 10`, 100, tokenMap["user_id"])
	if err != nil {
		return "", utils.ErrInfo(err)
	}

	m := EInfoResult{
		Token:    tokenMap,
		Wallets:  wallets,
		Orders:   orders,
		Withdraw: withdraw,
	}
	jsonData, err := json.Marshal(m)
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	return string(jsonData), nil
}
開發者ID:dzyk,項目名稱:dcoin-go,代碼行數:38,代碼來源:e_info.go


注:本文中的github.com/c-darwin/dcoin-go/packages/utils.CheckInputData函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。