File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -134,8 +134,7 @@ static fs::path GetMainchainAuthCookieFile()
134134 if (gArgs .GetChainName () == " liquidv1" ) {
135135 cookie_file = " .cookie" ;
136136 }
137- std::string path = gArgs .GetArg (" -mainchainrpccookiefile" , cookie_file);
138- return AbsPathForConfigVal (fs::path (path));
137+ return fsbridge::AbsPathJoin (GetMainchainDefaultDataDir (), gArgs .GetArg (" -mainchainrpccookiefile" , cookie_file));
139138}
140139
141140bool GetMainchainAuthCookie (std::string *cookie_out)
Original file line number Diff line number Diff line change @@ -827,6 +827,31 @@ fs::path GetDefaultDataDir()
827827}
828828#endif
829829
830+ fs::path GetMainchainDefaultDataDir ()
831+ {
832+ // Windows: C:\Users\Username\AppData\Roaming\Bitcoin
833+ // macOS: ~/Library/Application Support/Bitcoin
834+ // Unix-like: ~/.bitcoin
835+ #ifdef WIN32
836+ // Windows
837+ return GetSpecialFolderPath (CSIDL_APPDATA) / " Bitcoin" ;
838+ #else
839+ fs::path pathRet;
840+ char * pszHome = getenv (" HOME" );
841+ if (pszHome == nullptr || strlen (pszHome) == 0 )
842+ pathRet = fs::path (" /" );
843+ else
844+ pathRet = fs::path (pszHome);
845+ #ifdef MAC_OSX
846+ // macOS
847+ return pathRet / " Library/Application Support/Bitcoin" ;
848+ #else
849+ // Unix-like
850+ return pathRet / " .bitcoin" ;
851+ #endif
852+ #endif
853+ }
854+
830855bool CheckDataDirOption ()
831856{
832857 std::string datadir = gArgs .GetArg (" -datadir" , " " );
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ void ReleaseDirectoryLocks();
9090
9191bool TryCreateDirectories (const fs::path& p);
9292fs::path GetDefaultDataDir ();
93+ fs::path GetMainchainDefaultDataDir ();
9394// Return true if -datadir option points to a valid directory or is not specified.
9495bool CheckDataDirOption ();
9596fs::path GetConfigFile (const std::string& confPath);
You can’t perform that action at this time.
0 commit comments