-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
48 lines (40 loc) · 1.17 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
package main
import (
"flag"
"fmt"
"github.com/btcsuite/btcd/chaincfg"
)
type Flags struct {
Create bool
Simnet bool
Regtest bool
RPCUser string
RPCPass string
Node string
}
func parseFlags() (*Flags, error) {
flags := &Flags{}
flag.BoolVar(&flags.Create, "create", false, "Create a new wallet")
flag.BoolVar(&flags.Simnet, "simnet", false, "specify simnet")
flag.BoolVar(&flags.Regtest, "regtest", false, "specify regtest")
flag.StringVar(&flags.RPCUser, "rpcuser", "", "RPC username")
flag.StringVar(&flags.RPCPass, "rpcpass", "", "RPC password")
flag.StringVar(&flags.Node, "node", "btcd", "Node backing wallet (core or btcd)")
flag.Parse()
if flags.Node != "btcd" && flags.Node != "core" {
return nil, fmt.Errorf("Invalid node type. Please provide 'btcd' or 'core'")
}
if flags.Node == "core" && flags.Simnet {
return nil, fmt.Errorf("Simnet is not available with core. For core please specify testnet or regtest")
}
return flags, nil
}
func getNetwork(flags *Flags) *chaincfg.Params {
if flags.Simnet {
return &chaincfg.SimNetParams
} else if flags.Regtest {
return &chaincfg.RegressionNetParams
} else {
return &chaincfg.TestNet3Params
}
}