Improve UTXO file path stuff
Remove WalletWasabi.Assets folder (no need for it now)
DELETE
WalletWasabi.Assets/WasabiLogo.png
WalletWasabi.Assets/WasabiLogo.png
Binary files a/WalletWasabi.Assets/WasabiLogo.png and /dev/null differ

MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -36,6 +36,7 @@ namespace WalletWasabi.Gui
public static string WalletsDir => Path.Combine(DataDir, "Wallets");
public static Network Network => Config.Network;
+ public static string IndexFilePath => Path.Combine(DataDir, $"Index{Network}.dat");
public static BlindingRsaPubKey BlindingPubKey => Config.GetBlindingRsaPubKey();
@@ -51,13 +52,16 @@ namespace WalletWasabi.Gui
public static Config Config { get; private set; }
- public static void Initialize(Config config)
+ public static void InitializeConfig(Config config)
+ {
+ Config = Guard.NotNull(nameof(config), config);
+ }
+
+ public static void InitializeNoWallet()
{
WalletService = null;
ChaumianClient = null;
- Config = Guard.NotNull(nameof(config), config);
-
var addressManagerFolderPath = Path.Combine(DataDir, "AddressManager");
AddressManagerFilePath = Path.Combine(addressManagerFolderPath, $"AddressManager{Network}.dat");
var blocksFolderPath = Path.Combine(DataDir, $"Blocks{Network}");
@@ -119,8 +123,7 @@ namespace WalletWasabi.Gui
RegTestMemPoolServingNode = null;
}
- var indexFilePath = Path.Combine(DataDir, $"Index{Network}.dat");
- IndexDownloader = new IndexDownloader(Network, indexFilePath, Config.GetCurrentBackendUri());
+ IndexDownloader = new IndexDownloader(Network, IndexFilePath, Config.GetCurrentBackendUri());
UpdateChecker = new UpdateChecker(IndexDownloader.WasabiClient);

MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -33,7 +33,18 @@ namespace WalletWasabi.Gui
await config.LoadOrCreateDefaultFileAsync();
Logger.LogInfo<Config>("Config is successfully initialized.");
- Global.Initialize(config);
+ Global.InitializeConfig(config);
+
+ if (!File.Exists(Global.IndexFilePath)) // Load the index file from working folder if we have it.
+ {
+ var indexFileName = Path.GetFileName(Global.IndexFilePath);
+ if (File.Exists(indexFileName))
+ {
+ File.Copy(indexFileName, Global.IndexFilePath, overwrite: false);
+ }
+ }
+
+ Global.InitializeNoWallet();
statusBar = new StatusBarViewModel(Global.Nodes.ConnectedNodes, Global.MemPoolService, Global.IndexDownloader, Global.UpdateChecker);
MainWindowViewModel.Instance.StatusBar = statusBar;

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -35,7 +35,8 @@ namespace WalletWasabi.Services
public NodesGroup Nodes { get; }
public string BlocksFolderPath { get; }
- public string TmpMempoolDumpFilePath { get; }
+ public string TransactionsFolderPath { get; }
+ public string TransactionsFilePath { get; }
private AsyncLock HandleFiltersLock { get; }
private AsyncLock BlockDownloadLock { get; }
@@ -82,6 +83,7 @@ namespace WalletWasabi.Services
TransactionCache = new ConcurrentHashSet<SmartTransaction>();
BlocksFolderPath = Path.Combine(workFolderDir, "Blocks", Network.ToString());
+ TransactionsFolderPath = Path.Combine(workFolderDir, "Transactions", Network.ToString());
BlockFolderLock = new AsyncLock();
BlockDownloadLock = new AsyncLock();
@@ -101,8 +103,25 @@ namespace WalletWasabi.Services
{
Directory.CreateDirectory(BlocksFolderPath);
}
+ if (Directory.Exists(TransactionsFolderPath))
+ {
+ if (IndexDownloader.Network == Network.RegTest)
+ {
+ Directory.Delete(TransactionsFolderPath, true);
+ Directory.CreateDirectory(TransactionsFolderPath);
+ }
+ }
+ else
+ {
+ Directory.CreateDirectory(TransactionsFolderPath);
+ }
- TmpMempoolDumpFilePath = Path.Combine(BlocksFolderPath, $"TmpMempoolDump{Network}.json");
+ var walletName = "UnnamedWallet";
+ if (string.IsNullOrWhiteSpace(KeyManager.FilePath))
+ {
+ walletName = Path.GetFileNameWithoutExtension(KeyManager.FilePath);
+ }
+ TransactionsFilePath = Path.Combine(TransactionsFolderPath, $"{walletName}Transactions.json");
IndexDownloader.NewFilter += IndexDownloader_NewFilterAsync;
IndexDownloader.Reorged += IndexDownloader_ReorgedAsync;
@@ -178,9 +197,9 @@ namespace WalletWasabi.Services
}
// Load in dummy mempool
- if (File.Exists(TmpMempoolDumpFilePath))
+ if (File.Exists(TransactionsFilePath))
{
- string jsonString = File.ReadAllText(TmpMempoolDumpFilePath, Encoding.UTF8);
+ string jsonString = File.ReadAllText(TransactionsFilePath, Encoding.UTF8);
var mempool = JsonConvert.DeserializeObject<IEnumerable<SmartTransaction>>(jsonString);
foreach (var tx in mempool)
@@ -198,7 +217,7 @@ namespace WalletWasabi.Services
}
try
{
- File.Delete(TmpMempoolDumpFilePath);
+ File.Delete(TransactionsFilePath);
}
catch (Exception ex)
{
@@ -1015,10 +1034,10 @@ namespace WalletWasabi.Services
IndexDownloader.Reorged -= IndexDownloader_ReorgedAsync;
MemPool.TransactionReceived -= MemPool_TransactionReceived;
- var directoryPath = Path.GetDirectoryName(Path.GetFullPath(TmpMempoolDumpFilePath));
+ var directoryPath = Path.GetDirectoryName(Path.GetFullPath(TransactionsFilePath));
Directory.CreateDirectory(directoryPath);
string jsonString = JsonConvert.SerializeObject(TransactionCache.Where(x => x.Height == Height.MemPool), Formatting.Indented);
- File.WriteAllText(TmpMempoolDumpFilePath,
+ File.WriteAllText(TransactionsFilePath,
jsonString,
Encoding.UTF8);
}

Improve UTXO file path stuff
Remove WalletWasabi.Assets folder (no need for it now)