Documentation
¶
Index ¶
- Constants
- Variables
- func ConfirmConfigJSON(file []byte, result interface{}) error
- func ConfirmECS(file []byte) bool
- func ConfirmSalt(file []byte) bool
- func DecryptConfigFile(configData, key []byte) ([]byte, error)
- func EncryptConfigFile(configData, key []byte) ([]byte, error)
- func GetFilePath(file string) (string, error)
- func PromptForConfigKey(initialSetup bool) ([]byte, error)
- func RemoveECS(file []byte) []byte
- type BankAccount
- type BankTransaction
- type CommunicationsConfig
- type Config
- func (c *Config) CheckClientBankAccounts() error
- func (c *Config) CheckCommunicationsConfig() error
- func (c *Config) CheckConfig() error
- func (c *Config) CheckCurrencyConfigValues() error
- func (c *Config) CheckExchangeConfigValues() error
- func (c *Config) CheckPairConsistency(exchName string) error
- func (c *Config) CheckWebserverConfigValues() error
- func (c *Config) CountEnabledExchanges() int
- func (c *Config) GetAllExchangeConfigs() []ExchangeConfig
- func (c *Config) GetAvailablePairs(exchName string) ([]pair.CurrencyPair, error)
- func (c *Config) GetClientBankAccounts(exchangeName string, targetCurrency string) (BankAccount, error)
- func (c *Config) GetCommunicationsConfig() CommunicationsConfig
- func (c *Config) GetConfigCurrencyPairFormat(exchName string) (*CurrencyPairFormatConfig, error)
- func (c *Config) GetCurrencyConfig() CurrencyConfig
- func (c *Config) GetCurrencyPairDisplayConfig() *CurrencyPairFormatConfig
- func (c *Config) GetDisabledExchanges() []string
- func (c *Config) GetEnabledExchanges() []string
- func (c *Config) GetEnabledPairs(exchName string) ([]pair.CurrencyPair, error)
- func (c *Config) GetExchangeBankAccounts(exchangeName string, depositingCurrency string) (BankAccount, error)
- func (c *Config) GetExchangeConfig(name string) (ExchangeConfig, error)
- func (c *Config) GetForexProviderConfig(name string) (base.Settings, error)
- func (c *Config) GetPrimaryForexProvider() string
- func (c *Config) GetRequestCurrencyPairFormat(exchName string) (*CurrencyPairFormatConfig, error)
- func (c *Config) LoadConfig(configPath string) error
- func (c *Config) PromptForConfigEncryption() bool
- func (c *Config) ReadConfig(configPath string) error
- func (c *Config) RetrieveConfigCurrencyPairs(enabledOnly bool) error
- func (c *Config) SaveConfig(configPath string) error
- func (c *Config) SupportsPair(exchName string, p pair.CurrencyPair) (bool, error)
- func (c *Config) UpdateClientBankAccounts(bankCfg BankAccount) error
- func (c *Config) UpdateCommunicationsConfig(config CommunicationsConfig)
- func (c *Config) UpdateConfig(configPath string, newCfg Config) error
- func (c *Config) UpdateExchangeBankAccounts(exchangeName string, bankCfg []BankAccount) error
- func (c *Config) UpdateExchangeConfig(e ExchangeConfig) error
- type CurrencyConfig
- type CurrencyPairFormatConfig
- type ExchangeConfig
- type Post
- type SMSContact
- type SMSGlobalConfig
- type SMTPConfig
- type SlackConfig
- type TelegramConfig
- type WebserverConfig
Constants ¶
const ( FXProviderFixer = "fixer" EncryptedConfigFile = "config.dat" ConfigFile = "config.json" ConfigTestFile = "../testdata/configtest.json" )
Constants declared here are filename strings and test strings
const ( ErrExchangeNameEmpty = "Exchange #%d in config: Exchange name is empty." ErrExchangeAvailablePairsEmpty = "Exchange %s: Available pairs is empty." ErrExchangeEnabledPairsEmpty = "Exchange %s: Enabled pairs is empty." ErrExchangeBaseCurrenciesEmpty = "Exchange %s: Base currencies is empty." ErrExchangeNotFound = "Exchange %s: Not found." ErrNoEnabledExchanges = "No Exchanges enabled." ErrCryptocurrenciesEmpty = "Cryptocurrencies variable is empty." ErrFailureOpeningConfig = "Fatal error opening %s file. Error: %s" ErrCheckingConfigValues = "Fatal error checking config values. Error: %s" ErrSavingConfigBytesMismatch = "Config file %q bytes comparison doesn't match, read %s expected %s." WarningSMSGlobalDefaultOrEmptyValues = "WARNING -- SMS Support disabled due to default or empty Username/Password values." WarningSSMSGlobalSMSContactDefaultOrEmptyValues = "WARNING -- SMS contact #%d Name/Number disabled due to default or empty values." WarningSSMSGlobalSMSNoContacts = "WARNING -- SMS Support disabled due to no enabled contacts." WarningWebserverCredentialValuesEmpty = "WARNING -- Webserver support disabled due to empty Username/Password values." WarningWebserverListenAddressInvalid = "WARNING -- Webserver support disabled due to invalid listen address." WarningWebserverRootWebFolderNotFound = "WARNING -- Webserver support disabled due to missing web folder." WarningExchangeAuthAPIDefaultOrEmptyValues = "WARNING -- Exchange %s: Authenticated API support disabled due to default/empty APIKey/Secret/ClientID values." WarningCurrencyExchangeProvider = "WARNING -- Currency exchange provider invalid valid. Reset to Fixer." WarningPairsLastUpdatedThresholdExceeded = "WARNING -- Exchange %s: Last manual update of available currency pairs has exceeded %d days. Manual update required!" APIURLDefaultMessage = "NON_DEFAULT_HTTP_LINK_TO_EXCHANGE_API" )
Constants here hold some messages
const ( // EncryptConfirmString has a the general confirmation string to allow us to // see if the file is correctly encrypted EncryptConfirmString = "THORS-HAMMER" // SaltPrefix string SaltPrefix = "~GCT~SO~SALTY~" // SaltRandomLength is the number of random bytes to append after the prefix string SaltRandomLength = 12 )
Variables ¶
var ( Cfg Config IsInitialSetup bool )
Variables here are used for configuration
Functions ¶
func ConfirmConfigJSON ¶
ConfirmConfigJSON confirms JSON in file
func ConfirmECS ¶
ConfirmECS confirms that the encryption confirmation string is found
func ConfirmSalt ¶
ConfirmSalt checks whether the encrypted data contains a salt
func DecryptConfigFile ¶
DecryptConfigFile decrypts configuration data with the supplied key and returns the un-encrypted file as a byte array with an error
func EncryptConfigFile ¶
EncryptConfigFile encrypts configuration data that is parsed in with a key and returns it as a byte array with an error
func GetFilePath ¶
GetFilePath returns the desired config file or the default config file name based on if the application is being run under test or normal mode.
func PromptForConfigKey ¶
PromptForConfigKey asks for configuration key
Types ¶
type BankAccount ¶
type BankAccount struct {
Enabled bool `json:"enabled,omitempty"`
BankName string `json:"bankName"`
BankAddress string `json:"bankAddress"`
AccountName string `json:"accountName"`
AccountNumber string `json:"accountNumber"`
SWIFTCode string `json:"swiftCode"`
IBAN string `json:"iban"`
BSBNumber string `json:"bsbNumber,omitempty"`
SupportedCurrencies string `json:"supportedCurrencies"`
SupportedExchanges string `json:"supportedExchanges,omitempty"`
}
BankAccount holds differing bank account details by supported funding currency
type BankTransaction ¶
type BankTransaction struct {
ReferenceNumber string `json:"referenceNumber"`
TransactionNumber string `json:"transactionNumber"`
PaymentInstructions string `json:"paymentInstructions"`
}
BankTransaction defines a related banking transaction
type CommunicationsConfig ¶
type CommunicationsConfig struct {
SlackConfig SlackConfig `json:"slack"`
SMSGlobalConfig SMSGlobalConfig `json:"smsGlobal"`
SMTPConfig SMTPConfig `json:"smtp"`
TelegramConfig TelegramConfig `json:"telegram"`
}
CommunicationsConfig holds all the information needed for each enabled communication package
type Config ¶
type Config struct {
Name string `json:"name"`
EncryptConfig int `json:"encryptConfig"`
GlobalHTTPTimeout time.Duration `json:"globalHTTPTimeout"`
Currency CurrencyConfig `json:"currencyConfig"`
Communications CommunicationsConfig `json:"communications"`
Portfolio portfolio.Base `json:"portfolioAddresses"`
Webserver WebserverConfig `json:"webserver"`
Exchanges []ExchangeConfig `json:"exchanges"`
BankAccounts []BankAccount `json:"bankAccounts"`
// Deprecated config settings, will be removed at a future date
CurrencyPairFormat *CurrencyPairFormatConfig `json:"currencyPairFormat,omitempty"`
FiatDisplayCurrency string `json:"fiatDispayCurrency,omitempty"`
Cryptocurrencies string `json:"cryptocurrencies,omitempty"`
SMS *SMSGlobalConfig `json:"smsGlobal,omitempty"`
}
Config is the overarching object that holds all the information for prestart management of Portfolio, Communications, Webserver and Enabled Exchanges
func (*Config) CheckClientBankAccounts ¶
CheckClientBankAccounts checks client bank details
func (*Config) CheckCommunicationsConfig ¶
CheckCommunicationsConfig checks to see if the variables are set correctly from config.json
func (*Config) CheckConfig ¶
CheckConfig checks all config settings
func (*Config) CheckCurrencyConfigValues ¶
CheckCurrencyConfigValues checks to see if the currency config values are correct or not
func (*Config) CheckExchangeConfigValues ¶
CheckExchangeConfigValues returns configuation values for all enabled exchanges
func (*Config) CheckPairConsistency ¶
CheckPairConsistency checks to see if the enabled pair exists in the available pairs list
func (*Config) CheckWebserverConfigValues ¶
CheckWebserverConfigValues checks information before webserver starts and returns an error if values are incorrect.
func (*Config) CountEnabledExchanges ¶
CountEnabledExchanges returns the number of exchanges that are enabled.
func (*Config) GetAllExchangeConfigs ¶
func (c *Config) GetAllExchangeConfigs() []ExchangeConfig
GetAllExchangeConfigs returns all exchange configurations
func (*Config) GetAvailablePairs ¶
func (c *Config) GetAvailablePairs(exchName string) ([]pair.CurrencyPair, error)
GetAvailablePairs returns a list of currency pairs for a specifc exchange
func (*Config) GetClientBankAccounts ¶
func (c *Config) GetClientBankAccounts(exchangeName string, targetCurrency string) (BankAccount, error)
GetClientBankAccounts returns banking details used for a given exchange and currency
func (*Config) GetCommunicationsConfig ¶
func (c *Config) GetCommunicationsConfig() CommunicationsConfig
GetCommunicationsConfig returns the communications configuration
func (*Config) GetConfigCurrencyPairFormat ¶
func (c *Config) GetConfigCurrencyPairFormat(exchName string) (*CurrencyPairFormatConfig, error)
GetConfigCurrencyPairFormat returns the config currency pair format for a specific exchange
func (*Config) GetCurrencyConfig ¶
func (c *Config) GetCurrencyConfig() CurrencyConfig
GetCurrencyConfig returns currency configurations
func (*Config) GetCurrencyPairDisplayConfig ¶
func (c *Config) GetCurrencyPairDisplayConfig() *CurrencyPairFormatConfig
GetCurrencyPairDisplayConfig retrieves the currency pair display preference
func (*Config) GetDisabledExchanges ¶
GetDisabledExchanges returns a list of disabled exchanges
func (*Config) GetEnabledExchanges ¶
GetEnabledExchanges returns a list of enabled exchanges
func (*Config) GetEnabledPairs ¶
func (c *Config) GetEnabledPairs(exchName string) ([]pair.CurrencyPair, error)
GetEnabledPairs returns a list of currency pairs for a specifc exchange
func (*Config) GetExchangeBankAccounts ¶
func (c *Config) GetExchangeBankAccounts(exchangeName string, depositingCurrency string) (BankAccount, error)
GetExchangeBankAccounts returns banking details associated with an exchange for depositing funds
func (*Config) GetExchangeConfig ¶
func (c *Config) GetExchangeConfig(name string) (ExchangeConfig, error)
GetExchangeConfig returns exchange configurations by its indivdual name
func (*Config) GetForexProviderConfig ¶
GetForexProviderConfig returns a forex provider configuration by its name
func (*Config) GetPrimaryForexProvider ¶
GetPrimaryForexProvider returns the primary forex provider
func (*Config) GetRequestCurrencyPairFormat ¶
func (c *Config) GetRequestCurrencyPairFormat(exchName string) (*CurrencyPairFormatConfig, error)
GetRequestCurrencyPairFormat returns the request currency pair format for a specific exchange
func (*Config) LoadConfig ¶
LoadConfig loads your configuration file into your configuration object
func (*Config) PromptForConfigEncryption ¶
PromptForConfigEncryption asks for encryption key
func (*Config) ReadConfig ¶
ReadConfig verifies and checks for encryption and verifies the unencrypted file contains JSON.
func (*Config) RetrieveConfigCurrencyPairs ¶
RetrieveConfigCurrencyPairs splits, assigns and verifies enabled currency pairs either cryptoCurrencies or fiatCurrencies
func (*Config) SaveConfig ¶
SaveConfig saves your configuration to your desired path
func (*Config) SupportsPair ¶
SupportsPair returns true or not whether the exchange supports the supplied pair
func (*Config) UpdateClientBankAccounts ¶
func (c *Config) UpdateClientBankAccounts(bankCfg BankAccount) error
UpdateClientBankAccounts updates the configuration for a bank
func (*Config) UpdateCommunicationsConfig ¶
func (c *Config) UpdateCommunicationsConfig(config CommunicationsConfig)
UpdateCommunicationsConfig sets a new updated version of a Communications configuration
func (*Config) UpdateConfig ¶
UpdateConfig updates the config with a supplied config file
func (*Config) UpdateExchangeBankAccounts ¶
func (c *Config) UpdateExchangeBankAccounts(exchangeName string, bankCfg []BankAccount) error
UpdateExchangeBankAccounts updates the configuration for the associated exchange bank
func (*Config) UpdateExchangeConfig ¶
func (c *Config) UpdateExchangeConfig(e ExchangeConfig) error
UpdateExchangeConfig updates exchange configurations
type CurrencyConfig ¶
type CurrencyConfig struct {
ForexProviders []base.Settings `json:"forexProviders"`
Cryptocurrencies string `json:"cryptocurrencies"`
CurrencyPairFormat *CurrencyPairFormatConfig `json:"currencyPairFormat"`
FiatDisplayCurrency string `json:"fiatDisplayCurrency"`
}
CurrencyConfig holds all the information needed for currency related manipulation
type CurrencyPairFormatConfig ¶
type CurrencyPairFormatConfig struct {
Uppercase bool `json:"uppercase"`
Delimiter string `json:"delimiter,omitempty"`
Separator string `json:"separator,omitempty"`
Index string `json:"index,omitempty"`
}
CurrencyPairFormatConfig stores the users preferred currency pair display
type ExchangeConfig ¶
type ExchangeConfig struct {
Name string `json:"name"`
Enabled bool `json:"enabled"`
Verbose bool `json:"verbose"`
Websocket bool `json:"websocket"`
UseSandbox bool `json:"useSandbox"`
RESTPollingDelay time.Duration `json:"restPollingDelay"`
HTTPTimeout time.Duration `json:"httpTimeout"`
HTTPUserAgent string `json:"httpUserAgent"`
AuthenticatedAPISupport bool `json:"authenticatedApiSupport"`
APIKey string `json:"apiKey"`
APISecret string `json:"apiSecret"`
APIAuthPEMKeySupport bool `json:"apiAuthPemKeySupport,omitempty"`
APIAuthPEMKey string `json:"apiAuthPemKey,omitempty"`
APIURL string `json:"apiUrl"`
APIURLSecondary string `json:"apiUrlSecondary"`
ClientID string `json:"clientId,omitempty"`
AvailablePairs string `json:"availablePairs"`
EnabledPairs string `json:"enabledPairs"`
BaseCurrencies string `json:"baseCurrencies"`
AssetTypes string `json:"assetTypes"`
SupportsAutoPairUpdates bool `json:"supportsAutoPairUpdates"`
PairsLastUpdated int64 `json:"pairsLastUpdated,omitempty"`
ConfigCurrencyPairFormat *CurrencyPairFormatConfig `json:"configCurrencyPairFormat"`
RequestCurrencyPairFormat *CurrencyPairFormatConfig `json:"requestCurrencyPairFormat"`
BankAccounts []BankAccount `json:"bankAccounts"`
}
ExchangeConfig holds all the information needed for each enabled Exchange.
type SMSContact ¶
type SMSContact struct {
Name string `json:"name"`
Number string `json:"number"`
Enabled bool `json:"enabled"`
}
SMSContact stores the SMS contact info
type SMSGlobalConfig ¶
type SMSGlobalConfig struct {
Name string `json:"name"`
Enabled bool `json:"enabled"`
Verbose bool `json:"verbose"`
Username string `json:"username"`
Password string `json:"password"`
Contacts []SMSContact `json:"contacts"`
}
SMSGlobalConfig structure holds all the variables you need for instant messaging and broadcast used by SMSGlobal
type SMTPConfig ¶
type SMTPConfig struct {
Name string `json:"name"`
Enabled bool `json:"enabled"`
Verbose bool `json:"verbose"`
Host string `json:"host"`
Port string `json:"port"`
AccountName string `json:"accountName"`
AccountPassword string `json:"accountPassword"`
RecipientList string `json:"recipientList"`
}
SMTPConfig holds all variables to start and run the SMTP package
type SlackConfig ¶
type SlackConfig struct {
Name string `json:"name"`
Enabled bool `json:"enabled"`
Verbose bool `json:"verbose"`
TargetChannel string `json:"targetChannel"`
VerificationToken string `json:"verificationToken"`
}
SlackConfig holds all variables to start and run the Slack package
type TelegramConfig ¶
type TelegramConfig struct {
Name string `json:"name"`
Enabled bool `json:"enabled"`
Verbose bool `json:"verbose"`
VerificationToken string `json:"verificationToken"`
}
TelegramConfig holds all variables to start and run the Telegram package
type WebserverConfig ¶
type WebserverConfig struct {
Enabled bool `json:"enabled"`
AdminUsername string `json:"adminUsername"`
AdminPassword string `json:"adminPassword"`
ListenAddress string `json:"listenAddress"`
WebsocketConnectionLimit int `json:"websocketConnectionLimit"`
WebsocketMaxAuthFailures int `json:"websocketMaxAuthFailures"`
WebsocketAllowInsecureOrigin bool `json:"websocketAllowInsecureOrigin"`
}
WebserverConfig struct holds the prestart variables for the webserver.