Exemplo n.º 1
0
        public static async Task InitializeWalletServiceAsync(KeyManager keyManager)
        {
            while (!Initialized)
            {
                await Task.Delay(100);
            }

            if (Config.UseTor.Value)
            {
                ChaumianClient = new CcjClient(Synchronizer, Network, keyManager, () => Config.GetCurrentBackendUri(), Config.GetTorSocks5EndPoint());
            }
            else
            {
                ChaumianClient = new CcjClient(Synchronizer, Network, keyManager, Config.GetFallbackBackendUri(), null);
            }
            WalletService = new WalletService(BitcoinStore, keyManager, Synchronizer, ChaumianClient, MemPoolService, Nodes, DataDir, Config.ServiceConfiguration);

            ChaumianClient.Start();
            Logger.LogInfo("Start Chaumian CoinJoin service...");

            using (CancelWalletServiceInitialization = new CancellationTokenSource())
            {
                Logger.LogInfo("Starting WalletService...");
                await WalletService.InitializeAsync(CancelWalletServiceInitialization.Token);

                Logger.LogInfo("WalletService started.");
            }
            CancelWalletServiceInitialization      = null;        // Must make it null explicitly, because dispose won't make it null.
            WalletService.Coins.CollectionChanged += Coins_CollectionChanged;
        }
Exemplo n.º 2
0
        public static async Task InitializeWalletServiceAsync(KeyManager keyManager)
        {
            ChaumianClient = new CcjClient(Network, BlindingPubKey, keyManager, Config.GetCurrentBackendUri());
            WalletService  = new WalletService(keyManager, IndexDownloader, ChaumianClient, MemPoolService, Nodes, BlocksDir);

            ChaumianClient.Start();
            Logger.LogInfo("Start Chaumian CoinJoin service...");

            using (CancelWalletServiceInitialization = new CancellationTokenSource())
            {
                Logger.LogInfo("Starting WalletService...");
                await WalletService.InitializeAsync(CancelWalletServiceInitialization.Token);

                Logger.LogInfo("WalletService started.");
            }
            CancelWalletServiceInitialization = null;             // Must make it null explicitly, because dispose won't make it null.
        }
Exemplo n.º 3
0
        public static async Task InitializeWalletServiceAsync(KeyManager keyManager)
        {
            ChaumianClient = new CcjClient(Synchronizer, Network, BlindingPubKey, keyManager, Config.GetCurrentBackendUri(), Config.GetTorSocks5EndPoint());
            WalletService  = new WalletService(keyManager, Synchronizer, ChaumianClient, MemPoolService, Nodes, DataDir);

            ChaumianClient.Start();
            Logger.LogInfo("Start Chaumian CoinJoin service...");

            using (CancelWalletServiceInitialization = new CancellationTokenSource())
            {
                Logger.LogInfo("Starting WalletService...");
                await WalletService.InitializeAsync(CancelWalletServiceInitialization.Token);

                Logger.LogInfo("WalletService started.");
            }
            CancelWalletServiceInitialization      = null;        // Must make it null explicitly, because dispose won't make it null.
            WalletService.Coins.CollectionChanged += Coins_CollectionChanged;
        }
Exemplo n.º 4
0
        public async Task InitializeWalletServiceAsync(KeyManager keyManager)
        {
            using (_cancelWalletServiceInitialization = new CancellationTokenSource())
            {
                var token = _cancelWalletServiceInitialization.Token;
                while (!Initialized)
                {
                    await Task.Delay(100, token);
                }

                if (Config.UseTor)
                {
                    ChaumianClient = new CcjClient(Synchronizer, Network, keyManager, () => Config.GetCurrentBackendUri(), Config.TorSocks5EndPoint);
                }
                else
                {
                    ChaumianClient = new CcjClient(Synchronizer, Network, keyManager, Config.GetFallbackBackendUri(), null);
                }

                try
                {
                    keyManager.CorrectBlockHeights(BitcoinStore.HashChain); // Block heights are wrong sometimes. It's a hack. We have to retroactively fix existing wallets, but also we have to figure out where we ruin the block heights.
                }
                catch (Exception ex)                                        // Whatever this is not critical, but let's log it.
                {
                    Logger.LogWarning(ex, nameof(Global));
                }

                WalletService = new WalletService(BitcoinStore, keyManager, Synchronizer, ChaumianClient, MempoolService, Nodes, DataDir, Config.ServiceConfiguration);

                ChaumianClient.Start();
                Logger.LogInfo("Start Chaumian CoinJoin service...");

                Logger.LogInfo($"Starting {nameof(WalletService)}...");
                await WalletService.InitializeAsync(token);

                Logger.LogInfo($"{nameof(WalletService)} started.");

                token.ThrowIfCancellationRequested();
                WalletService.Coins.CollectionChanged += Coins_CollectionChanged;
            }
            _cancelWalletServiceInitialization = null;             // Must make it null explicitly, because dispose won't make it null.
        }