bbgo_origin/bbgo/exchange/max/maxapi/auth.go

32 lines
569 B
Go
Raw Normal View History

2020-10-01 08:48:08 +00:00
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))
}