Skip to content

Commit 855dd8d

Browse files
committed
system: use %LOCALAPPDATA% as default datadir on windows
1 parent 312f542 commit 855dd8d

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

doc/bitcoin-conf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ The `includeconf=<file>` option in the `bitcoin.conf` file can be used to includ
5959

6060
Operating System | Data Directory | Example Path
6161
-- | -- | --
62-
Windows | `%APPDATA%\Bitcoin\` | `C:\Users\username\AppData\Roaming\Bitcoin\bitcoin.conf`
62+
Windows | `%LOCALAPPDATA%\Bitcoin\` | `C:\Users\username\AppData\Local\Bitcoin\bitcoin.conf`
6363
Linux | `$HOME/.bitcoin/` | `/home/username/.bitcoin/bitcoin.conf`
6464
macOS | `$HOME/Library/Application Support/Bitcoin/` | `/Users/username/Library/Application Support/Bitcoin/bitcoin.conf`
6565

doc/files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Platform | Data directory path
2828
---------|--------------------
2929
Linux | `$HOME/.bitcoin/`
3030
macOS | `$HOME/Library/Application Support/Bitcoin/`
31-
Windows | `%APPDATA%\Bitcoin\` <sup>[\[1\]](#note1)</sup>
31+
Windows | `%LOCALAPPDATA%\Bitcoin\` <sup>[\[1\]](#note1)</sup>
3232

3333
2. A custom data directory path can be specified with the `-datadir` option.
3434

doc/managing-wallets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ By default, wallets are created in the `wallets` folder of the data directory, w
2020
| Operating System | Default wallet directory |
2121
| -----------------|:------------------------------------------------------------|
2222
| Linux | `/home/<user>/.bitcoin/wallets` |
23-
| Windows | `C:\Users\<user>\AppData\Roaming\Bitcoin\wallets` |
23+
| Windows | `C:\Users\<user>\AppData\Local\Bitcoin\wallets` |
2424
| macOS | `/Users/<user>/Library/Application Support/Bitcoin/wallets` |
2525

2626
### 1.2 Encrypting the Wallet

src/common/args.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,12 +696,19 @@ bool HasTestOption(const ArgsManager& args, const std::string& test_option)
696696

697697
fs::path GetDefaultDataDir()
698698
{
699-
// Windows: C:\Users\Username\AppData\Roaming\Bitcoin
699+
// Windows:
700+
// old: C:\Users\Username\AppData\Roaming\Bitcoin
701+
// new: C:\Users\Username\AppData\Local\Bitcoin
700702
// macOS: ~/Library/Application Support/Bitcoin
701703
// Unix-like: ~/.bitcoin
702704
#ifdef WIN32
703705
// Windows
704-
return GetSpecialFolderPath(CSIDL_APPDATA) / "Bitcoin";
706+
// Check for existence of datadir in old location and keep it there
707+
fs::path legacy_path = GetSpecialFolderPath(CSIDL_APPDATA) / "Bitcoin";
708+
if (fs::exists(legacy_path)) return legacy_path;
709+
710+
// Otherwise, fresh installs can start in the new, "proper" location
711+
return GetSpecialFolderPath(CSIDL_LOCAL_APPDATA) / "Bitcoin";
705712
#else
706713
fs::path pathRet;
707714
char* pszHome = getenv("HOME");

0 commit comments

Comments
 (0)