Skip to content

Commit 915d727

Browse files
committed
Merge bitcoin/bitcoin#27064: system: use %LOCALAPPDATA% as default datadir on windows
84900ac doc: add release-notes-27064.md (Matthew Zipkin) 855dd8d system: use %LOCALAPPDATA% as default datadir on windows (Matthew Zipkin) Pull request description: Closes bitcoin/bitcoin#2391 This PR changes the default datadir location on Windows from `C:\Users\Username\AppData\Roaming\Bitcoin` to `C:\Users\Username\AppData\Local\Bitcoin`. This change only applies to fresh installs. To preserve backwards compatibility, on startup we check for the existence of `C:\Users\Username\AppData\Roaming\Bitcoin\chainstate` and if it is there, we continue using the "Roaming" directory as the default datadir location. [Note that in Windows 11 this change may be moot:](https://learn.microsoft.com/en-us/uwp/api/windows.storage.applicationdata.roamingfolder?view=winrt-22621) > Roaming data and settings is no longer supported as of Windows 11. The recommended replacement is [Azure App Service](https://learn.microsoft.com/en-us/azure/app-service/). Azure App Service is widely supported, well documented, reliable, and supports cross-platform/cross-ecosystem scenarios such as iOS, Android and web. Settings stored here no longer roam (as of Windows 11), but the settings store is still available. ACKs for top commit: achow101: ACK 84900ac BenWestgate: crACK bitcoin/bitcoin@84900ac hebasto: re-ACK 84900ac, only addressed feedback since my recent [review](bitcoin/bitcoin#27064 (review)). Tree-SHA512: 807c6e89571287e2c8f4934229aec91ef28e7d0a675234acf1b7d085c24c7b73a08b6e345fbfc9038e6239187b6b69c08490ddaa1c057de5ea975c4a000bba42
2 parents 867f6af + 84900ac commit 915d727

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-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
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Files
2+
-----
3+
4+
The default data directory on Windows has been moved from `C:\Users\Username\AppData\Roaming\Bitcoin`
5+
to `C:\Users\Username\AppData\Local\Bitcoin`. Bitcoin Core will check the existence
6+
of the old directory first and continue to use that directory for backwards
7+
compatibility if it is present.

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)