mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
Add httputil.DumpRequestOut & httputil.DumpResponse to SendPayload (#298)
* First pass adding DumpResponse * WIP * Added httpDebug flag to SendPayload * anx -> coinbase converted * HTTPDebug flag added to all exchanges * Updated Alphapoint: * reworded error message * Corrected itbit and huobihadax sendpayload * Removed setting of default value * don't return body for response as we already get this in verbose mode * body is now included based on verbose setting * WIP * Due to issues with DumpResponse and gzip decoding use raw response from exchange for body output Also adds gzip decoding back as bug fix for OK group exchange * removed additional new line * Added URL path to dumpbody display as well
This commit is contained in:
@@ -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"`
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -240,5 +240,6 @@ func (c *CurrencyLayer) SendHTTPRequest(endPoint string, values url.Values, resu
|
||||
&result,
|
||||
auth,
|
||||
false,
|
||||
c.Verbose)
|
||||
c.Verbose,
|
||||
false)
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -264,5 +264,6 @@ func (f *Fixer) SendOpenHTTPRequest(endpoint string, v url.Values, result interf
|
||||
result,
|
||||
auth,
|
||||
false,
|
||||
f.Verbose)
|
||||
f.Verbose,
|
||||
false)
|
||||
}
|
||||
|
||||
@@ -264,5 +264,6 @@ func (o *OXR) SendHTTPRequest(endpoint string, values url.Values, result interfa
|
||||
result,
|
||||
false,
|
||||
false,
|
||||
o.Verbose)
|
||||
o.Verbose,
|
||||
false)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -271,6 +271,7 @@ type Base struct {
|
||||
SupportsRESTTickerBatching bool
|
||||
HTTPTimeout time.Duration
|
||||
HTTPUserAgent string
|
||||
HTTPDebugging bool
|
||||
WebsocketURL string
|
||||
APIUrl string
|
||||
APIUrlDefault string
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
28
testdata/configtest.json
vendored
28
testdata/configtest.json
vendored
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user