本文整理匯總了Golang中github.com/c-darwin/dcoin-go/packages/utils.CheckSign函數的典型用法代碼示例。如果您正苦於以下問題:Golang CheckSign函數的具體用法?Golang CheckSign怎麽用?Golang CheckSign使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CheckSign函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AdminAddCurrencyFront
func (p *Parser) AdminAddCurrencyFront() error {
err := p.generalCheckAdmin()
if err != nil {
return p.ErrInfo(err)
}
verifyData := map[string]string{"currency_name": "currency_name", "currency_full_name": "currency_full_name", "max_promised_amount": "int", "max_other_currencies": "int"}
err = p.CheckInputData(verifyData)
if err != nil {
return p.ErrInfo(err)
}
// проверим, нет ли уже такой валюты
name, err := p.Single("SELECT name FROM currency WHERE name = ?", p.TxMaps.String["currency_name"]).String()
if err != nil {
return p.ErrInfo(err)
}
if len(name) > 0 {
return p.ErrInfo("exists currency_name")
}
forSign := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["currency_name"], p.TxMap["currency_full_name"], p.TxMap["max_promised_amount"], p.TxMap["max_other_currencies"])
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
}
示例2: DelCreditFront
func (p *Parser) DelCreditFront() error {
err := p.generalCheck()
if err != nil {
return p.ErrInfo(err)
}
verifyData := map[string]string{"credit_id": "bigint"}
err = p.CheckInputData(verifyData)
if err != nil {
return p.ErrInfo(err)
}
// явлется данный юзер кредитором
id, err := p.Single("SELECT id FROM credits WHERE id = ? AND to_user_id = ? AND del_block_id = 0", p.TxMaps.Int64["credit_id"], p.TxUserID).Int64()
if err != nil {
return p.ErrInfo(err)
}
if id == 0 {
return p.ErrInfo("not a creditor")
}
forSign := fmt.Sprintf("%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["credit_id"])
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
}
示例3: AdminBlogFront
func (p *Parser) AdminBlogFront() error {
err := p.generalCheckAdmin()
if err != nil {
return p.ErrInfo(err)
}
if len(p.TxMaps.String["title"]) > 255 {
return p.ErrInfo("len title>255")
}
if len(p.TxMaps.String["message"]) > 1048576 {
return p.ErrInfo("len message>1048576")
}
forSign := fmt.Sprintf("%s,%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["lng"], p.TxMap["title"], p.TxMap["message"])
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
}
示例4: AdminAnswerFront
func (p *Parser) AdminAnswerFront() error {
err := p.generalCheckAdmin()
if err != nil {
return p.ErrInfo(err)
}
if len(p.TxMaps.Bytes["encrypted_message"]) > 20480 {
return p.ErrInfo("len encrypted_message>20480")
}
verifyData := map[string]string{"to_user_id": "user_id"}
err = p.CheckInputData(verifyData)
if err != nil {
return p.ErrInfo(err)
}
forSign := fmt.Sprintf("%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["to_user_id"], p.TxMap["encrypted_message"])
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
}
示例5: AdminNewVersionFront
func (p *Parser) AdminNewVersionFront() error {
err := p.generalCheckAdmin()
if err != nil {
return p.ErrInfo(err)
}
verifyData := map[string]string{"version": "version", "soft_type": "soft_type"}
err = p.CheckInputData(verifyData)
if err != nil {
return p.ErrInfo(err)
}
version, err := p.Single("SELECT version FROM new_version WHERE version = ?", p.TxMap["version"]).String()
if err != nil {
return p.ErrInfo(err)
}
if len(version) > 0 {
return p.ErrInfo("exists version")
}
forSign := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["soft_type"], p.TxMap["version"], utils.Sha256(p.TxMap["file"]), p.TxMap["format"])
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
}
示例6: ChangeSellerHoldBackFront
func (p *Parser) ChangeSellerHoldBackFront() error {
err := p.generalCheck()
if err != nil {
return p.ErrInfo(err)
}
verifyData := map[string]string{"arbitration_days_refund": "smallint", "hold_back_pct": "pct"}
err = p.CheckInputData(verifyData)
if err != nil {
return p.ErrInfo(err)
}
if p.TxMaps.Money["hold_back_pct"] < 0.01 || p.TxMaps.Money["hold_back_pct"] > 100 {
return p.ErrInfo("incorrect hold_back_pct")
}
forSign := fmt.Sprintf("%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["arbitration_days_refund"], p.TxMap["hold_back_pct"])
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_SELLER_HOLD_BACK, "change_seller_hold_back", consts.LIMIT_CHANGE_SELLER_HOLD_BACK_PERIOD)
if err != nil {
return p.ErrInfo(err)
}
return nil
}
示例7: 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
}
示例8: AdminNewVersionAlertFront
func (p *Parser) AdminNewVersionAlertFront() error {
err := p.generalCheckAdmin()
if err != nil {
return p.ErrInfo(err)
}
verifyData := map[string]string{"version": "version", "soft_type": "soft_type"}
err = p.CheckInputData(verifyData)
if err != nil {
return p.ErrInfo(err)
}
alert, err := p.Single("SELECT alert FROM new_version WHERE version = ?", p.TxMaps.String["version"]).Int64()
if err != nil {
return p.ErrInfo(err)
}
if alert == 1 {
return p.ErrInfo("alert == 1")
}
forSign := fmt.Sprintf("%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["soft_type"], p.TxMap["version"])
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
}
示例9: 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
}
示例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
}
示例11: ChangeKeyActiveFront
func (p *Parser) ChangeKeyActiveFront() error {
err := p.generalCheck()
if err != nil {
return p.ErrInfo(err)
}
if len(p.TxMaps.Bytes["secret"]) > 2048 {
return p.ErrInfo("len secret > 2048")
}
// проверим, чтобы не было повторных смен
changeKey, err := p.Single("SELECT change_key FROM users WHERE user_id = ?", p.TxUserID).Int64()
if err != nil {
return p.ErrInfo(err)
}
if changeKey == p.TxMaps.Int64["active"] {
return p.ErrInfo("active")
}
forSign := fmt.Sprintf("%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMaps.String["secret_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")
}
err = p.limitRequest(consts.LIMIT_CHANGE_KEY_ACTIVE, "change_key_active", consts.LIMIT_CHANGE_KEY_ACTIVE_PERIOD)
if err != nil {
return p.ErrInfo(err)
}
return nil
}
示例12: DelAutoPaymentFront
func (p *Parser) DelAutoPaymentFront() error {
err := p.generalCheck()
if err != nil {
return p.ErrInfo(err)
}
verifyData := map[string]string{"auto_payment_id": "int"}
err = p.CheckInputData(verifyData)
if err != nil {
return p.ErrInfo(err)
}
// проверим, есть ли такой автоплатеж, принадлежащий нашем юзеру
autoPayment, err := p.Single("SELECT id FROM auto_payments WHERE id = ? and sender = ?", p.TxMaps.Int64["project_id"], p.TxUserID).Int64()
if err != nil {
return p.ErrInfo(err)
}
if autoPayment == 0 {
return p.ErrInfo("incorrect auto_payment_id")
}
forSign := fmt.Sprintf("%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["auto_payment_id"])
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
}
示例13: ChangeKeyCloseFront
func (p *Parser) ChangeKeyCloseFront() error {
err := p.generalCheck()
if err != nil {
return p.ErrInfo(err)
}
// проверим, не стоит ли уже close
changeKeyClose, err := p.Single("SELECT change_key_close FROM users WHERE user_id = ?", p.TxUserID).Int64()
if err != nil {
return p.ErrInfo(err)
}
if changeKeyClose > 0 {
return p.ErrInfo("change_key_close=1")
}
forSign := fmt.Sprintf("%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"])
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
}
示例14: MessageToAdminFront
func (p *Parser) MessageToAdminFront() error {
err := p.generalCheck()
if err != nil {
return p.ErrInfo(err)
}
// в бинарном виде проверить можем только размер
if len(p.TxMaps.Bytes["encrypted_message"]) > 20480 || len(p.TxMaps.Bytes["encrypted_message"]) == 0 {
return p.ErrInfo("encrypted_message len")
}
forSign := fmt.Sprintf("%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["encrypted_message"])
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_message_to_admin"], "message_to_admin", p.Variables.Int64["limit_message_to_admin_period"])
if err != nil {
return p.ErrInfo(err)
}
return nil
}
示例15: MoneyBackFront
func (p *Parser) MoneyBackFront() error {
err := p.generalCheck()
if err != nil {
return p.ErrInfo(err)
}
verifyData := map[string]string{"order_id": "bigint", "amount": "amount"}
err = p.CheckInputData(verifyData)
if err != nil {
return p.ErrInfo(err)
}
var txTime int64
if p.BlockData != nil {
txTime = p.BlockData.Time
} else {
txTime = time.Now().Unix() - 30 // просто на всякий случай небольшой запас
}
// проверим корректность ордера. тр-ия может быть как от продавца, так и от арбитра
orderId, err := p.Single(`
SELECT id
FROM orders
WHERE id = ? AND
status = 'refund' AND
(
(
(arbitrator0 = ? OR arbitrator1 = ? OR arbitrator2 = ? OR arbitrator3 = ? OR arbitrator4 = ?) AND
refund = 0 AND
(amount - voluntary_refund - ?) >= 0 AND
end_time >= ?
)
OR (
seller = ? AND
voluntary_refund = 0 AND
(amount - refund - ?) >= 0 AND
end_time >= ?
)
)
LIMIT 1
`, p.TxMaps.Int64["order_id"], p.TxUserID, p.TxUserID, p.TxUserID, p.TxUserID, p.TxUserID, string(p.TxMap["amount"]), txTime, p.TxUserID, string(p.TxMap["amount"]), txTime).Int64()
if err != nil {
return p.ErrInfo(err)
}
if orderId == 0 {
return p.ErrInfo("orderId==0")
}
forSign := fmt.Sprintf("%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["order_id"], p.TxMap["amount"])
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
}