Add nonce package for exchanges

This commit is contained in:
Adrian Gallagher
2017-08-21 15:57:41 +10:00
parent 0fea98857c
commit f3c1f4880d
20 changed files with 256 additions and 61 deletions

View File

@@ -318,10 +318,14 @@ func (b *Bittrex) SendAuthenticatedHTTPRequest(path string, values url.Values, r
return fmt.Errorf(exchange.WarningAuthenticatedRequestWithoutCredentialsSet, b.Name)
}
nonce := strconv.FormatInt(time.Now().UnixNano(), 10)
if b.Nonce.Get() == 0 {
b.Nonce.Set(time.Now().UnixNano())
} else {
b.Nonce.Inc()
}
values.Set("apikey", b.APIKey)
values.Set("apisecret", b.APISecret)
values.Set("nonce", nonce)
values.Set("nonce", b.Nonce.String())
rawQuery := path + "?" + values.Encode()
hmac := common.GetHMAC(
common.HashSHA512, []byte(rawQuery), []byte(b.APISecret),