Adjust GetDefaultBitcoinCoreDataDirOrEmptyString.
MODIFY
WalletWasabi.Gui/Config.cs
WalletWasabi.Gui/Config.cs
@@ -84,7 +84,7 @@ namespace WalletWasabi.Gui
public bool StopLocalBitcoinCoreOnShutdown { get; internal set; }
[JsonProperty(PropertyName = "LocalBitcoinCoreDataDir")]
- public string LocalBitcoinCoreDataDir { get; internal set; } = EnvironmentHelpers.TryGetDefaultBitcoinCoreDataDir() ?? "";
+ public string LocalBitcoinCoreDataDir { get; internal set; } = EnvironmentHelpers.GetDefaultBitcoinCoreDataDirOrEmptyString();
[JsonProperty(PropertyName = "TorSocks5EndPoint")]
[JsonConverter(typeof(EndPointJsonConverter), Constants.DefaultTorSocksPort)]

MODIFY
WalletWasabi/Helpers/EnvironmentHelpers.cs
WalletWasabi/Helpers/EnvironmentHelpers.cs
@@ -43,7 +43,7 @@ namespace WalletWasabi.Helpers
// Do not change the output of this function. Backwards compatibility depends on it.
public static string GetDataDir(string appName)
{
- if (DataDirDict.TryGetValue(appName, out string dataDir))
+ if (DataDirDict.TryGetValue(appName, out string? dataDir))
{
return dataDir;
}
@@ -90,13 +90,19 @@ namespace WalletWasabi.Helpers
return directory;
}
- public static string TryGetDefaultBitcoinCoreDataDir()
+ /// <summary>
+ /// Gets Bitcoin <c>datadir</c> parameter from:
+ /// <list type="bullet">
+ /// <item><c>APPDATA</c> environment variable on Windows, and</item>
+ /// <item><c>HOME</c> environment variable on other platforms.</item>
+ /// </list>
+ /// </summary>
+ /// <returns><c>datadir</c> or empty string.</returns>
+ /// <seealso href="https://en.bitcoin.it/wiki/Data_directory"/>
+ public static string GetDefaultBitcoinCoreDataDirOrEmptyString()
{
- string directory = null;
+ string directory = "";
- // https://en.bitcoin.it/wiki/Data_directory
- try
- {
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var localAppData = Environment.GetEnvironmentVariable("APPDATA");
@@ -106,7 +112,7 @@ namespace WalletWasabi.Helpers
}
else
{
- throw new DirectoryNotFoundException($"Could not find suitable default {Constants.BuiltinBitcoinNodeName} datadir.");
+ Logger.LogDebug($"Could not find suitable default {Constants.BuiltinBitcoinNodeName} datadir.");
}
}
else
@@ -120,15 +126,8 @@ namespace WalletWasabi.Helpers
}
else
{
- throw new DirectoryNotFoundException($"Could not find suitable default {Constants.BuiltinBitcoinNodeName} datadir.");
- }
+ Logger.LogDebug($"Could not find suitable default {Constants.BuiltinBitcoinNodeName} datadir.");
}
-
- return directory;
- }
- catch (Exception ex)
- {
- Logger.LogDebug(ex);
}
return directory;

Adjust GetDefaultBitcoinCoreDataDirOrEmptyString.