-
Notifications
You must be signed in to change notification settings - Fork 46
/
main.go
87 lines (73 loc) · 1.57 KB
/
main.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package main
import (
"fmt"
"net/http"
_ "net/http/pprof"
"os"
"path/filepath"
"time"
"gioui.org/app"
"github.com/planetdecred/dcrlibwallet"
"github.com/planetdecred/godcr/ui"
_ "github.com/planetdecred/godcr/ui/assets"
"github.com/planetdecred/godcr/wallet"
)
var (
Version = "1.7.0"
BuildDate string
BuildEnv = wallet.DevBuild
)
func main() {
cfg, err := loadConfig()
if err != nil {
fmt.Printf("Error: %s\n", err.Error())
return
}
if cfg.Profile > 0 {
go func() {
log.Info(fmt.Sprintf("Starting profiling server on port %d", cfg.Profile))
log.Error(http.ListenAndServe(fmt.Sprintf("127.0.0.1:%d", cfg.Profile), nil))
}()
}
dcrlibwallet.SetLogLevels(cfg.DebugLevel)
var buildDate time.Time
if BuildEnv == wallet.ProdBuild {
buildDate, err = time.Parse(time.RFC3339, BuildDate)
if err != nil {
fmt.Printf("Error: %s\n", err.Error())
return
}
} else {
buildDate = time.Now()
}
var net string
switch cfg.Network {
case "testnet":
net = "testnet3"
default:
net = cfg.Network
}
logFile := filepath.Join(cfg.LogDir, defaultLogFilename)
wal, err := wallet.NewWallet(cfg.HomeDir, net, Version, logFile, buildDate)
if err != nil {
log.Error(err)
return
}
err = wal.InitMultiWallet()
if err != nil {
log.Errorf("init multiwallet error: %v", err)
return
}
win, err := ui.CreateWindow(wal)
if err != nil {
log.Errorf("Could not initialize window: %s\ns", err)
return
}
go func() {
win.HandleEvents() // blocks until the app window is closed
wal.Shutdown()
os.Exit(0)
}()
// Start the GUI frontend.
app.Main()
}