linter: Enable error checking linter (#766)

* golangci: Enable err checking linter to expose unchecked errors.

* gct: handle errors across the board

* gct: handle errors NOTE: Found bug in FTX (WIP)

* linter: fix issues

* ftx/exchanges: fix bug where error was being returned when setting pair management variables to an already enabled state

* bitmex: fix bug where a dangly supported asset in config danglied up the place.

* linter: fix more linter issues

* linter: fix my terrible spelling.

* currency: fix test

* exchanges: fix tests

* logger: fix test

* exchanges: fix tests

* glorious: nits

* vm: revert rm variable and instigate test
This commit is contained in:
Ryan O'Hara-Reid
2021-08-30 14:06:40 +10:00
committed by GitHub
parent c9ab0b1164
commit 8020e1ec6a
99 changed files with 814 additions and 293 deletions

View File

@@ -1153,18 +1153,24 @@ func (f *FTX) SendAuthHTTPRequest(ep exchange.URL, method, path string, data, re
ts := strconv.FormatInt(time.Now().UnixNano()/1000000, 10)
var body io.Reader
var hmac, payload []byte
sigPayload := ts + method + "/api" + path
if data != nil {
payload, err = json.Marshal(data)
if err != nil {
return nil, err
}
body = bytes.NewBuffer(payload)
sigPayload := ts + method + "/api" + path + string(payload)
hmac = crypto.GetHMAC(crypto.HashSHA256, []byte(sigPayload), []byte(f.API.Credentials.Secret))
} else {
sigPayload := ts + method + "/api" + path
hmac = crypto.GetHMAC(crypto.HashSHA256, []byte(sigPayload), []byte(f.API.Credentials.Secret))
sigPayload += string(payload)
}
hmac, err = crypto.GetHMAC(crypto.HashSHA256,
[]byte(sigPayload),
[]byte(f.API.Credentials.Secret))
if err != nil {
return nil, err
}
headers := make(map[string]string)
headers["FTX-KEY"] = f.API.Credentials.Key
headers["FTX-SIGN"] = crypto.HexEncodeToString(hmac)

View File

@@ -76,11 +76,14 @@ func (f *FTX) WsConnect() error {
func (f *FTX) WsAuth() error {
intNonce := time.Now().UnixNano() / 1000000
strNonce := strconv.FormatInt(intNonce, 10)
hmac := crypto.GetHMAC(
hmac, err := crypto.GetHMAC(
crypto.HashSHA256,
[]byte(strNonce+"websocket_login"),
[]byte(f.API.Credentials.Secret),
)
if err != nil {
return err
}
sign := crypto.HexEncodeToString(hmac)
req := Authenticate{Operation: "login",
Args: AuthenticationData{