From 741117c6211edbc0a8182c181b9d96c027b96ef0 Mon Sep 17 00:00:00 2001 From: linstohu Date: Thu, 28 Dec 2023 17:09:08 +0800 Subject: [PATCH] fix: mexc signature verification failed --- mexc/contract/utils/client.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mexc/contract/utils/client.go b/mexc/contract/utils/client.go index bd9d328..dea7874 100644 --- a/mexc/contract/utils/client.go +++ b/mexc/contract/utils/client.go @@ -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