-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
71 lines (62 loc) · 1.66 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"encoding/json"
"os"
"time"
)
type LNDConfig struct {
Directory string `json:"lndDir"`
CertPath string `json:"certPath"`
Host string `json:"host"`
Port int `json:"port"`
}
type LSSDConfig struct {
Host string `json:"host"`
Port int `json:"port"`
TimeoutStr string `json:"timeout"`
Timeout time.Duration
}
type BotConfig struct {
Host string `json:"host"`
Port int `json:"port"`
LNCLIPath string `json:"lnCLIPath"`
}
type Config struct {
Bot BotConfig `json:"botCfg"`
LSSDConfig LSSDConfig `json:"lssdConfig"`
XSN LNDConfig `json:"xsnLNDConfig"`
LTC LNDConfig `json:"ltcLNDConfig"`
BTC LNDConfig `json:"btcLNDConfig"`
Orders []Order `json:"orders"`
}
type Order struct {
Side string `json:"side"`
TradingPair string `json:"tradingPair"`
PriceRangeStart int `json:"priceRangeStart"`
PriceRangeEnd int `json:"priceRangeEnd"`
PriceRangeStepSize int `json:"priceRangeStepSize"`
FixedFunding int `json:"fixedFunding"`
}
type CancelTradingPair struct {
TradingPair string `json:"tradingPair"`
DeleteAll bool `json:"deleteAll,omitempty"`
OrderIDs []string `json:"orderIds,omitempty"`
}
type OrderCancel struct {
TradingPair []CancelTradingPair `json:"cancelTradingPairs"`
}
func readConfig() error {
file, err := os.Open("cfg.json")
if err != nil {
logger.Fatalf("can't open config file: %v", err)
return err
}
defer file.Close()
decoder := json.NewDecoder(file)
err = decoder.Decode(&cfg)
if err != nil {
logger.Fatalf("can't decode config JSON: %v", err)
return err
}
return nil
}