Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions factom-walletd.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func main() {
factomdRpcUser = flag.String("factomduser", "", "Username for API connections to factomd")
factomdRpcPassword = flag.String("factomdpassword", "", "Password for API connections to factomd")
corsDomains = flag.String("corsdomains", "", "CORS Domains")
whitelist = flag.String("whitelist", "", "If not empty, only whitelisted IPs will be able to connect. Comma separated list of IP addresses. Local addresses will always be able to connect.")

factomdLocation = flag.String("s", "", "IPAddr:port# of factomd API to use to access blockchain (default localhost:8088)")
walletdLocation = flag.String("selfaddr", "", "comma seperated IPAddresses and DNS names of this factom-walletd to use when creating a cert file")
Expand All @@ -53,15 +54,13 @@ func main() {
)
flag.Parse()


// see if the config file has values which should be used instead of null strings
filename := util.ConfigFilename()
if *configPath != "" {
filename = *configPath
}
cfg := util.ReadConfig(filename)


if !*encryptedDB {
if cfg.Walletd.WalletEncrypted {
fmt.Printf("WalletEncryption enabled in config file at: %s\n", filename)
Expand All @@ -79,14 +78,24 @@ func main() {
}
}

if *whitelist != "" {
ips := strings.Split(*whitelist, ",")
for _, ip := range ips {
ip = strings.TrimSpace(ip)
if err := wsapi.WhiteListIP(ip); err != nil {
fmt.Printf("Unable to whitelist \"%s\": %v\n", ip, err)
os.Exit(1)
}
}
}

encryptedPath := util.GetHomeDir() + "/.factom/wallet/factom_wallet_encrypted.db"
isEncryptedFirstBoot := false

if *wflag != "" {
walletPath = *wflag
}


// Conditions around using the encrypted wallet
if *encryptedDB {
// Check if regular wallet exists, exit if the wrong wallet exists, assuming an unsafe configuration issue.
Expand Down Expand Up @@ -240,13 +249,14 @@ func main() {

port := *pflag
RPCConfig := factom.RPCConfig{
WalletTLSEnable: *walletTLSflag,
WalletTLSKeyFile: *walletTLSKey,
WalletTLSCertFile: *walletTLSCert,
WalletRPCUser: *walletRpcUser,
WalletRPCPassword: *walletRpcPassword,
WalletServer: *walletdLocation,
WalletCORSDomains: *corsDomains,
WalletTLSEnable: *walletTLSflag,
WalletTLSKeyFile: *walletTLSKey,
WalletTLSCertFile: *walletTLSCert,
WalletRPCUser: *walletRpcUser,
WalletRPCPassword: *walletRpcPassword,
WalletServer: *walletdLocation,
WalletCORSDomains: *corsDomains,
WalletWhiteListEnable: *whitelist != "",
}
factom.SetFactomdRpcConfig(*factomdRpcUser, *factomdRpcPassword)
factom.SetFactomdServer(*factomdLocation)
Expand Down