mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-11 09:33:50 +00:00
32 lines
569 B
Go
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))
|
||
|
}
|
||
|
|