Refactor Exchange code

This commit is contained in:
Adrian Gallagher
2017-03-17 17:03:27 +11:00
parent ef59b4bcd5
commit bbe660b5f4
18 changed files with 55 additions and 395 deletions

View File

@@ -1,7 +1,14 @@
package exchange
import (
"log"
"time"
"github.com/thrasher-/gocryptotrader/common"
)
const (
WarningBase64DecryptSecretKeyFailed = "WARNING -- Exchange %s unable to base64 decode secret key.. Disabling Authenticated API support."
)
type ExchangeBase struct {
@@ -19,3 +26,33 @@ type ExchangeBase struct {
WebsocketURL string
APIUrl string
}
func (e *ExchangeBase) GetName() string {
return e.Name
}
func (e *ExchangeBase) GetEnabledCurrencies() []string {
return e.EnabledPairs
}
func (e *ExchangeBase) SetEnabled(enabled bool) {
e.Enabled = enabled
}
func (e *ExchangeBase) IsEnabled() bool {
return e.Enabled
}
func (e *ExchangeBase) SetAPIKeys(APIKey, APISecret, ClientID string, b64Decode bool) {
e.APIKey = APIKey
e.ClientID = ClientID
if b64Decode {
result, err := common.Base64Decode(APISecret)
if err != nil {
e.AuthenticatedAPISupport = false
log.Printf(WarningBase64DecryptSecretKeyFailed, e.Name)
}
e.APISecret = string(result)
} else {
e.APISecret = APISecret
}
}