diff --git a/config/config.go b/config/config.go index 940c431d..aaa8ef40 100644 --- a/config/config.go +++ b/config/config.go @@ -158,6 +158,7 @@ type ExchangeConfig struct { RESTPollingDelay time.Duration `json:"restPollingDelay"` HTTPTimeout time.Duration `json:"httpTimeout"` HTTPUserAgent string `json:"httpUserAgent"` + HTTPDebugging bool `json:"httpDebugging"` AuthenticatedAPISupport bool `json:"authenticatedApiSupport"` APIKey string `json:"apiKey"` APISecret string `json:"apiSecret"` diff --git a/currency/coinmarketcap/coinmarketcap.go b/currency/coinmarketcap/coinmarketcap.go index 60a51dc9..f6cd6349 100644 --- a/currency/coinmarketcap/coinmarketcap.go +++ b/currency/coinmarketcap/coinmarketcap.go @@ -731,7 +731,8 @@ func (c *Coinmarketcap) SendHTTPRequest(method, endpoint string, v url.Values, r result, false, false, - c.Verbose) + c.Verbose, + false) } // CheckAccountPlan checks your current account plan to the minimal account diff --git a/currency/forexprovider/currencyconverterapi/currencyconverterapi.go b/currency/forexprovider/currencyconverterapi/currencyconverterapi.go index e5d7a932..5c23ebd7 100644 --- a/currency/forexprovider/currencyconverterapi/currencyconverterapi.go +++ b/currency/forexprovider/currencyconverterapi/currencyconverterapi.go @@ -191,7 +191,8 @@ func (c *CurrencyConverter) SendHTTPRequest(endPoint string, values url.Values, &result, auth, false, - c.Verbose) + c.Verbose, + false) if err != nil { return fmt.Errorf("currency converter API SendHTTPRequest error %s with path %s", err, diff --git a/currency/forexprovider/currencylayer/currencylayer.go b/currency/forexprovider/currencylayer/currencylayer.go index c759d641..7b9d9345 100644 --- a/currency/forexprovider/currencylayer/currencylayer.go +++ b/currency/forexprovider/currencylayer/currencylayer.go @@ -240,5 +240,6 @@ func (c *CurrencyLayer) SendHTTPRequest(endPoint string, values url.Values, resu &result, auth, false, - c.Verbose) + c.Verbose, + false) } diff --git a/currency/forexprovider/exchangeratesapi.io/exchangeratesapi.go b/currency/forexprovider/exchangeratesapi.io/exchangeratesapi.go index d81ab481..2b58bc79 100644 --- a/currency/forexprovider/exchangeratesapi.io/exchangeratesapi.go +++ b/currency/forexprovider/exchangeratesapi.io/exchangeratesapi.go @@ -177,7 +177,8 @@ func (e *ExchangeRates) SendHTTPRequest(endPoint string, values url.Values, resu &result, false, false, - e.Verbose) + e.Verbose, + false) if err != nil { return fmt.Errorf("exchangeRatesAPI SendHTTPRequest error %s with path %s", err, diff --git a/currency/forexprovider/fixer.io/fixer.go b/currency/forexprovider/fixer.io/fixer.go index 0b46bbac..d83642ae 100644 --- a/currency/forexprovider/fixer.io/fixer.go +++ b/currency/forexprovider/fixer.io/fixer.go @@ -264,5 +264,6 @@ func (f *Fixer) SendOpenHTTPRequest(endpoint string, v url.Values, result interf result, auth, false, - f.Verbose) + f.Verbose, + false) } diff --git a/currency/forexprovider/openexchangerates/openexchangerates.go b/currency/forexprovider/openexchangerates/openexchangerates.go index f5b5dc27..9c00b676 100644 --- a/currency/forexprovider/openexchangerates/openexchangerates.go +++ b/currency/forexprovider/openexchangerates/openexchangerates.go @@ -264,5 +264,6 @@ func (o *OXR) SendHTTPRequest(endpoint string, values url.Values, result interfa result, false, false, - o.Verbose) + o.Verbose, + false) } diff --git a/exchanges/alphapoint/alphapoint.go b/exchanges/alphapoint/alphapoint.go index c3234f98..0d7f5d68 100644 --- a/exchanges/alphapoint/alphapoint.go +++ b/exchanges/alphapoint/alphapoint.go @@ -534,7 +534,7 @@ func (a *Alphapoint) SendHTTPRequest(method, path string, data map[string]interf return errors.New("unable to JSON request") } - return a.SendPayload(method, path, headers, bytes.NewBuffer(PayloadJSON), result, false, false, a.Verbose) + return a.SendPayload(method, path, headers, bytes.NewBuffer(PayloadJSON), result, false, false, a.Verbose, a.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an authenticated request @@ -559,5 +559,5 @@ func (a *Alphapoint) SendAuthenticatedHTTPRequest(method, path string, data map[ return errors.New("unable to JSON request") } - return a.SendPayload(method, path, headers, bytes.NewBuffer(PayloadJSON), result, true, true, a.Verbose) + return a.SendPayload(method, path, headers, bytes.NewBuffer(PayloadJSON), result, true, true, a.Verbose, a.HTTPDebugging) } diff --git a/exchanges/anx/anx.go b/exchanges/anx/anx.go index 036e6033..573e8791 100644 --- a/exchanges/anx/anx.go +++ b/exchanges/anx/anx.go @@ -87,6 +87,7 @@ func (a *ANX) Setup(exch *config.ExchangeConfig) { a.SetHTTPClientUserAgent(exch.HTTPUserAgent) a.RESTPollingDelay = exch.RESTPollingDelay a.Verbose = exch.Verbose + a.HTTPDebugging = exch.HTTPDebugging a.BaseCurrencies = exch.BaseCurrencies a.AvailablePairs = exch.AvailablePairs a.EnabledPairs = exch.EnabledPairs @@ -402,7 +403,7 @@ func (a *ANX) GetDepositAddressByCurrency(currency, name string, newAddr bool) ( // SendHTTPRequest sends an unauthenticated HTTP request func (a *ANX) SendHTTPRequest(path string, result interface{}) error { - return a.SendPayload(http.MethodGet, path, nil, nil, result, false, false, a.Verbose) + return a.SendPayload(http.MethodGet, path, nil, nil, result, false, false, a.Verbose, a.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends a authenticated HTTP request @@ -435,7 +436,7 @@ func (a *ANX) SendAuthenticatedHTTPRequest(path string, params map[string]interf headers["Rest-Sign"] = common.Base64Encode(hmac) headers["Content-Type"] = "application/json" - return a.SendPayload(http.MethodPost, a.APIUrl+path, headers, bytes.NewBuffer(PayloadJSON), result, true, true, a.Verbose) + return a.SendPayload(http.MethodPost, a.APIUrl+path, headers, bytes.NewBuffer(PayloadJSON), result, true, true, a.Verbose, a.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/binance/binance.go b/exchanges/binance/binance.go index 52b9d336..5a999426 100644 --- a/exchanges/binance/binance.go +++ b/exchanges/binance/binance.go @@ -113,6 +113,7 @@ func (b *Binance) Setup(exch *config.ExchangeConfig) { b.SetHTTPClientUserAgent(exch.HTTPUserAgent) b.RESTPollingDelay = exch.RESTPollingDelay b.Verbose = exch.Verbose + b.HTTPDebugging = exch.HTTPDebugging b.Websocket.SetWsStatusAndConnection(exch.Websocket) b.BaseCurrencies = exch.BaseCurrencies b.AvailablePairs = exch.AvailablePairs @@ -594,7 +595,7 @@ func (b *Binance) GetAccount() (*Account, error) { // SendHTTPRequest sends an unauthenticated request func (b *Binance) SendHTTPRequest(path string, result interface{}) error { - return b.SendPayload(http.MethodGet, path, nil, nil, result, false, false, b.Verbose) + return b.SendPayload(http.MethodGet, path, nil, nil, result, false, false, b.Verbose, b.HTTPDebugging) } // SendAuthHTTPRequest sends an authenticated HTTP request @@ -630,7 +631,7 @@ func (b *Binance) SendAuthHTTPRequest(method, path string, params url.Values, re Message string `json:"msg"` }{} - err := b.SendPayload(method, path, headers, bytes.NewBuffer(nil), &interim, true, false, b.Verbose) + err := b.SendPayload(method, path, headers, bytes.NewBuffer(nil), &interim, true, false, b.Verbose, b.HTTPDebugging) if err != nil { return err } diff --git a/exchanges/bitfinex/bitfinex.go b/exchanges/bitfinex/bitfinex.go index 9368e0a7..7fb3fabf 100644 --- a/exchanges/bitfinex/bitfinex.go +++ b/exchanges/bitfinex/bitfinex.go @@ -129,6 +129,7 @@ func (b *Bitfinex) Setup(exch *config.ExchangeConfig) { b.SetHTTPClientUserAgent(exch.HTTPUserAgent) b.RESTPollingDelay = exch.RESTPollingDelay b.Verbose = exch.Verbose + b.HTTPDebugging = exch.HTTPDebugging b.Websocket.SetWsStatusAndConnection(exch.Websocket) b.BaseCurrencies = exch.BaseCurrencies b.AvailablePairs = exch.AvailablePairs @@ -1001,7 +1002,7 @@ func (b *Bitfinex) CloseMarginFunding(swapID int64) (Offer, error) { // SendHTTPRequest sends an unauthenticated request func (b *Bitfinex) SendHTTPRequest(path string, result interface{}, verbose bool) error { - return b.SendPayload(http.MethodGet, path, nil, nil, result, false, false, verbose) + return b.SendPayload(http.MethodGet, path, nil, nil, result, false, false, verbose, b.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an autheticated http request and json @@ -1046,7 +1047,8 @@ func (b *Bitfinex) SendAuthenticatedHTTPRequest(method, path string, params map[ result, true, true, - b.Verbose) + b.Verbose, + b.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/bitflyer/bitflyer.go b/exchanges/bitflyer/bitflyer.go index 3a4b6e7a..b4e68583 100644 --- a/exchanges/bitflyer/bitflyer.go +++ b/exchanges/bitflyer/bitflyer.go @@ -114,6 +114,7 @@ func (b *Bitflyer) Setup(exch *config.ExchangeConfig) { b.SetHTTPClientUserAgent(exch.HTTPUserAgent) b.RESTPollingDelay = exch.RESTPollingDelay b.Verbose = exch.Verbose + b.HTTPDebugging = exch.HTTPDebugging b.Websocket.SetWsStatusAndConnection(exch.Websocket) b.BaseCurrencies = exch.BaseCurrencies b.AvailablePairs = exch.AvailablePairs @@ -378,7 +379,7 @@ func (b *Bitflyer) GetTradingCommission() { // SendHTTPRequest sends an unauthenticated request func (b *Bitflyer) SendHTTPRequest(path string, result interface{}) error { - return b.SendPayload(http.MethodGet, path, nil, nil, result, false, false, b.Verbose) + return b.SendPayload(http.MethodGet, path, nil, nil, result, false, false, b.Verbose, b.HTTPDebugging) } // SendAuthHTTPRequest sends an authenticated HTTP request diff --git a/exchanges/bithumb/bithumb.go b/exchanges/bithumb/bithumb.go index ae903215..f9c87f9d 100644 --- a/exchanges/bithumb/bithumb.go +++ b/exchanges/bithumb/bithumb.go @@ -96,6 +96,7 @@ func (b *Bithumb) Setup(exch *config.ExchangeConfig) { b.SetHTTPClientUserAgent(exch.HTTPUserAgent) b.RESTPollingDelay = exch.RESTPollingDelay b.Verbose = exch.Verbose + b.HTTPDebugging = exch.HTTPDebugging b.Websocket.SetWsStatusAndConnection(exch.Websocket) b.BaseCurrencies = exch.BaseCurrencies b.AvailablePairs = exch.AvailablePairs @@ -543,7 +544,7 @@ func (b *Bithumb) MarketSellOrder(currency string, units float64) (MarketSell, e // SendHTTPRequest sends an unauthenticated HTTP request func (b *Bithumb) SendHTTPRequest(path string, result interface{}) error { - return b.SendPayload(http.MethodGet, path, nil, nil, result, false, false, b.Verbose) + return b.SendPayload(http.MethodGet, path, nil, nil, result, false, false, b.Verbose, b.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an authenticated HTTP request to bithumb @@ -586,7 +587,8 @@ func (b *Bithumb) SendAuthenticatedHTTPRequest(path string, params url.Values, r &intermediary, true, true, - b.Verbose) + b.Verbose, + b.HTTPDebugging) if err != nil { return err } diff --git a/exchanges/bitmex/bitmex.go b/exchanges/bitmex/bitmex.go index 4b493f24..54558d48 100644 --- a/exchanges/bitmex/bitmex.go +++ b/exchanges/bitmex/bitmex.go @@ -148,6 +148,7 @@ func (b *Bitmex) Setup(exch *config.ExchangeConfig) { b.SetAPIKeys(exch.APIKey, exch.APISecret, "", false) b.RESTPollingDelay = exch.RESTPollingDelay b.Verbose = exch.Verbose + b.HTTPDebugging = exch.HTTPDebugging b.Websocket.SetWsStatusAndConnection(exch.Websocket) b.BaseCurrencies = exch.BaseCurrencies b.AvailablePairs = exch.AvailablePairs @@ -850,14 +851,14 @@ func (b *Bitmex) SendHTTPRequest(path string, params Parameter, result interface if err != nil { return err } - err = b.SendPayload(http.MethodGet, encodedPath, nil, nil, &respCheck, false, false, b.Verbose) + err = b.SendPayload(http.MethodGet, encodedPath, nil, nil, &respCheck, false, false, b.Verbose, b.HTTPDebugging) if err != nil { return err } return b.CaptureError(respCheck, result) } } - err := b.SendPayload(http.MethodGet, path, nil, nil, &respCheck, false, false, b.Verbose) + err := b.SendPayload(http.MethodGet, path, nil, nil, &respCheck, false, false, b.Verbose, b.HTTPDebugging) if err != nil { return err } @@ -908,7 +909,8 @@ func (b *Bitmex) SendAuthenticatedHTTPRequest(verb, path string, params Paramete &respCheck, true, false, - b.Verbose) + b.Verbose, + b.HTTPDebugging) if err != nil { return err } diff --git a/exchanges/bitstamp/bitstamp.go b/exchanges/bitstamp/bitstamp.go index 2712024b..8c9d5944 100644 --- a/exchanges/bitstamp/bitstamp.go +++ b/exchanges/bitstamp/bitstamp.go @@ -103,6 +103,7 @@ func (b *Bitstamp) Setup(exch *config.ExchangeConfig) { b.SetHTTPClientUserAgent(exch.HTTPUserAgent) b.RESTPollingDelay = exch.RESTPollingDelay b.Verbose = exch.Verbose + b.HTTPDebugging = exch.HTTPDebugging b.Websocket.SetWsStatusAndConnection(exch.Websocket) b.BaseCurrencies = exch.BaseCurrencies b.AvailablePairs = exch.AvailablePairs @@ -645,7 +646,7 @@ func (b *Bitstamp) TransferAccountBalance(amount float64, currency, subAccount s // SendHTTPRequest sends an unauthenticated HTTP request func (b *Bitstamp) SendHTTPRequest(path string, result interface{}) error { - return b.SendPayload(http.MethodGet, path, nil, nil, result, false, false, b.Verbose) + return b.SendPayload(http.MethodGet, path, nil, nil, result, false, false, b.Verbose, b.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an authenticated request @@ -687,7 +688,7 @@ func (b *Bitstamp) SendAuthenticatedHTTPRequest(path string, v2 bool, values url Error string `json:"error"` }{} - err := b.SendPayload(http.MethodPost, path, headers, readerValues, &interim, true, true, b.Verbose) + err := b.SendPayload(http.MethodPost, path, headers, readerValues, &interim, true, true, b.Verbose, b.HTTPDebugging) if err != nil { return err } diff --git a/exchanges/bittrex/bittrex.go b/exchanges/bittrex/bittrex.go index d5139869..68a835a7 100644 --- a/exchanges/bittrex/bittrex.go +++ b/exchanges/bittrex/bittrex.go @@ -100,6 +100,7 @@ func (b *Bittrex) Setup(exch *config.ExchangeConfig) { b.SetHTTPClientUserAgent(exch.HTTPUserAgent) b.RESTPollingDelay = exch.RESTPollingDelay b.Verbose = exch.Verbose + b.HTTPDebugging = exch.HTTPDebugging b.BaseCurrencies = exch.BaseCurrencies b.AvailablePairs = exch.AvailablePairs b.EnabledPairs = exch.EnabledPairs @@ -493,7 +494,7 @@ func (b *Bittrex) GetDepositHistory(currency string) (WithdrawalHistory, error) // SendHTTPRequest sends an unauthenticated HTTP request func (b *Bittrex) SendHTTPRequest(path string, result interface{}) error { - return b.SendPayload(http.MethodGet, path, nil, nil, result, false, false, b.Verbose) + return b.SendPayload(http.MethodGet, path, nil, nil, result, false, false, b.Verbose, b.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an authenticated http request to a desired @@ -514,7 +515,7 @@ func (b *Bittrex) SendAuthenticatedHTTPRequest(path string, values url.Values, r headers := make(map[string]string) headers["apisign"] = common.HexEncodeToString(hmac) - return b.SendPayload(http.MethodGet, rawQuery, headers, nil, result, true, true, b.Verbose) + return b.SendPayload(http.MethodGet, rawQuery, headers, nil, result, true, true, b.Verbose, b.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/btcc/btcc.go b/exchanges/btcc/btcc.go index a0a25a0c..d083d648 100644 --- a/exchanges/btcc/btcc.go +++ b/exchanges/btcc/btcc.go @@ -60,6 +60,7 @@ func (b *BTCC) Setup(exch *config.ExchangeConfig) { b.SetHTTPClientUserAgent(exch.HTTPUserAgent) b.RESTPollingDelay = exch.RESTPollingDelay b.Verbose = exch.Verbose + b.HTTPDebugging = exch.HTTPDebugging b.Websocket.SetWsStatusAndConnection(exch.Websocket) b.BaseCurrencies = exch.BaseCurrencies b.AvailablePairs = exch.AvailablePairs diff --git a/exchanges/btcmarkets/btcmarkets.go b/exchanges/btcmarkets/btcmarkets.go index 42bb2505..b70e4c52 100644 --- a/exchanges/btcmarkets/btcmarkets.go +++ b/exchanges/btcmarkets/btcmarkets.go @@ -89,6 +89,7 @@ func (b *BTCMarkets) Setup(exch *config.ExchangeConfig) { b.SetHTTPClientUserAgent(exch.HTTPUserAgent) b.RESTPollingDelay = exch.RESTPollingDelay b.Verbose = exch.Verbose + b.HTTPDebugging = exch.HTTPDebugging b.BaseCurrencies = exch.BaseCurrencies b.AvailablePairs = exch.AvailablePairs b.EnabledPairs = exch.EnabledPairs @@ -431,7 +432,7 @@ func (b *BTCMarkets) WithdrawAUD(accountName, accountNumber, bankName, bsbNumber // SendHTTPRequest sends an unauthenticated HTTP request func (b *BTCMarkets) SendHTTPRequest(path string, result interface{}) error { - return b.SendPayload(http.MethodGet, path, nil, nil, result, false, false, b.Verbose) + return b.SendPayload(http.MethodGet, path, nil, nil, result, false, false, b.Verbose, b.HTTPDebugging) } // SendAuthenticatedRequest sends an authenticated HTTP request @@ -481,7 +482,8 @@ func (b *BTCMarkets) SendAuthenticatedRequest(reqType, path string, data, result result, true, true, - b.Verbose) + b.Verbose, + b.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/btse/btse.go b/exchanges/btse/btse.go index a0426300..80a620c9 100644 --- a/exchanges/btse/btse.go +++ b/exchanges/btse/btse.go @@ -252,7 +252,7 @@ func (b *BTSE) GetFills(orderID, productID, before, after, limit string) (*Fille // SendHTTPRequest sends an HTTP request to the desired endpoint func (b *BTSE) SendHTTPRequest(method, endpoint string, result interface{}) error { p := fmt.Sprintf("%s/%s", btseAPIURL, endpoint) - return b.SendPayload(method, p, nil, nil, &result, false, false, b.Verbose) + return b.SendPayload(method, p, nil, nil, &result, false, false, b.Verbose, b.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an authenticated HTTP request to the desired endpoint @@ -278,7 +278,7 @@ func (b *BTSE) SendAuthenticatedHTTPRequest(method, endpoint string, req map[str log.Debugf("Sending %s request to URL %s with params %s\n", method, p, string(payload)) } return b.SendPayload(method, p, headers, strings.NewReader(string(payload)), - &result, true, false, b.Verbose) + &result, true, false, b.Verbose, b.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/coinbasepro/coinbasepro.go b/exchanges/coinbasepro/coinbasepro.go index 5222c2e3..e6518d77 100644 --- a/exchanges/coinbasepro/coinbasepro.go +++ b/exchanges/coinbasepro/coinbasepro.go @@ -103,6 +103,7 @@ func (c *CoinbasePro) Setup(exch *config.ExchangeConfig) { c.SetHTTPClientUserAgent(exch.HTTPUserAgent) c.RESTPollingDelay = exch.RESTPollingDelay c.Verbose = exch.Verbose + c.HTTPDebugging = exch.HTTPDebugging c.Websocket.SetWsStatusAndConnection(exch.Websocket) c.BaseCurrencies = exch.BaseCurrencies c.AvailablePairs = exch.AvailablePairs @@ -792,7 +793,7 @@ func (c *CoinbasePro) GetTrailingVolume() ([]Volume, error) { // SendHTTPRequest sends an unauthenticated HTTP request func (c *CoinbasePro) SendHTTPRequest(path string, result interface{}) error { - return c.SendPayload(http.MethodGet, path, nil, nil, result, false, false, c.Verbose) + return c.SendPayload(http.MethodGet, path, nil, nil, result, false, false, c.Verbose, c.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an authenticated HTTP reque @@ -832,7 +833,8 @@ func (c *CoinbasePro) SendAuthenticatedHTTPRequest(method, path string, params m result, true, true, - c.Verbose) + c.Verbose, + c.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/coinut/coinut.go b/exchanges/coinut/coinut.go index fcfb3412..c67612f8 100644 --- a/exchanges/coinut/coinut.go +++ b/exchanges/coinut/coinut.go @@ -92,6 +92,7 @@ func (c *COINUT) Setup(exch *config.ExchangeConfig) { c.SetHTTPClientUserAgent(exch.HTTPUserAgent) c.RESTPollingDelay = exch.RESTPollingDelay c.Verbose = exch.Verbose + c.HTTPDebugging = exch.HTTPDebugging c.Websocket.SetWsStatusAndConnection(exch.Websocket) c.BaseCurrencies = exch.BaseCurrencies c.AvailablePairs = exch.AvailablePairs @@ -371,7 +372,9 @@ func (c *COINUT) SendHTTPRequest(apiRequest string, params map[string]interface{ &rawMsg, authenticated, true, - c.Verbose) + c.Verbose, + c.HTTPDebugging, + ) if err != nil { return err } diff --git a/exchanges/exchange.go b/exchanges/exchange.go index 9bdebd0b..4902bf5c 100644 --- a/exchanges/exchange.go +++ b/exchanges/exchange.go @@ -271,6 +271,7 @@ type Base struct { SupportsRESTTickerBatching bool HTTPTimeout time.Duration HTTPUserAgent string + HTTPDebugging bool WebsocketURL string APIUrl string APIUrlDefault string diff --git a/exchanges/exmo/exmo.go b/exchanges/exmo/exmo.go index 10d59e60..06b6db70 100644 --- a/exchanges/exmo/exmo.go +++ b/exchanges/exmo/exmo.go @@ -82,6 +82,7 @@ func (e *EXMO) Setup(exch *config.ExchangeConfig) { e.SetEnabled(false) } else { e.Enabled = true + e.HTTPDebugging = exch.HTTPDebugging e.AuthenticatedAPISupport = exch.AuthenticatedAPISupport e.SetAPIKeys(exch.APIKey, exch.APISecret, "", false) e.SetHTTPClientTimeout(exch.HTTPTimeout) @@ -371,7 +372,7 @@ func (e *EXMO) GetWalletHistory(date int64) (WalletHistory, error) { // SendHTTPRequest sends an unauthenticated HTTP request func (e *EXMO) SendHTTPRequest(path string, result interface{}) error { - return e.SendPayload(http.MethodGet, path, nil, nil, result, false, false, e.Verbose) + return e.SendPayload(http.MethodGet, path, nil, nil, result, false, false, e.Verbose, e.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an authenticated HTTP request @@ -410,7 +411,8 @@ func (e *EXMO) SendAuthenticatedHTTPRequest(method, endpoint string, vals url.Va result, true, true, - e.Verbose) + e.Verbose, + e.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/gateio/gateio.go b/exchanges/gateio/gateio.go index a972951e..f3743b8e 100644 --- a/exchanges/gateio/gateio.go +++ b/exchanges/gateio/gateio.go @@ -98,6 +98,7 @@ func (g *Gateio) Setup(exch *config.ExchangeConfig) { g.AvailablePairs = exch.AvailablePairs g.EnabledPairs = exch.EnabledPairs g.WebsocketURL = gateioWebsocketEndpoint + g.HTTPDebugging = exch.HTTPDebugging err := g.SetCurrencyPairFormat() if err != nil { log.Fatal(err) @@ -392,7 +393,7 @@ func (g *Gateio) CancelExistingOrder(orderID int64, symbol string) (bool, error) // SendHTTPRequest sends an unauthenticated HTTP request func (g *Gateio) SendHTTPRequest(path string, result interface{}) error { - return g.SendPayload(http.MethodGet, path, nil, nil, result, false, false, g.Verbose) + return g.SendPayload(http.MethodGet, path, nil, nil, result, false, false, g.Verbose, g.HTTPDebugging) } // CancelAllExistingOrders all orders for a given symbol and side @@ -490,7 +491,8 @@ func (g *Gateio) SendAuthenticatedHTTPRequest(method, endpoint, param string, re &intermidiary, true, false, - g.Verbose) + g.Verbose, + g.HTTPDebugging) if err != nil { return err } diff --git a/exchanges/gemini/gemini.go b/exchanges/gemini/gemini.go index c625b4ce..6b9ac2e1 100644 --- a/exchanges/gemini/gemini.go +++ b/exchanges/gemini/gemini.go @@ -138,6 +138,7 @@ func (g *Gemini) Setup(exch *config.ExchangeConfig) { g.SetHTTPClientUserAgent(exch.HTTPUserAgent) g.RESTPollingDelay = exch.RESTPollingDelay g.Verbose = exch.Verbose + g.HTTPDebugging = exch.HTTPDebugging g.BaseCurrencies = exch.BaseCurrencies g.AvailablePairs = exch.AvailablePairs g.EnabledPairs = exch.EnabledPairs @@ -490,7 +491,7 @@ func (g *Gemini) PostHeartbeat() (string, error) { // SendHTTPRequest sends an unauthenticated request func (g *Gemini) SendHTTPRequest(path string, result interface{}) error { - return g.SendPayload(http.MethodGet, path, nil, nil, result, false, false, g.Verbose) + return g.SendPayload(http.MethodGet, path, nil, nil, result, false, false, g.Verbose, g.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an authenticated HTTP request to the @@ -528,7 +529,7 @@ func (g *Gemini) SendAuthenticatedHTTPRequest(method, path string, params map[st headers["X-GEMINI-SIGNATURE"] = common.HexEncodeToString(hmac) headers["Cache-Control"] = "no-cache" - return g.SendPayload(method, g.APIUrl+"/v1/"+path, headers, strings.NewReader(""), result, true, false, g.Verbose) + return g.SendPayload(method, g.APIUrl+"/v1/"+path, headers, strings.NewReader(""), result, true, false, g.Verbose, g.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/hitbtc/hitbtc.go b/exchanges/hitbtc/hitbtc.go index 09be9548..e50a090b 100644 --- a/exchanges/hitbtc/hitbtc.go +++ b/exchanges/hitbtc/hitbtc.go @@ -95,6 +95,7 @@ func (h *HitBTC) Setup(exch *config.ExchangeConfig) { h.SetHTTPClientUserAgent(exch.HTTPUserAgent) h.RESTPollingDelay = exch.RESTPollingDelay // Max 60000ms h.Verbose = exch.Verbose + h.HTTPDebugging = exch.HTTPDebugging h.Websocket.SetWsStatusAndConnection(exch.Websocket) h.BaseCurrencies = exch.BaseCurrencies h.AvailablePairs = exch.AvailablePairs @@ -591,7 +592,7 @@ func (h *HitBTC) TransferBalance(currency, from, to string, amount float64) (boo // SendHTTPRequest sends an unauthenticated HTTP request func (h *HitBTC) SendHTTPRequest(path string, result interface{}) error { - return h.SendPayload(http.MethodGet, path, nil, nil, result, false, false, h.Verbose) + return h.SendPayload(http.MethodGet, path, nil, nil, result, false, false, h.Verbose, h.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an authenticated http request @@ -612,7 +613,8 @@ func (h *HitBTC) SendAuthenticatedHTTPRequest(method, endpoint string, values ur result, true, false, - h.Verbose) + h.Verbose, + h.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/huobi/huobi.go b/exchanges/huobi/huobi.go index badef447..091a9a24 100644 --- a/exchanges/huobi/huobi.go +++ b/exchanges/huobi/huobi.go @@ -112,6 +112,7 @@ func (h *HUOBI) Setup(exch *config.ExchangeConfig) { h.SetHTTPClientUserAgent(exch.HTTPUserAgent) h.RESTPollingDelay = exch.RESTPollingDelay h.Verbose = exch.Verbose + h.HTTPDebugging = exch.HTTPDebugging h.Websocket.SetWsStatusAndConnection(exch.Websocket) h.BaseCurrencies = exch.BaseCurrencies h.AvailablePairs = exch.AvailablePairs @@ -831,7 +832,7 @@ func (h *HUOBI) CancelWithdraw(withdrawID int64) (int64, error) { // SendHTTPRequest sends an unauthenticated HTTP request func (h *HUOBI) SendHTTPRequest(path string, result interface{}) error { - return h.SendPayload(http.MethodGet, path, nil, nil, result, false, false, h.Verbose) + return h.SendPayload(http.MethodGet, path, nil, nil, result, false, false, h.Verbose, h.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends authenticated requests to the HUOBI API @@ -908,7 +909,7 @@ func (h *HUOBI) SendAuthenticatedHTTPRequest(method, endpoint string, values url body = encoded } - return h.SendPayload(method, urlPath, headers, bytes.NewReader(body), result, true, false, h.Verbose) + return h.SendPayload(method, urlPath, headers, bytes.NewReader(body), result, true, false, h.Verbose, h.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/huobihadax/huobihadax.go b/exchanges/huobihadax/huobihadax.go index 3d0ba8a5..192748cc 100644 --- a/exchanges/huobihadax/huobihadax.go +++ b/exchanges/huobihadax/huobihadax.go @@ -107,6 +107,7 @@ func (h *HUOBIHADAX) Setup(exch *config.ExchangeConfig) { h.SetHTTPClientUserAgent(exch.HTTPUserAgent) h.RESTPollingDelay = exch.RESTPollingDelay h.Verbose = exch.Verbose + h.HTTPDebugging = exch.HTTPDebugging h.BaseCurrencies = exch.BaseCurrencies h.AvailablePairs = exch.AvailablePairs h.EnabledPairs = exch.EnabledPairs @@ -826,7 +827,7 @@ func (h *HUOBIHADAX) CancelWithdraw(withdrawID int64) (int64, error) { // SendHTTPRequest sends an unauthenticated HTTP request func (h *HUOBIHADAX) SendHTTPRequest(path string, result interface{}) error { - return h.SendPayload(http.MethodGet, path, nil, nil, result, false, false, h.Verbose) + return h.SendPayload(http.MethodGet, path, nil, nil, result, false, false, h.Verbose, h.HTTPDebugging) } // SendAuthenticatedHTTPPostRequest sends authenticated requests to the HUOBI API @@ -853,7 +854,7 @@ func (h *HUOBIHADAX) SendAuthenticatedHTTPPostRequest(method, endpoint, postBody signatureParams.Set("Signature", common.Base64Encode(hmac)) urlPath := common.EncodeURLValues(fmt.Sprintf("%s%s", h.APIUrl, endpoint), signatureParams) - return h.SendPayload(method, urlPath, headers, bytes.NewBufferString(postBodyValues), result, true, false, h.Verbose) + return h.SendPayload(method, urlPath, headers, bytes.NewBufferString(postBodyValues), result, true, false, h.Verbose, h.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends authenticated requests to the HUOBI API @@ -879,7 +880,7 @@ func (h *HUOBIHADAX) SendAuthenticatedHTTPRequest(method, endpoint string, value urlPath := common.EncodeURLValues(fmt.Sprintf("%s%s", h.APIUrl, endpoint), values) - return h.SendPayload(method, urlPath, headers, bytes.NewBufferString(""), result, true, false, h.Verbose) + return h.SendPayload(method, urlPath, headers, bytes.NewBufferString(""), result, true, false, h.Verbose, h.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/itbit/itbit.go b/exchanges/itbit/itbit.go index f9bf026e..d1bbf83f 100644 --- a/exchanges/itbit/itbit.go +++ b/exchanges/itbit/itbit.go @@ -80,6 +80,7 @@ func (i *ItBit) Setup(exch *config.ExchangeConfig) { i.SetHTTPClientUserAgent(exch.HTTPUserAgent) i.RESTPollingDelay = exch.RESTPollingDelay i.Verbose = exch.Verbose + i.HTTPDebugging = exch.HTTPDebugging i.BaseCurrencies = exch.BaseCurrencies i.AvailablePairs = exch.AvailablePairs i.EnabledPairs = exch.EnabledPairs @@ -343,7 +344,7 @@ func (i *ItBit) WalletTransfer(walletID, sourceWallet, destWallet string, amount // SendHTTPRequest sends an unauthenticated HTTP request func (i *ItBit) SendHTTPRequest(path string, result interface{}) error { - return i.SendPayload(http.MethodGet, path, nil, nil, result, false, false, i.Verbose) + return i.SendPayload(http.MethodGet, path, nil, nil, result, false, false, i.Verbose, i.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an authenticated request to itBit @@ -403,7 +404,7 @@ func (i *ItBit) SendAuthenticatedHTTPRequest(method, path string, params map[str RequestID string `json:"requestId"` }{} - err = i.SendPayload(method, urlPath, headers, bytes.NewBuffer(PayloadJSON), &intermediary, true, true, i.Verbose) + err = i.SendPayload(method, urlPath, headers, bytes.NewBuffer(PayloadJSON), &intermediary, true, true, i.Verbose, i.HTTPDebugging) if err != nil { return err } diff --git a/exchanges/kraken/kraken.go b/exchanges/kraken/kraken.go index fdf7b714..fed15ee5 100644 --- a/exchanges/kraken/kraken.go +++ b/exchanges/kraken/kraken.go @@ -110,6 +110,7 @@ func (k *Kraken) Setup(exch *config.ExchangeConfig) { k.SetHTTPClientUserAgent(exch.HTTPUserAgent) k.RESTPollingDelay = exch.RESTPollingDelay k.Verbose = exch.Verbose + k.HTTPDebugging = exch.HTTPDebugging k.Websocket.SetWsStatusAndConnection(exch.Websocket) k.BaseCurrencies = exch.BaseCurrencies k.AvailablePairs = exch.AvailablePairs @@ -926,7 +927,7 @@ func GetError(apiErrors []string) error { // SendHTTPRequest sends an unauthenticated HTTP requests func (k *Kraken) SendHTTPRequest(path string, result interface{}) error { - return k.SendPayload(http.MethodGet, path, nil, nil, result, false, false, k.Verbose) + return k.SendPayload(http.MethodGet, path, nil, nil, result, false, false, k.Verbose, k.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an authenticated HTTP request @@ -969,7 +970,8 @@ func (k *Kraken) SendAuthenticatedHTTPRequest(method string, params url.Values, result, true, true, - k.Verbose) + k.Verbose, + k.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/lakebtc/lakebtc.go b/exchanges/lakebtc/lakebtc.go index 96ad6c7b..a220b46a 100644 --- a/exchanges/lakebtc/lakebtc.go +++ b/exchanges/lakebtc/lakebtc.go @@ -80,6 +80,7 @@ func (l *LakeBTC) Setup(exch *config.ExchangeConfig) { l.SetHTTPClientUserAgent(exch.HTTPUserAgent) l.RESTPollingDelay = exch.RESTPollingDelay l.Verbose = exch.Verbose + l.HTTPDebugging = exch.HTTPDebugging l.BaseCurrencies = exch.BaseCurrencies l.AvailablePairs = exch.AvailablePairs l.EnabledPairs = exch.EnabledPairs @@ -334,7 +335,7 @@ func (l *LakeBTC) CreateWithdraw(amount float64, accountID string) (Withdraw, er // SendHTTPRequest sends an unauthenticated http request func (l *LakeBTC) SendHTTPRequest(path string, result interface{}) error { - return l.SendPayload(http.MethodGet, path, nil, nil, result, false, false, l.Verbose) + return l.SendPayload(http.MethodGet, path, nil, nil, result, false, false, l.Verbose, l.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an autheticated HTTP request to a LakeBTC @@ -367,7 +368,7 @@ func (l *LakeBTC) SendAuthenticatedHTTPRequest(method, params string, result int headers["Authorization"] = "Basic " + common.Base64Encode([]byte(l.APIKey+":"+common.HexEncodeToString(hmac))) headers["Content-Type"] = "application/json-rpc" - return l.SendPayload(http.MethodPost, l.APIUrl, headers, strings.NewReader(string(data)), result, true, true, l.Verbose) + return l.SendPayload(http.MethodPost, l.APIUrl, headers, strings.NewReader(string(data)), result, true, true, l.Verbose, l.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/localbitcoins/localbitcoins.go b/exchanges/localbitcoins/localbitcoins.go index 860743a4..2aaaef85 100644 --- a/exchanges/localbitcoins/localbitcoins.go +++ b/exchanges/localbitcoins/localbitcoins.go @@ -149,6 +149,7 @@ func (l *LocalBitcoins) Setup(exch *config.ExchangeConfig) { l.SetHTTPClientUserAgent(exch.HTTPUserAgent) l.RESTPollingDelay = exch.RESTPollingDelay l.Verbose = exch.Verbose + l.HTTPDebugging = exch.HTTPDebugging l.BaseCurrencies = exch.BaseCurrencies l.AvailablePairs = exch.AvailablePairs l.EnabledPairs = exch.EnabledPairs @@ -726,7 +727,7 @@ func (l *LocalBitcoins) GetOrderbook(currency string) (Orderbook, error) { // SendHTTPRequest sends an unauthenticated HTTP request func (l *LocalBitcoins) SendHTTPRequest(path string, result interface{}) error { - return l.SendPayload(http.MethodGet, path, nil, nil, result, false, false, l.Verbose) + return l.SendPayload(http.MethodGet, path, nil, nil, result, false, false, l.Verbose, l.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an authenticated HTTP request to @@ -756,7 +757,7 @@ func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, params path += "?" + encoded } - return l.SendPayload(method, l.APIUrl+path, headers, strings.NewReader(encoded), result, true, true, l.Verbose) + return l.SendPayload(method, l.APIUrl+path, headers, strings.NewReader(encoded), result, true, true, l.Verbose, l.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/okgroup/okgroup.go b/exchanges/okgroup/okgroup.go index 563164ee..0a0c9605 100644 --- a/exchanges/okgroup/okgroup.go +++ b/exchanges/okgroup/okgroup.go @@ -115,6 +115,7 @@ func (o *OKGroup) Setup(exch *config.ExchangeConfig) { o.SetHTTPClientUserAgent(exch.HTTPUserAgent) o.RESTPollingDelay = exch.RESTPollingDelay o.Verbose = exch.Verbose + o.HTTPDebugging = exch.HTTPDebugging o.Websocket.SetWsStatusAndConnection(exch.Websocket) o.BaseCurrencies = exch.BaseCurrencies o.AvailablePairs = exch.AvailablePairs @@ -623,7 +624,7 @@ func (o *OKGroup) SendHTTPRequest(httpMethod, requestType, requestPath string, d errCap := errCapFormat{} errCap.Result = true - err = o.SendPayload(strings.ToUpper(httpMethod), path, headers, bytes.NewBuffer(payload), &intermediary, authenticated, false, o.Verbose) + err = o.SendPayload(strings.ToUpper(httpMethod), path, headers, bytes.NewBuffer(payload), &intermediary, authenticated, false, o.Verbose, o.HTTPDebugging) if err != nil { return err } diff --git a/exchanges/poloniex/poloniex.go b/exchanges/poloniex/poloniex.go index d3c9b88a..e2e1f1b9 100644 --- a/exchanges/poloniex/poloniex.go +++ b/exchanges/poloniex/poloniex.go @@ -104,6 +104,7 @@ func (p *Poloniex) Setup(exch *config.ExchangeConfig) { p.SetHTTPClientUserAgent(exch.HTTPUserAgent) p.RESTPollingDelay = exch.RESTPollingDelay p.Verbose = exch.Verbose + p.HTTPDebugging = exch.HTTPDebugging p.Websocket.SetWsStatusAndConnection(exch.Websocket) p.BaseCurrencies = exch.BaseCurrencies p.AvailablePairs = exch.AvailablePairs @@ -865,7 +866,8 @@ func (p *Poloniex) SendHTTPRequest(path string, result interface{}) error { result, false, false, - p.Verbose) + p.Verbose, + p.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an authenticated HTTP request @@ -898,7 +900,8 @@ func (p *Poloniex) SendAuthenticatedHTTPRequest(method, endpoint string, values result, true, true, - p.Verbose) + p.Verbose, + p.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/request/request.go b/exchanges/request/request.go index fa37c015..ff25174e 100644 --- a/exchanges/request/request.go +++ b/exchanges/request/request.go @@ -8,6 +8,7 @@ import ( "io/ioutil" "net" "net/http" + "net/http/httputil" "net/url" "sync" "time" @@ -59,15 +60,16 @@ type JobResult struct { // Job holds a request job type Job struct { - Request *http.Request - Method string - Path string - Headers map[string]string - Body io.Reader - Result interface{} - JobResult chan *JobResult - AuthRequest bool - Verbose bool + Request *http.Request + Method string + Path string + Headers map[string]string + Body io.Reader + Result interface{} + JobResult chan *JobResult + AuthRequest bool + Verbose bool + HTTPDebugging bool } // NewRateLimit creates a new RateLimit @@ -262,7 +264,7 @@ func (r *Requester) checkRequest(method, path string, body io.Reader, headers ma } // DoRequest performs a HTTP/HTTPS request with the supplied params -func (r *Requester) DoRequest(req *http.Request, path string, body io.Reader, result interface{}, authRequest, verbose bool) error { +func (r *Requester) DoRequest(req *http.Request, path string, body io.Reader, result interface{}, authRequest, verbose, httpDebug bool) error { if verbose { log.Debugf("%s exchange request path: %s requires rate limiter: %v", r.Name, path, r.RequiresRateLimiter()) for k, d := range req.Header { @@ -337,10 +339,21 @@ func (r *Requester) DoRequest(req *http.Request, path string, body io.Reader, re return err } + if httpDebug { + dump, err := httputil.DumpResponse(resp, false) + if err != nil { + log.Errorf("DumpResponse invalid response: %v:", err) + } + log.Debugf("DumpResponse Headers (%v):\n%s", path, dump) + log.Debugf("DumpResponse Body (%v):\n %s", path, string(contents)) + } + resp.Body.Close() if verbose { log.Debugf("HTTP status: %s, Code: %v", resp.Status, resp.StatusCode) - log.Debugf("%s exchange raw response: %s", r.Name, string(contents)) + if !httpDebug { + log.Debugf("%s exchange raw response: %s", r.Name, string(contents)) + } } if result != nil { @@ -359,7 +372,7 @@ func (r *Requester) worker() { if !r.IsRateLimited(x.AuthRequest) { r.IncrementRequests(x.AuthRequest) - err := r.DoRequest(x.Request, x.Path, x.Body, x.Result, x.AuthRequest, x.Verbose) + err := r.DoRequest(x.Request, x.Path, x.Body, x.Result, x.AuthRequest, x.Verbose, x.HTTPDebugging) x.JobResult <- &JobResult{ Error: err, Result: x.Result, @@ -383,7 +396,7 @@ func (r *Requester) worker() { log.Debugf("%s request. No longer rate limited! Doing request", r.Name) } - err := r.DoRequest(x.Request, x.Path, x.Body, x.Result, x.AuthRequest, x.Verbose) + err := r.DoRequest(x.Request, x.Path, x.Body, x.Result, x.AuthRequest, x.Verbose, x.HTTPDebugging) x.JobResult <- &JobResult{ Error: err, Result: x.Result, @@ -396,7 +409,7 @@ func (r *Requester) worker() { } // SendPayload handles sending HTTP/HTTPS requests -func (r *Requester) SendPayload(method, path string, headers map[string]string, body io.Reader, result interface{}, authRequest, nonceEnabled, verbose bool) error { +func (r *Requester) SendPayload(method, path string, headers map[string]string, body io.Reader, result interface{}, authRequest, nonceEnabled, verbose, httpDebugging bool) error { if !nonceEnabled { r.lock() } @@ -422,9 +435,17 @@ func (r *Requester) SendPayload(method, path string, headers map[string]string, return err } + if httpDebugging { + dump, err := httputil.DumpRequestOut(req, true) + if err != nil { + log.Errorf("DumpRequest invalid response %v:", err) + } + log.Debugf("DumpRequest:\n%s", dump) + } + if !r.RequiresRateLimiter() { r.unlock() - return r.DoRequest(req, path, body, result, authRequest, verbose) + return r.DoRequest(req, path, body, result, authRequest, verbose, httpDebugging) } if len(r.Jobs) == maxRequestJobs { @@ -443,15 +464,16 @@ func (r *Requester) SendPayload(method, path string, headers map[string]string, jobResult := make(chan *JobResult) newJob := Job{ - Request: req, - Method: method, - Path: path, - Headers: headers, - Body: body, - Result: result, - JobResult: jobResult, - AuthRequest: authRequest, - Verbose: verbose, + Request: req, + Method: method, + Path: path, + Headers: headers, + Body: body, + Result: result, + JobResult: jobResult, + AuthRequest: authRequest, + Verbose: verbose, + HTTPDebugging: httpDebugging, } if verbose { @@ -468,6 +490,7 @@ func (r *Requester) SendPayload(method, path string, headers map[string]string, if verbose { log.Debugf("%s request. Job complete.", r.Name) } + return resp.Error } diff --git a/exchanges/request/request_test.go b/exchanges/request/request_test.go index bf8f8901..6517965a 100644 --- a/exchanges/request/request_test.go +++ b/exchanges/request/request_test.go @@ -200,7 +200,7 @@ func TestCheckRequest(t *testing.T) { func TestDoRequest(t *testing.T) { var test = new(Requester) - err := test.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, false, false, true) + err := test.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, false, false, true, false) if err == nil { t.Fatal("not iniitalised") } @@ -211,17 +211,17 @@ func TestDoRequest(t *testing.T) { } r.Name = "bitfinex" - err = r.SendPayload("BLAH", "https://www.google.com", nil, nil, nil, false, false, true) + err = r.SendPayload("BLAH", "https://www.google.com", nil, nil, nil, false, false, true, false) if err == nil { t.Fatal("unexpected values") } - err = r.SendPayload(http.MethodGet, "", nil, nil, nil, false, false, true) + err = r.SendPayload(http.MethodGet, "", nil, nil, nil, false, false, true, false) if err == nil { t.Fatal("unexpected values") } - err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, false, false, true) + err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, false, false, true, false) if err != nil { t.Fatal("unexpected values") } @@ -233,7 +233,7 @@ func TestDoRequest(t *testing.T) { r.SetRateLimit(false, time.Second, 0) r.SetRateLimit(true, time.Second, 0) - err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, false, false, true) + err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, false, false, true, false) if err != nil { t.Fatal("unexpected values") } @@ -250,7 +250,7 @@ func TestDoRequest(t *testing.T) { t.Fatal("unexepcted values") } - err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, false, false, true) + err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, false, false, true, false) if err != nil { t.Fatal("unexpected values") } @@ -261,27 +261,27 @@ func TestDoRequest(t *testing.T) { t.Fatal("unexepcted values") } - err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, true, false, true) + err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, nil, true, false, true, false) if err != nil { t.Fatal("unexpected values") } var result interface{} - err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, result, false, false, true) + err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, result, false, false, true, false) if err != nil { t.Fatal(err) } headers := make(map[string]string) headers["content-type"] = "content/text" - err = r.SendPayload(http.MethodPost, "https://bitfinex.com", headers, nil, result, false, false, true) + err = r.SendPayload(http.MethodPost, "https://bitfinex.com", headers, nil, result, false, false, true, false) if err != nil { t.Fatal(err) } r.StartCycle() r.UnauthLimit.SetRequests(100) - err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, result, false, false, false) + err = r.SendPayload(http.MethodGet, "https://www.google.com", nil, nil, result, false, false, false, false) if err != nil { t.Fatal("unexpected values") } @@ -297,7 +297,7 @@ func TestDoRequest(t *testing.T) { } r.HTTPClient.Timeout = 1 * time.Second - err = r.SendPayload(http.MethodPost, "https://httpstat.us/200?sleep=20000", nil, nil, nil, false, false, true) + err = r.SendPayload(http.MethodPost, "https://httpstat.us/200?sleep=20000", nil, nil, nil, false, false, true, false) if err == nil { t.Fatal(err) } @@ -327,6 +327,6 @@ func BenchmarkRequestLockMech(b *testing.B) { var r = new(Requester) var meep interface{} for n := 0; n < b.N; n++ { - r.SendPayload(http.MethodGet, "127.0.0.1", nil, nil, &meep, false, false, false) + r.SendPayload(http.MethodGet, "127.0.0.1", nil, nil, &meep, false, false, false, false) } } diff --git a/exchanges/yobit/yobit.go b/exchanges/yobit/yobit.go index 9626b702..c25a739b 100644 --- a/exchanges/yobit/yobit.go +++ b/exchanges/yobit/yobit.go @@ -87,6 +87,7 @@ func (y *Yobit) Setup(exch *config.ExchangeConfig) { y.SetAPIKeys(exch.APIKey, exch.APISecret, "", false) y.RESTPollingDelay = exch.RESTPollingDelay y.Verbose = exch.Verbose + y.HTTPDebugging = exch.HTTPDebugging y.Websocket.SetWsStatusAndConnection(exch.Websocket) y.BaseCurrencies = exch.BaseCurrencies y.AvailablePairs = exch.AvailablePairs @@ -337,7 +338,8 @@ func (y *Yobit) SendHTTPRequest(path string, result interface{}) error { result, false, false, - y.Verbose) + y.Verbose, + y.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends an authenticated HTTP request to Yobit @@ -380,7 +382,8 @@ func (y *Yobit) SendAuthenticatedHTTPRequest(path string, params url.Values, res result, true, true, - y.Verbose) + y.Verbose, + y.HTTPDebugging) } // GetFee returns an estimate of fee based on type of transaction diff --git a/exchanges/zb/zb.go b/exchanges/zb/zb.go index 781a7ede..1e13230a 100644 --- a/exchanges/zb/zb.go +++ b/exchanges/zb/zb.go @@ -94,6 +94,7 @@ func (z *ZB) Setup(exch *config.ExchangeConfig) { z.SetHTTPClientUserAgent(exch.HTTPUserAgent) z.RESTPollingDelay = exch.RESTPollingDelay z.Verbose = exch.Verbose + z.HTTPDebugging = exch.HTTPDebugging z.Websocket.SetWsStatusAndConnection(exch.Websocket) z.BaseCurrencies = exch.BaseCurrencies z.AvailablePairs = exch.AvailablePairs @@ -361,7 +362,7 @@ func (z *ZB) GetCryptoAddress(currency currency.Code) (UserAddress, error) { // SendHTTPRequest sends an unauthenticated HTTP request func (z *ZB) SendHTTPRequest(path string, result interface{}) error { - return z.SendPayload(http.MethodGet, path, nil, nil, result, false, false, z.Verbose) + return z.SendPayload(http.MethodGet, path, nil, nil, result, false, false, z.Verbose, z.HTTPDebugging) } // SendAuthenticatedHTTPRequest sends authenticated requests to the zb API @@ -398,7 +399,8 @@ func (z *ZB) SendAuthenticatedHTTPRequest(httpMethod string, params url.Values, &intermediary, true, false, - z.Verbose) + z.Verbose, + z.HTTPDebugging) if err != nil { return err } diff --git a/testdata/configtest.json b/testdata/configtest.json index 3730c972..061104a4 100644 --- a/testdata/configtest.json +++ b/testdata/configtest.json @@ -171,6 +171,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -211,6 +212,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -251,6 +253,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -299,6 +302,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -341,6 +345,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -382,6 +387,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -422,6 +428,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -463,6 +470,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -502,6 +510,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -543,6 +552,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -583,6 +593,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -623,6 +634,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -665,6 +677,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -706,6 +719,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -747,6 +761,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -786,6 +801,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -826,6 +842,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -867,6 +884,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -908,6 +926,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -949,6 +968,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -990,6 +1010,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -1029,6 +1050,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -1068,6 +1090,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -1109,6 +1132,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -1150,6 +1174,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -1191,6 +1216,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -1234,6 +1260,7 @@ "restPollingDelay": 10, "httpTimeout": 15000000000, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret", @@ -1275,6 +1302,7 @@ "restPollingDelay": 10, "httpTimeout": 10, "httpUserAgent": "", + "httpDebugging": false, "authenticatedApiSupport": false, "apiKey": "Key", "apiSecret": "Secret",