Skip to content

Commit

Permalink
Config: Fix AuthenticatedAPISupport default values check (thrasher-co…
Browse files Browse the repository at this point in the history
…rp#306)

* Fixes issue where first if statement always gets hit

* fmtimport

* Slightly more granular checks for keys, secret keys and clientids

* Moves log warn and removes extra checks
  • Loading branch information
gloriousCode authored and thrasher- committed May 22, 2019
1 parent c082226 commit 7a4ffef
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,16 +799,22 @@ func (c *Config) CheckExchangeConfigValues() error {
return fmt.Errorf(ErrExchangeBaseCurrenciesEmpty, c.Exchanges[i].Name)
}
if c.Exchanges[i].AuthenticatedAPISupport { // non-fatal error
if c.Exchanges[i].APIKey == "" || c.Exchanges[i].APISecret == "" ||
c.Exchanges[i].APIKey == DefaultUnsetAPIKey ||
c.Exchanges[i].APISecret == DefaultUnsetAPISecret {
if c.Exchanges[i].APIKey == "" || c.Exchanges[i].APIKey == DefaultUnsetAPIKey {
c.Exchanges[i].AuthenticatedAPISupport = false
}

if (c.Exchanges[i].APISecret == "" || c.Exchanges[i].APISecret == DefaultUnsetAPISecret) &&
c.Exchanges[i].Name != "COINUT" {
c.Exchanges[i].AuthenticatedAPISupport = false
}

if (c.Exchanges[i].ClientID == "ClientID" || c.Exchanges[i].ClientID == "") &&
(c.Exchanges[i].Name == "ITBIT" || c.Exchanges[i].Name == "Bitstamp" || c.Exchanges[i].Name == "COINUT" || c.Exchanges[i].Name == "CoinbasePro") {
c.Exchanges[i].AuthenticatedAPISupport = false
}

if !c.Exchanges[i].AuthenticatedAPISupport {
log.Warnf(WarningExchangeAuthAPIDefaultOrEmptyValues, c.Exchanges[i].Name)
} else if c.Exchanges[i].Name == "ITBIT" || c.Exchanges[i].Name == "Bitstamp" || c.Exchanges[i].Name == "COINUT" || c.Exchanges[i].Name == "CoinbasePro" {
if c.Exchanges[i].ClientID == "" || c.Exchanges[i].ClientID == "ClientID" {
c.Exchanges[i].AuthenticatedAPISupport = false
log.Warnf(WarningExchangeAuthAPIDefaultOrEmptyValues, c.Exchanges[i].Name)
}
}
}
if !c.Exchanges[i].SupportsAutoPairUpdates {
Expand Down

0 comments on commit 7a4ffef

Please sign in to comment.