示例#1
0
        private static void RunSend(RepositoryConfiguration repositoryConfig)
        {
            var repoFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

            var bitcoinBusiness = new BitcoinBusiness.BitcoinBusiness(repoFactory);
            var connection      = repoFactory.GetOldConnection() ?? repoFactory.GetDbConnection();

            try
            {
                while (true)
                {
                    Console.WriteLine("Start Send Bitcoin....");
                    var rpc = new BitcoinRpc(AppSettingHelper.GetBitcoinNode(),
                                             AppSettingHelper.GetBitcoinRpcAuthentication());

                    using (var bitcoinRepo = repoFactory.GetBitcoinWithdrawTransactionRepository(connection))
                    {
                        var resultSend = bitcoinBusiness.SendTransactionAsync(bitcoinRepo, rpc);
                        Console.WriteLine(JsonHelper.SerializeObject(resultSend.Result));

                        Console.WriteLine("Send Bitcoin End...");
                        Thread.Sleep(1000);
                    }
                }
            }
            catch (Exception e)
            {
                connection.Close();
                _logger.Error(e, "Send Bitcoin");
                Console.WriteLine(e.ToString());
            }
        }
示例#2
0
        public void AfterLogin()
        {
            Console.WriteLine("start");
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            Console.WriteLine("New Address");
            PersistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
            var userBus        = new UserBusiness.UserBusiness(PersistenceFactory);
            var walletBusiness = new WalletBusiness.WalletBusiness(PersistenceFactory);
            var userRepo       = PersistenceFactory.GetUserRepository(PersistenceFactory.GetOldConnection());

            var resultCreated = userBus.Login(
                new User {
                Email = "*****@*****.**", PhoneNumber = "+84988478266", FullName = "Ngo Ngoc Huan"
            });

            walletBusiness.MakeAllWalletForNewUser(userRepo.FindByEmailAddress("*****@*****.**"));
            Console.WriteLine(JsonHelper.SerializeObject(resultCreated));
            Assert.IsNotNull(resultCreated);

            resultCreated = userBus.Login(
                new User
            {
                Email = "*****@*****.**", PhoneNumber = "+84965995710", FullName = "Tieu Thanh Liem"
            });
            walletBusiness.MakeAllWalletForNewUser(userRepo.FindByEmailAddress("*****@*****.**"));
            Console.WriteLine(JsonHelper.SerializeObject(resultCreated));
            Assert.IsNotNull(resultCreated);
        }
示例#3
0
        private static void RunSend(RepositoryConfiguration repositoryConfig, string nodeUrl)
        {
            var repoFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

            var business   = new VakacoinBusiness.VakacoinBusiness(repoFactory);
            var connection = repoFactory.GetOldConnection() ?? repoFactory.GetDbConnection();

            if (nodeUrl == null)
            {
                Console.WriteLine("node url null");
                return;
            }

            try
            {
                while (true)
                {
                    try
                    {
                        var rpc = new VakacoinRpc(nodeUrl);

                        business.SetAccountRepositoryForRpc(rpc);

                        Console.WriteLine("Start Send Vakacoin...");
                        using (var repo = repoFactory.GetVakacoinWithdrawTransactionRepository(connection))
                        {
                            var resultSend = business.SendTransactionAsync(repo, rpc);
                            Console.WriteLine(JsonHelper.SerializeObject(resultSend.Result));

                            Console.WriteLine("Send Vakacoin End...");
                            Thread.Sleep(100);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
            catch (Exception e)
            {
                connection.Close();
                Console.WriteLine(e.ToString());
            }
        }
        public void WithdrawVakacoin()
        {
            var walletRepository =
                _vakapayRepositoryFactory.GetWalletRepository(_vakapayRepositoryFactory.GetOldConnection());
            var userRepo = _vakapayRepositoryFactory.GetUserRepository(_vakapayRepositoryFactory.GetOldConnection());
            var wallet   = walletRepository.FindByUserAndNetwork(
                userRepo.FindByEmailAddress("*****@*****.**").Id,
                CryptoCurrency.VAKA);

            var res = _walletBusiness.Withdraw(wallet, "useraaaaaaab", (decimal)0.0001, 0);

            Assert.AreEqual(res.Status, Status.STATUS_SUCCESS);
        }
示例#5
0
        private static void RunScan(RepositoryConfiguration repositoryConfig)
        {
            var repoFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

            var ethereumBusiness = new EthereumBusiness.EthereumBusiness(repoFactory);
            var walletBusiness   = new WalletBusiness.WalletBusiness(repoFactory);
            var connection       = repoFactory.GetOldConnection() ?? repoFactory.GetDbConnection();

            try
            {
                while (true)
                {
                    Console.WriteLine("==========Start Scan Ethereum==========");

                    var rpc = new EthereumRpc(AppSettingHelper.GetEthereumNode());

                    using (var ethereumRepo = repoFactory.GetEthereumWithdrawTransactionRepository(connection))
                    {
                        using (var ethereumDepoRepo = repoFactory.GetEthereumDepositeTransactionRepository(connection))
                        {
                            var resultSend =
                                ethereumBusiness
                                .ScanBlockAsync <EthereumWithdrawTransaction, EthereumDepositTransaction,
                                                 EthereumBlockResponse, EthereumTransactionResponse>(CryptoCurrency.ETH, walletBusiness,
                                                                                                     ethereumRepo, ethereumDepoRepo, rpc);
                            Console.WriteLine(JsonHelper.SerializeObject(resultSend.Result));


                            Console.WriteLine("==========Scan Ethereum End==========");
                            Console.WriteLine("==========Wait for next scan==========");
                            Thread.Sleep(5000);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                connection.Close();
                Console.WriteLine(e.ToString());
            }
        }