Changed const naming convention assoc. with common.go

This commit is contained in:
Ryan O'Hara-Reid
2017-07-22 09:55:53 +10:00
committed by Adrian Gallagher
parent c4e09fad08
commit 00d2024e5a
19 changed files with 54 additions and 36 deletions

View File

@@ -415,7 +415,7 @@ func (a *Alphapoint) SendAuthenticatedHTTPRequest(method, path string, data map[
nonce := time.Now().UnixNano()
nonceStr := strconv.FormatInt(nonce, 10)
data["apiNonce"] = nonce
hmac := common.GetHMAC(common.HASH_SHA256, []byte(nonceStr+a.ClientID+a.APIKey), []byte(a.APISecret))
hmac := common.GetHMAC(common.HashSHA256, []byte(nonceStr+a.ClientID+a.APIKey), []byte(a.APISecret))
data["apiSig"] = common.StringToUpper(common.HexEncodeToString(hmac))
path = fmt.Sprintf("%s/ajax/v%s/%s", a.APIUrl, ALPHAPOINT_API_VERSION, path)
PayloadJson, err := common.JSONEncode(data)

View File

@@ -306,7 +306,7 @@ func (a *ANX) SendAuthenticatedHTTPRequest(path string, params map[string]interf
log.Printf("Request JSON: %s\n", PayloadJson)
}
hmac := common.GetHMAC(common.HASH_SHA512, []byte(path+string("\x00")+string(PayloadJson)), []byte(a.APISecret))
hmac := common.GetHMAC(common.HashSHA512, []byte(path+string("\x00")+string(PayloadJson)), []byte(a.APISecret))
headers := make(map[string]string)
headers["Rest-Key"] = a.APIKey
headers["Rest-Sign"] = common.Base64Encode([]byte(hmac))

View File

@@ -613,7 +613,7 @@ func (b *Bitfinex) SendAuthenticatedHTTPRequest(method, path string, params map[
}
PayloadBase64 := common.Base64Encode(PayloadJson)
hmac := common.GetHMAC(common.HASH_SHA512_384, []byte(PayloadBase64), []byte(b.APISecret))
hmac := common.GetHMAC(common.HashSHA512_384, []byte(PayloadBase64), []byte(b.APISecret))
headers := make(map[string]string)
headers["X-BFX-APIKEY"] = b.APIKey
headers["X-BFX-PAYLOAD"] = PayloadBase64

View File

@@ -74,7 +74,7 @@ func (b *Bitfinex) WebsocketSendAuth() error {
payload := "AUTH" + strconv.FormatInt(time.Now().UnixNano(), 10)[:13]
request["event"] = "auth"
request["apiKey"] = b.APIKey
request["authSig"] = common.HexEncodeToString(common.GetHMAC(common.HASH_SHA512_384, []byte(payload), []byte(b.APISecret)))
request["authSig"] = common.HexEncodeToString(common.GetHMAC(common.HashSHA512_384, []byte(payload), []byte(b.APISecret)))
request["authPayload"] = payload
return b.WebsocketSend(request)
}

View File

@@ -476,7 +476,7 @@ func (b *Bitstamp) SendAuthenticatedHTTPRequest(path string, v2 bool, values url
values.Set("key", b.APIKey)
values.Set("nonce", nonce)
hmac := common.GetHMAC(common.HASH_SHA256, []byte(nonce+b.ClientID+b.APIKey), []byte(b.APISecret))
hmac := common.GetHMAC(common.HashSHA256, []byte(nonce+b.ClientID+b.APIKey), []byte(b.APISecret))
values.Set("signature", common.StringToUpper(common.HexEncodeToString(hmac)))
if v2 {

View File

@@ -558,7 +558,7 @@ func (b *BTCC) SendAuthenticatedHTTPRequest(method string, params []interface{})
log.Println(encoded)
}
hmac := common.GetHMAC(common.HASH_SHA1, []byte(encoded), []byte(b.APISecret))
hmac := common.GetHMAC(common.HashSHA1, []byte(encoded), []byte(b.APISecret))
postData := make(map[string]interface{})
postData["method"] = method
postData["params"] = params

View File

@@ -298,7 +298,7 @@ func (b *BTCE) SendAuthenticatedHTTPRequest(method string, values url.Values, re
values.Set("method", method)
encoded := values.Encode()
hmac := common.GetHMAC(common.HASH_SHA512, []byte(encoded), []byte(b.APISecret))
hmac := common.GetHMAC(common.HashSHA512, []byte(encoded), []byte(b.APISecret))
if b.Verbose {
log.Printf("Sending POST request to %s calling method %s with params %s\n", BTCE_API_PRIVATE_URL, method, encoded)

View File

@@ -105,8 +105,8 @@ func (b *BTCMarkets) Order(currency, instrument string, price, amount int64, ord
order := Order{}
order.Currency = currency
order.Instrument = instrument
order.Price = price * common.SATOSHIS_PER_BTC
order.Volume = amount * common.SATOSHIS_PER_BTC
order.Price = price * common.SatoshisPerBTC
order.Volume = amount * common.SatoshisPerBTC
order.OrderSide = orderSide
order.OrderType = orderType
order.ClientRequestId = clientReq
@@ -212,14 +212,14 @@ func (b *BTCMarkets) GetOrders(currency, instrument string, limit, since int64,
}
for i := range resp.Orders {
resp.Orders[i].Price = resp.Orders[i].Price / common.SATOSHIS_PER_BTC
resp.Orders[i].OpenVolume = resp.Orders[i].OpenVolume / common.SATOSHIS_PER_BTC
resp.Orders[i].Volume = resp.Orders[i].Volume / common.SATOSHIS_PER_BTC
resp.Orders[i].Price = resp.Orders[i].Price / common.SatoshisPerBTC
resp.Orders[i].OpenVolume = resp.Orders[i].OpenVolume / common.SatoshisPerBTC
resp.Orders[i].Volume = resp.Orders[i].Volume / common.SatoshisPerBTC
for x := range resp.Orders[i].Trades {
resp.Orders[i].Trades[x].Fee = resp.Orders[i].Trades[x].Fee / common.SATOSHIS_PER_BTC
resp.Orders[i].Trades[x].Price = resp.Orders[i].Trades[x].Price / common.SATOSHIS_PER_BTC
resp.Orders[i].Trades[x].Volume = resp.Orders[i].Trades[x].Volume / common.SATOSHIS_PER_BTC
resp.Orders[i].Trades[x].Fee = resp.Orders[i].Trades[x].Fee / common.SatoshisPerBTC
resp.Orders[i].Trades[x].Price = resp.Orders[i].Trades[x].Price / common.SatoshisPerBTC
resp.Orders[i].Trades[x].Volume = resp.Orders[i].Trades[x].Volume / common.SatoshisPerBTC
}
}
return resp.Orders, nil
@@ -251,14 +251,14 @@ func (b *BTCMarkets) GetOrderDetail(orderID []int64) ([]BTCMarketsOrder, error)
}
for i := range resp.Orders {
resp.Orders[i].Price = resp.Orders[i].Price / common.SATOSHIS_PER_BTC
resp.Orders[i].OpenVolume = resp.Orders[i].OpenVolume / common.SATOSHIS_PER_BTC
resp.Orders[i].Volume = resp.Orders[i].Volume / common.SATOSHIS_PER_BTC
resp.Orders[i].Price = resp.Orders[i].Price / common.SatoshisPerBTC
resp.Orders[i].OpenVolume = resp.Orders[i].OpenVolume / common.SatoshisPerBTC
resp.Orders[i].Volume = resp.Orders[i].Volume / common.SatoshisPerBTC
for x := range resp.Orders[i].Trades {
resp.Orders[i].Trades[x].Fee = resp.Orders[i].Trades[x].Fee / common.SATOSHIS_PER_BTC
resp.Orders[i].Trades[x].Price = resp.Orders[i].Trades[x].Price / common.SATOSHIS_PER_BTC
resp.Orders[i].Trades[x].Volume = resp.Orders[i].Trades[x].Volume / common.SATOSHIS_PER_BTC
resp.Orders[i].Trades[x].Fee = resp.Orders[i].Trades[x].Fee / common.SatoshisPerBTC
resp.Orders[i].Trades[x].Price = resp.Orders[i].Trades[x].Price / common.SatoshisPerBTC
resp.Orders[i].Trades[x].Volume = resp.Orders[i].Trades[x].Volume / common.SatoshisPerBTC
}
}
return resp.Orders, nil
@@ -274,8 +274,8 @@ func (b *BTCMarkets) GetAccountBalance() ([]BTCMarketsAccountBalance, error) {
for i := range balance {
if balance[i].Currency == "LTC" || balance[i].Currency == "BTC" {
balance[i].Balance = balance[i].Balance / common.SATOSHIS_PER_BTC
balance[i].PendingFunds = balance[i].PendingFunds / common.SATOSHIS_PER_BTC
balance[i].Balance = balance[i].Balance / common.SatoshisPerBTC
balance[i].PendingFunds = balance[i].PendingFunds / common.SatoshisPerBTC
}
}
return balance, nil
@@ -296,7 +296,7 @@ func (b *BTCMarkets) SendAuthenticatedRequest(reqType, path string, data interfa
request = path + "\n" + nonce + "\n"
}
hmac := common.GetHMAC(common.HASH_SHA512, []byte(request), []byte(b.APISecret))
hmac := common.GetHMAC(common.HashSHA512, []byte(request), []byte(b.APISecret))
if b.Verbose {
log.Printf("Sending %s request to URL %s with params %s\n", reqType, BTCMARKETS_API_URL+path, request)

View File

@@ -290,7 +290,7 @@ func (c *COINUT) SendAuthenticatedHTTPRequest(apiRequest string, params map[stri
log.Printf("Request JSON: %s\n", payload)
}
hmac := common.GetHMAC(common.HASH_SHA256, []byte(payload), []byte(c.APIKey))
hmac := common.GetHMAC(common.HashSHA256, []byte(payload), []byte(c.APIKey))
headers := make(map[string]string)
headers["X-USER"] = c.ClientID
headers["X-SIGNATURE"] = common.HexEncodeToString(hmac)

View File

@@ -387,7 +387,7 @@ func (g *GDAX) SendAuthenticatedHTTPRequest(method, path string, params map[stri
}
message := timestamp + method + "/" + path + string(payload)
hmac := common.GetHMAC(common.HASH_SHA256, []byte(message), []byte(g.APISecret))
hmac := common.GetHMAC(common.HashSHA256, []byte(message), []byte(g.APISecret))
headers := make(map[string]string)
headers["CB-ACCESS-SIGN"] = common.Base64Encode([]byte(hmac))
headers["CB-ACCESS-TIMESTAMP"] = timestamp

View File

@@ -266,7 +266,7 @@ func (g *Gemini) SendAuthenticatedHTTPRequest(method, path string, params map[st
}
PayloadBase64 := common.Base64Encode(PayloadJson)
hmac := common.GetHMAC(common.HASH_SHA512_384, []byte(PayloadBase64), []byte(g.APISecret))
hmac := common.GetHMAC(common.HashSHA512_384, []byte(PayloadBase64), []byte(g.APISecret))
headers := make(map[string]string)
headers["X-GEMINI-APIKEY"] = g.APIKey
headers["X-GEMINI-PAYLOAD"] = PayloadBase64

View File

@@ -266,7 +266,7 @@ func (i *ItBit) SendAuthenticatedHTTPRequest(method string, path string, params
}
hash := common.GetSHA256([]byte(nonceStr + string(message)))
hmac := common.GetHMAC(common.HASH_SHA512, []byte(url+string(hash)), []byte(i.APISecret))
hmac := common.GetHMAC(common.HashSHA512, []byte(url+string(hash)), []byte(i.APISecret))
signature := common.Base64Encode(hmac)
headers := make(map[string]string)

View File

@@ -518,7 +518,7 @@ func (k *Kraken) SendAuthenticatedHTTPRequest(method string, values url.Values)
}
shasum := common.GetSHA256([]byte(values.Get("nonce") + values.Encode()))
signature := common.Base64Encode(common.GetHMAC(common.HASH_SHA512, append([]byte(path), shasum...), secret))
signature := common.Base64Encode(common.GetHMAC(common.HashSHA512, append([]byte(path), shasum...), secret))
if k.Verbose {
log.Printf("Sending POST request to %s, path: %s.", KRAKEN_API_URL, path)

View File

@@ -274,7 +274,7 @@ func (l *LakeBTC) CreateWithdraw(amount float64, accountID int64) (LakeBTCWithdr
func (l *LakeBTC) SendAuthenticatedHTTPRequest(method, params string, result interface{}) (err error) {
nonce := strconv.FormatInt(time.Now().UnixNano(), 10)
req := fmt.Sprintf("tonce=%s&accesskey=%s&requestmethod=post&id=1&method=%s&params=%s", nonce, l.APIKey, method, params)
hmac := common.GetHMAC(common.HASH_SHA1, []byte(req), []byte(l.APISecret))
hmac := common.GetHMAC(common.HashSHA1, []byte(req), []byte(l.APISecret))
if l.Verbose {
log.Printf("Sending POST request to %s calling method %s with params %s\n", LAKEBTC_API_URL, method, req)

View File

@@ -254,7 +254,7 @@ func (l *Liqui) SendAuthenticatedHTTPRequest(method string, values url.Values, r
values.Set("method", method)
encoded := values.Encode()
hmac := common.GetHMAC(common.HASH_SHA512, []byte(encoded), []byte(l.APISecret))
hmac := common.GetHMAC(common.HashSHA512, []byte(encoded), []byte(l.APISecret))
if l.Verbose {
log.Printf("Sending POST request to %s calling method %s with params %s\n", LIQUI_API_PRIVATE_URL, method, encoded)

View File

@@ -276,7 +276,7 @@ func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, values
}
message := string(nonce) + l.APIKey + path + payload
hmac := common.GetHMAC(common.HASH_SHA256, []byte(message), []byte(l.APISecret))
hmac := common.GetHMAC(common.HashSHA256, []byte(message), []byte(l.APISecret))
headers := make(map[string]string)
headers["Apiauth-Key"] = l.APIKey
headers["Apiauth-Nonce"] = string(nonce)

View File

@@ -755,7 +755,7 @@ func (p *Poloniex) SendAuthenticatedHTTPRequest(method, endpoint string, values
values.Set("nonce", nonceStr)
values.Set("command", endpoint)
hmac := common.GetHMAC(common.HASH_SHA512, []byte(values.Encode()), []byte(p.APISecret))
hmac := common.GetHMAC(common.HashSHA512, []byte(values.Encode()), []byte(p.APISecret))
headers["Sign"] = common.HexEncodeToString(hmac)
path := fmt.Sprintf("%s/%s", POLONIEX_API_URL, POLONIEX_API_TRADING_ENDPOINT)