-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWithdraw.go
56 lines (43 loc) · 1.09 KB
/
Withdraw.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
package main
import (
"fmt"
"github.com/howeyc/gopass"
"os"
"withdraw/accounts"
"withdraw/logger"
"runtime"
"withdraw/txupdater"
"github.com/zhooq/go-ethereum/ethclient"
"github.com/zhooq/go-ethereum/rpc"
"withdraw/listener"
"withdraw/withdraw"
"github.com/julienschmidt/httprouter"
"net/http"
"log"
"withdraw/config"
"github.com/spf13/viper"
)
const (
VERSION = "0.01"
)
func init() {
config.Load()
}
func main() {
fmt.Printf("Database password: ")
pass, _ := gopass.GetPasswd()
if len(pass) > 1 {
accounts.KEY = string(pass)
}
logger.Log.Printf("Server v%s pid=%d started with processes: %d", VERSION, os.Getpid(), runtime.GOMAXPROCS(runtime.NumCPU()))
conn, err := ethclient.Dial(viper.GetString("BlockchainEndpoint"))
client, err := rpc.Dial(viper.GetString("BlockchainEndpoint"))
if err != nil {
fmt.Println("Failed to connect to the Ethereum client: %v", err)
}
go txupdater.StartTxUpdating(client)
go listener.StartListener(client, conn)
router := httprouter.New()
router.POST("/withdraw/", withdraw.MakeWithdraw)
log.Fatal(http.ListenAndServe(":9011", router))
}