Skip to content

Commit

Permalink
expand dcr rpcwallet cert
Browse files Browse the repository at this point in the history
  • Loading branch information
ukane-philemon committed Mar 15, 2022
1 parent 960256e commit 90b22ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
3 changes: 2 additions & 1 deletion client/asset/dcr/rpcwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ func newRPCWallet(cfg *Config, chainParams *chaincfg.Params, logger dex.Logger)
log: log,
}

certs, err := os.ReadFile(cfg.RPCCert)
cert := dex.CleanAndExpandPath(cfg.RPCCert)
certs, err := os.ReadFile(cert)
if err != nil {
return nil, fmt.Errorf("TLS certificate read error: %w", err)
}
Expand Down
4 changes: 3 additions & 1 deletion client/cmd/dexc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ func configure() (*Config, error) {
}
}

cfgPath := dex.CleanAndExpandPath(preCfg.Config)

// Load additional config from file.
parser := flags.NewParser(&iniCfg, flags.Default)
err := flags.NewIniParser(parser).ParseFile(preCfg.Config)
err := flags.NewIniParser(parser).ParseFile(cfgPath)
if err != nil {
if _, ok := err.(*os.PathError); !ok {
fmt.Fprintln(os.Stderr, err)
Expand Down
14 changes: 5 additions & 9 deletions dex/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func CleanAndExpandPath(path string) string {
// they didn't have a LOCALAPPDATA.
dirName = os.Getenv("LOCALAPPDATA")
}

return filepath.Join(dirName, path)
}

Expand All @@ -40,17 +39,14 @@ func CleanAndExpandPath(path string) string {
// %VARIABLE%, but the variables can still be expanded via POSIX-style
// $VARIABLE.
path = os.ExpandEnv(path)
path, _ = filepath.Abs(path)
return path
}

if strings.HasPrefix(path, "~") {
dirName, _ = os.UserHomeDir()
return filepath.Clean(path)
}

if dirName == "" {
dirName, err := os.UserHomeDir()
if err != nil {
// Fallback to CWD if retrieving user home directory fails.
dirName = "."
}

return filepath.Join(dirName, path[2:])
return filepath.Join(dirName, path[1:])
}

0 comments on commit 90b22ad

Please sign in to comment.