Coder Social home page Coder Social logo

Comments (1)

jolan avatar jolan commented on August 15, 2024
diff --git a/config.go b/config.go
index 29ed421..2948267 100644
--- a/config.go
+++ b/config.go
@@ -58,6 +58,20 @@ type config struct {
    ProxyPass   string `long:"proxypass" default-mask:"-" description:"Password for proxy server"`
 }

+// cleanAndExpandPath expands environement variables and leading ~ in the
+// passed path, cleans the result, and returns it.
+func cleanAndExpandPath(path string) string {
+   // Expand initial ~ to OS specific home directory.
+   if strings.HasPrefix(path, "~") {
+       homeDir := filepath.Dir(btcwalletHomeDir)
+       path = strings.Replace(path, "~", homeDir, 1)
+   }
+
+   // NOTE: The os.ExpandEnv doesn't work with Windows-style %VARIABLE%,
+   // but they variables can still be expanded via POSIX-style $VARIABLE.
+   return filepath.Clean(os.ExpandEnv(path))
+}
+
 // updateConfigWithActiveParams update the passed config with parameters
 // from the active net params if the relevant options in the passed config
 // object are the default so options specified by the user on the command line
@@ -182,6 +196,8 @@ func loadConfig() (*config, []string, error) {
    // Add default port to connect flag if missing.
    cfg.Connect = normalizeAddress(cfg.Connect, activeNetParams.btcdPort)

+   cfg.CAFile = cleanAndExpandPath(cfg.CAFile)
+
    return &cfg, remainingArgs, nil
 }

from btcwallet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.