bbgo_origin/bbgo/exchange/max/maxapi/auth.go
2020-10-01 16:48:08 +08:00

32 lines
569 B
Go

package max
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
)
type AuthMessage struct {
Action string `json:"action"`
APIKey string `json:"apiKey"`
Nonce int64 `json:"nonce"`
Signature string `json:"signature"`
ID string `json:"id"`
}
type AuthEvent struct {
Event string
ID string
Timestamp int64
}
func signPayload(payload string, secret string) string {
var sig = hmac.New(sha256.New, []byte(secret))
_, err := sig.Write([]byte(payload))
if err != nil {
return ""
}
return hex.EncodeToString(sig.Sum(nil))
}