-
Notifications
You must be signed in to change notification settings - Fork 1
/
btcw.go
47 lines (40 loc) · 904 Bytes
/
btcw.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
package main
import (
"errors"
"fmt"
"os"
"github.com/elnosh/btcw/rpcserver"
"github.com/elnosh/btcw/wallet"
)
func main() {
flags, err := parseFlags()
if err != nil {
printErr(err)
}
net := getNetwork(flags)
if flags.Create {
err := wallet.CreateWallet(net)
if err != nil {
printErr(err)
}
} else {
if flags.RPCUser == "" || flags.RPCPass == "" {
printErr(errors.New("RPC username and password are required to start wallet"))
}
w, err := wallet.LoadWallet(net, flags.RPCUser, flags.RPCPass, flags.Node)
if err != nil {
if err == wallet.ErrWalletNotExists {
printErr(errors.New("A wallet does not exist. Please create one first with -create"))
}
printErr(fmt.Errorf("error loading wallet: %v", err))
}
err = rpcserver.StartRPCServer(w)
if err != nil {
printErr(err)
}
}
}
func printErr(msg error) {
fmt.Println(msg.Error())
os.Exit(0)
}