mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-05 07:26:47 +00:00
Refactor Exchange code
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user