-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
58 lines (48 loc) · 1.32 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
package main
import (
"fmt"
"log"
"github.com/btcsuite/btcd/rpcclient"
"github.com/gertjaap/vertcoin-extras/blockprocessor"
"github.com/gertjaap/vertcoin-extras/config"
"github.com/gertjaap/vertcoin-extras/server"
"github.com/gertjaap/vertcoin-extras/wallet"
"github.com/skratchdot/open-golang/open"
)
func main() {
configChanged := make(chan bool, 0)
cfg, err := config.InitConfig(configChanged)
if err != nil {
log.Fatal(err)
}
connCfg := &rpcclient.ConnConfig{
Host: cfg.RpcHost,
User: cfg.RpcUser,
Pass: cfg.RpcPassword,
HTTPPostMode: true, // Bitcoin core only supports HTTP POST mode
DisableTLS: true, // Bitcoin core does not provide TLS by default
}
client, err := rpcclient.New(connCfg, nil)
if err != nil {
log.Fatal(err)
}
defer client.Shutdown()
w := wallet.NewWallet(client, cfg)
bp := blockprocessor.NewBlockProcessor(w, client, cfg)
srv := server.NewHttpServer(w, cfg, bp)
go func(wal *wallet.Wallet, blp *blockprocessor.BlockProcessor, config *rpcclient.ConnConfig) {
for {
<-configChanged
config.Host = cfg.RpcHost
config.User = cfg.RpcUser
config.Pass = cfg.RpcPassword
}
}(w, bp, connCfg)
err = w.InitKey()
if err != nil {
log.Fatal(err)
}
go bp.Loop()
open.Run(fmt.Sprintf("http://localhost:%d/", cfg.Port))
log.Fatal(srv.Run())
}