#pragma warning disable IDE1006 // Naming Styles private async void OnActivated(object sender, EventArgs e) #pragma warning restore IDE1006 // Naming Styles { try { Activated -= OnActivated; var uiConfigFilePath = Path.Combine(Global.DataDir, "UiConfig.json"); var uiConfig = new UiConfig(uiConfigFilePath); await uiConfig.LoadOrCreateDefaultFileAsync(); Global.InitializeUiConfig(uiConfig); Logging.Logger.LogInfo <UiConfig>("UiConfig is successfully initialized."); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { MainWindowViewModel.Instance.Width = (double)uiConfig.Width; MainWindowViewModel.Instance.Height = (double)uiConfig.Height; MainWindowViewModel.Instance.WindowState = (WindowState)uiConfig.WindowState; } else { MainWindowViewModel.Instance.WindowState = WindowState.Maximized; } DisplayWalletManager(); } catch (Exception ex) { Logging.Logger.LogWarning <MainWindow>(ex); } }
public Global(string dataDir, string torLogsFile, Config config, UiConfig uiConfig, WalletManager walletManager) { using (BenchmarkLogger.Measure()) { StoppingCts = new CancellationTokenSource(); DataDir = dataDir; Config = config; UiConfig = uiConfig; TorSettings = new TorSettings(DataDir, torLogsFile, distributionFolderPath: EnvironmentHelpers.GetFullBaseDirectory()); Logger.InitializeDefaults(Path.Combine(DataDir, "Logs.txt")); HostedServices = new HostedServices(); WalletManager = walletManager; LegalDocuments = LegalDocuments.TryLoadAgreed(DataDir); WalletManager.OnDequeue += WalletManager_OnDequeue; WalletManager.WalletRelevantTransactionProcessed += WalletManager_WalletRelevantTransactionProcessed; var networkWorkFolderPath = Path.Combine(DataDir, "BitcoinStore", Network.ToString()); var transactionStore = new AllTransactionStore(networkWorkFolderPath, Network); var indexStore = new IndexStore(Path.Combine(networkWorkFolderPath, "IndexStore"), Network, new SmartHeaderChain()); var mempoolService = new MempoolService(); var blocks = new FileSystemBlockRepository(Path.Combine(networkWorkFolderPath, "Blocks"), Network); BitcoinStore = new BitcoinStore(indexStore, transactionStore, mempoolService, blocks); WasabiClientFactory wasabiClientFactory = Config.UseTor ? new WasabiClientFactory(Config.TorSocks5EndPoint, backendUriGetter: () => Config.GetCurrentBackendUri()) : new WasabiClientFactory(torEndPoint: null, backendUriGetter: () => Config.GetFallbackBackendUri()); Synchronizer = new WasabiSynchronizer(Network, BitcoinStore, wasabiClientFactory); } }
public Global(string dataDir, string torLogsFile, Config config, UiConfig uiConfig, WalletManager walletManager) { using (BenchmarkLogger.Measure()) { CrashReporter = new CrashReporter(); StoppingCts = new CancellationTokenSource(); DataDir = dataDir; Config = config; UiConfig = uiConfig; TorLogsFile = torLogsFile; Logger.InitializeDefaults(Path.Combine(DataDir, "Logs.txt")); HostedServices = new HostedServices(); WalletManager = walletManager; LegalDocuments = LegalDocuments.TryLoadAgreed(DataDir); WalletManager.OnDequeue += WalletManager_OnDequeue; WalletManager.WalletRelevantTransactionProcessed += WalletManager_WalletRelevantTransactionProcessed; var indexStore = new IndexStore(Network, new SmartHeaderChain()); BitcoinStore = new BitcoinStore( Path.Combine(DataDir, "BitcoinStore"), Network, indexStore, new AllTransactionStore(), new MempoolService() ); SingleInstanceChecker = new SingleInstanceChecker(Network); } }
public Global() { using (BenchmarkLogger.Measure()) { StoppingCts = new CancellationTokenSource(); DataDir = EnvironmentHelpers.GetDataDir(Path.Combine("MustardWalletLTC", "Client")); TorLogsFile = Path.Combine(DataDir, "TorLogs.txt"); Directory.CreateDirectory(DataDir); Logger.InitializeDefaults(Path.Combine(DataDir, "Logs.txt")); UiConfig = new UiConfig(Path.Combine(DataDir, "UiConfig.json")); UiConfig.LoadOrCreateDefaultFile(); Config = new Config(Path.Combine(DataDir, "Config.json")); Config.LoadOrCreateDefaultFile(); HostedServices = new HostedServices(); WalletManager = new WalletManager(Network, new WalletDirectories(DataDir)); LegalDocuments = LegalDocuments.TryLoadAgreed(DataDir); WalletManager.OnDequeue += WalletManager_OnDequeue; WalletManager.WalletRelevantTransactionProcessed += WalletManager_WalletRelevantTransactionProcessed; } }
private static Global CreateGlobal() { string dataDir = EnvironmentHelpers.GetDataDir(Path.Combine("WalletWasabi", "Client")); Directory.CreateDirectory(dataDir); string torLogsFile = Path.Combine(dataDir, "TorLogs.txt"); var uiConfig = new UiConfig(Path.Combine(dataDir, "UiConfig.json")); uiConfig.LoadOrCreateDefaultFile(); var config = new Config(Path.Combine(dataDir, "Config.json")); config.LoadOrCreateDefaultFile(); config.CorrectMixUntilAnonymitySet(); var walletManager = new WalletManager(config.Network, new WalletDirectories(dataDir)); return(new Global(dataDir, torLogsFile, config, uiConfig, walletManager)); }
public async Task <bool> InitializeUiConfigAsync() { try { var uiConfigFilePath = Path.Combine(DataDir, "UiConfig.json"); var uiConfig = new UiConfig(uiConfigFilePath); await uiConfig.LoadOrCreateDefaultFileAsync().ConfigureAwait(false); UiConfig = uiConfig; return(true); } catch (Exception ex) { Logger.LogError(ex); } return(false); }
private void InitializeComponent() { Closing += MainWindow_ClosingAsync; AvaloniaXamlLoader.Load(this); DisplayWalletManager(); var uiConfigFilePath = Path.Combine(Global.DataDir, "UiConfig.json"); var uiConfig = new UiConfig(uiConfigFilePath); uiConfig.LoadOrCreateDefaultFileAsync() .ToObservable(RxApp.TaskpoolScheduler) .Take(1) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => { try { Global.InitializeUiConfig(uiConfig); Application.Current.Resources.AddOrReplace(Global.UiConfigResourceKey, Global.UiConfig); Logger.LogInfo($"{nameof(Global.UiConfig)} is successfully initialized."); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { MainWindowViewModel.Instance.Width = uiConfig.Width; MainWindowViewModel.Instance.Height = uiConfig.Height; MainWindowViewModel.Instance.WindowState = uiConfig.WindowState; } else { MainWindowViewModel.Instance.WindowState = WindowState.Maximized; } MainWindowViewModel.Instance.LockScreen.Initialize(); } catch (Exception ex) { Logger.LogError(ex); } }, onError: ex => Logger.LogError(ex)); }
public Global(string dataDir, Config config, UiConfig uiConfig, WalletManager walletManager) { using (BenchmarkLogger.Measure()) { StoppingCts = new CancellationTokenSource(); DataDir = dataDir; Config = config; UiConfig = uiConfig; TorSettings = new TorSettings(DataDir, distributionFolderPath: EnvironmentHelpers.GetFullBaseDirectory(), Config.TerminateTorOnExit, Environment.ProcessId); HostedServices = new HostedServices(); WalletManager = walletManager; WalletManager.OnDequeue += WalletManager_OnDequeue; WalletManager.WalletRelevantTransactionProcessed += WalletManager_WalletRelevantTransactionProcessed; var networkWorkFolderPath = Path.Combine(DataDir, "BitcoinStore", Network.ToString()); var transactionStore = new AllTransactionStore(networkWorkFolderPath, Network); var indexStore = new IndexStore(Path.Combine(networkWorkFolderPath, "IndexStore"), Network, new SmartHeaderChain()); var mempoolService = new MempoolService(); var blocks = new FileSystemBlockRepository(Path.Combine(networkWorkFolderPath, "Blocks"), Network); BitcoinStore = new BitcoinStore(indexStore, transactionStore, mempoolService, blocks); if (Config.UseTor) { BackendHttpClientFactory = new HttpClientFactory(TorSettings.SocksEndpoint, backendUriGetter: () => Config.GetCurrentBackendUri()); ExternalHttpClientFactory = new HttpClientFactory(TorSettings.SocksEndpoint, backendUriGetter: null); } else { BackendHttpClientFactory = new HttpClientFactory(torEndPoint: null, backendUriGetter: () => Config.GetFallbackBackendUri()); ExternalHttpClientFactory = new HttpClientFactory(torEndPoint: null, backendUriGetter: null); } Synchronizer = new WasabiSynchronizer(BitcoinStore, BackendHttpClientFactory); LegalChecker = new(DataDir); TransactionBroadcaster = new TransactionBroadcaster(Network, BitcoinStore, BackendHttpClientFactory, WalletManager); } }
public Global(string dataDir, string torLogsFile, Config config, UiConfig uiConfig, WalletManager walletManager) { using (BenchmarkLogger.Measure()) { CrashReporter = new CrashReporter(); StoppingCts = new CancellationTokenSource(); DataDir = dataDir; Config = config; UiConfig = uiConfig; TorLogsFile = torLogsFile; Logger.InitializeDefaults(Path.Combine(DataDir, "Logs.txt")); HostedServices = new HostedServices(); WalletManager = walletManager; LegalDocuments = LegalDocuments.TryLoadAgreed(DataDir); WalletManager.OnDequeue += WalletManager_OnDequeue; WalletManager.WalletRelevantTransactionProcessed += WalletManager_WalletRelevantTransactionProcessed; var networkWorkFolderPath = Path.Combine(DataDir, "BitcoinStore", Network.ToString()); var transactionStore = new AllTransactionStore(networkWorkFolderPath, Network); var indexStore = new IndexStore(Path.Combine(networkWorkFolderPath, "IndexStore"), Network, new SmartHeaderChain()); var mempoolService = new MempoolService(); BitcoinStore = new BitcoinStore(indexStore, transactionStore, mempoolService); SingleInstanceChecker = new SingleInstanceChecker(Network); if (Config.UseTor) { Synchronizer = new WasabiSynchronizer(Network, BitcoinStore, () => Config.GetCurrentBackendUri(), Config.TorSocks5EndPoint); } else { Synchronizer = new WasabiSynchronizer(Network, BitcoinStore, Config.GetFallbackBackendUri(), null); } } }
public static void InitializeUiConfig(UiConfig uiConfig) { UiConfig = Guard.NotNull(nameof(uiConfig), uiConfig); }