Skip to content

Commit

Permalink
fix: mexc signature verification failed
Browse files Browse the repository at this point in the history
  • Loading branch information
linstohu committed Dec 28, 2023
1 parent ce5be49 commit 741117c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions mexc/contract/utils/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,12 @@ func (c *ContractClient) GenAuthHeaders(req HTTPRequest) (map[string]string, err

timestamp := fmt.Sprintf("%d", time.Now().UnixMilli())

if signString != "" {
sign := fmt.Sprintf("%s%s%s", c.key, timestamp, signString)
h := hmac.New(sha256.New, []byte(c.secret))
h.Write([]byte(sign))
signature := hex.EncodeToString(h.Sum(nil))
headers["Signature"] = signature
}
sign := fmt.Sprintf("%s%s%s", c.key, timestamp, signString)
h := hmac.New(sha256.New, []byte(c.secret))
h.Write([]byte(sign))

signature := hex.EncodeToString(h.Sum(nil))
headers["Signature"] = signature

headers["ApiKey"] = c.key
headers["Request-Time"] = timestamp
Expand Down

0 comments on commit 741117c

Please sign in to comment.