public void CreateAllWalletForUser(string userId)
        {
            var repositoryConfig = new RepositoryConfiguration()
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            var persistence = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

            _walletBusiness =
                new Vakapay.WalletBusiness.WalletBusiness(persistence);
            var user = new User();

            user.Id = userId;

            //blockChain.Name = NetworkName.ETH;
            //var resultTest = _walletBusiness.CreateNewWallet(user, blockChain.Name);
            //Assert.AreEqual(Status.StatusSuccess, resultTest.Status);

            //blockChain.Name = NetworkName.BTC;
            //_walletBusiness.CreateNewWallet(user, blockChain.Name);
            //Assert.AreEqual(Status.StatusSuccess, resultTest.Status);

            //blockChain.Name = NetworkName.VAKA;
            //_walletBusiness.CreateNewWallet(user, blockChain.Name);
            var resultTest = _walletBusiness.MakeAllWalletForNewUser(user);

            Console.WriteLine(JsonHelper.SerializeObject(resultTest));
            Assert.AreEqual(Status.STATUS_SUCCESS, resultTest.Status);
        }
        static void Main(string[] args)
        {
            var persistenceFactory = new SmartContractRepositoryMysqlPersistenceFactory(new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            });


            var addAddressBusiness = new AutoCreateAddress.AutoCreateAddress(persistenceFactory);

            while (true)
            {
                try
                {
                    var result = addAddressBusiness.CreateAddressAsync();
                    Console.WriteLine(JsonHelper.SerializeObject(result));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }

                Thread.Sleep(1000);
            }
        }
        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);
        }
Example #4
0
        public void FakeDeposite(int numOfTrans)
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

            _ethBus = new Vakapay.EthereumBusiness.EthereumBusiness(persistenceFactory);
            var trans = new EthereumDepositTransaction()
            {
                UserId      = "8377a95b-79b4-4dfb-8e1e-b4833443c306",
                ToAddress   = "0x12890d2cce102216644c59dae5baed380d84830c",
                FromAddress = "0x3a2e25cfb83d633c184f6e4de1066552c5bf4517",
                Amount      = 10
            };
            ReturnObject outPut = null;

            for (int i = 0; i < numOfTrans; i++)
            {
                outPut = _ethBus.FakeDepositTransaction(trans);
            }
            Console.WriteLine(JsonHelper.SerializeObject(outPut));
            Assert.IsNotNull(outPut);
        }
Example #5
0
        private static void Main()
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
            var sendSmsBusiness    = new SendSmsBusiness.SendSmsBusiness(persistenceFactory);

            while (true)
            {
                try
                {
                    var result = sendSmsBusiness.SendSmsAsync(AppSettingHelper.GetElasticSmsUrl(),
                                                              AppSettingHelper.GetElasticApiKey());
                    Console.WriteLine(JsonHelper.SerializeObject(result.Result));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }

                Thread.Sleep(1000);
            }
        }
Example #6
0
        private static void Main(string[] args)
        {
            try
            {
                CacheHelper.DeleteCacheString("cache");

                var repositoryConfig = new RepositoryConfiguration
                {
                    ConnectionString = AppSettingHelper.GetDbConnection()
                };
                string rootAddress  = "0x15118dB6ED8Fa2f461d62F395DC55C51c42f3488";
                string rootPassword = "******";
                EthereumRpc.SetAdminAddressPassword(rootAddress, rootPassword);


                for (var i = 0; i < 1; i++)
                {
                    var ts = new Thread(() => RunSend(repositoryConfig));
                    ts.Start();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
        public async System.Threading.Tasks.Task CreateNewAddressAsync(string walletId)
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

            _ethBus = new Vakapay.EthereumBusiness.EthereumBusiness(persistenceFactory);
            var connection = persistenceFactory.GetDbConnection();

            using (var ethAddressRepos = persistenceFactory.GetEthereumAddressRepository(connection))
            {
                _walletBusiness = new WalletBusiness.WalletBusiness(persistenceFactory);

                string pass = "******";
                //	var resultTest = _ethBus.CreateNewAddAddress(wallet);
                var outPut =
                    await _ethBus.CreateAddressAsync <EthereumAddress>(ethAddressRepos, RpcClass, walletId,
                                                                       pass);

                Assert.IsNotNull(outPut);
            }
        }
Example #8
0
        public AddressController()
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            VakapayRepositoryFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
        }
Example #9
0
        private static void Main(string[] args)
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            RunScan(repositoryConfig);
        }
Example #10
0
        public BaseActionFilter()
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            _repositoryFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
        }
Example #11
0
        public UserController()
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            VakapayRepositoryFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
            userBusiness             = new UserBusiness.UserBusiness(VakapayRepositoryFactory);
        }
Example #12
0
        static void Main(string[] args)
        {
            Console.WriteLine("start auto scan");
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
            var ethBus             = new Vakapay.EthereumBusiness.EthereumBusiness(persistenceFactory);
            //_ethBus.AutoScanBlock();
        }
Example #13
0
        public void Setup()
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

            // New DB connection
            var accountRepo = persistenceFactory.GetVakacoinAccountRepository(persistenceFactory.GetDbConnection());
        }
Example #14
0
        public static void RunPortfolioHistory()
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };
            var persistenceFactory       = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
            var walletBusiness           = new WalletBusiness.WalletBusiness(persistenceFactory);
            var portfolioHistoryBusiness = new PortfolioHistoryBusiness.PortfolioHistoryBusiness(persistenceFactory);

            SavePortfolioHistoryEvery(DashboardConfig.INTERVAL, walletBusiness, portfolioHistoryBusiness);
        }
Example #15
0
        public void Setup()
        {
            var repsitoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            VakapayRepositoryMysqlPersistenceFactory persistenceFactory =
                new VakapayRepositoryMysqlPersistenceFactory(repsitoryConfig);

            _mailBusiness = new SendMailBusiness.SendMailBusiness(persistenceFactory);
        }
        public void Setup()
        {
            var repositoryConfig = new RepositoryConfiguration()
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            _vakapayRepositoryFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

            _walletBusiness = new WalletBusiness.WalletBusiness(_vakapayRepositoryFactory);
            _userBusiness   =
                new Vakapay.UserBusiness.UserBusiness(_vakapayRepositoryFactory);
        }
        public void ValidateAddress(string networkName, bool result, string address)
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

            _walletBusiness =
                new Vakapay.WalletBusiness.WalletBusiness(persistenceFactory);

            Assert.AreEqual(result, Vakapay.WalletBusiness.WalletBusiness.ValidateAddress(address, networkName));
        }
        public void InitFakeAddressAndCoin()
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            //Create user active for test
            var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
            var connection         = persistenceFactory.GetDbConnection();
            var userRepo           = persistenceFactory.GetUserRepository(connection);
            var walletRepo         = persistenceFactory.GetWalletRepository(connection);


            //fake userId
            for (int i = 1; i < 10; i++)
            {
                var ins = userRepo.Insert(
                    new User()
                {
                    Id     = i.ToString(),
                    Status = "Active"
                }
                    );
                Assert.AreEqual(Status.STATUS_SUCCESS, ins.Status);
            }

            //create wallet without address
            for (int i = 1; i < 10; i++)
            {
                CreateAllWalletForUser(i.ToString());
            }

            //insert address into WalletDb
            // and insert to ethereumAddress
            for (int i = 1; i < 10; i++)
            {
                var prepareWallet = walletRepo.FindByUserAndNetwork(i.ToString(), CryptoCurrency.ETH);
                CreateNewAddressAsync(prepareWallet.Id);
            }

            //send coin from rootAddress to new address
            for (int i = 1; i < 10; i++)
            {
                var prepareWallet = walletRepo.FindByUserAndNetwork(i.ToString(), CryptoCurrency.ETH);
                //Todo update prepareWallet.Address
                //				InsertPendingTxsToWithdraw("46b4594c-a45a-400d-86ce-9a7869d61180", prepareWallet.Address);
            }
        }
Example #19
0
        static void Main(string[] args)
        {
            Console.WriteLine("Program Test Make new Wallet!!!!");
            try
            {
                var repositoryConfig = new RepositoryConfiguration
                {
                    ConnectionString = AppSettingHelper.GetDbConnection()
                };

                var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

//                foreach (var VARIABLE in RpcClient.GetAllTransactionsInBlock("16302351"))
//                {
//                    Console.WriteLine(VARIABLE.ToString());
//                }
//                var result = vakacoinBusiness.CreateTransactionHistory();


                var walletBusiness = new WalletBusiness.WalletBusiness(persistenceFactory);

                var walletLst = walletBusiness.GetAllWallet();

                foreach (var variable in walletLst)
                {
                    Console.WriteLine(JsonHelper.SerializeObject(variable));
                }

//                var user = new User
//                {
//                    Id = CommonHelper.GenerateUuid(),
//                };
//                var blockChainNetwork = new BlockchainNetwork
//                {
//                    Name = "Ethereum",
//                    Status = Status.StatusActive,
//                    Sysbol = "ETH",
//                    Id = CommonHelper.GenerateUuid()
//                };
//
//                var result = WalletBusiness.CreateNewWallet(user, blockChainNetwork);

//                Console.WriteLine(JsonHelper.SerializeObject(walletLst));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #20
0
        private static void Main(string[] args)
        {
            try
            {
                var repositoryConfig = new RepositoryConfiguration
                {
                    ConnectionString = AppSettingHelper.GetDbConnection()
                };

                _persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

                var btcBusiness = new BitcoinBusiness.BitcoinBusiness(_persistenceFactory);
                var rpc         = new BitcoinRpc(AppSettingHelper.GetBitcoinNode(),
                                                 AppSettingHelper.GetBitcoinRpcAuthentication());

                var transaction = rpc.FindTransactionByHash(args[0]);
                Logger.Debug("BitcoinNotify =>> BTCTransactionModel: " + transaction.Data);
                var transactionModel = BtcTransactionModel.FromJson(transaction.Data);
                if (transactionModel.BtcTransactionDetailsModel != null &&
                    transactionModel.BtcTransactionDetailsModel.Length > 0)
                {
                    foreach (var transactionModelDetail in transactionModel.BtcTransactionDetailsModel)
                    {
                        _walletBusiness = new WalletBusiness.WalletBusiness(_persistenceFactory);
                        if (transactionModelDetail.Category.Equals("receive"))
                        {
                            HandleNotifyDataReceiver(transactionModel, transactionModelDetail, btcBusiness);
                        }
                        else if (transactionModelDetail.Category.Equals("send"))
                        {
                            // if isExist(by address and transactionId) then update, else insert
                            HandleNotifyDataSend(transactionModel, transactionModelDetail, btcBusiness);
                        }
                    }
                }
                else
                {
                    Logger.Debug("BitcoinNotify BtcTransactionDetailsModel is not exist");
                }
            }
            catch (Exception e)
            {
                Logger.Error(e, "BitcoinNotify exception");
            }
        }
Example #21
0
        public void FakeWalletID()
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
            var walletBusiness     = new WalletBusiness.WalletBusiness(persistenceFactory);
            var user = new User
            {
                Id = CommonHelper.GenerateUuid(),
            };
            var result = walletBusiness.CreateNewWallet(user, CryptoCurrency.ETH);

            Console.WriteLine(JsonHelper.SerializeObject(result));
            Assert.IsNotNull(result);
        }
Example #22
0
        private static void Main(string[] args)
        {
            try
            {
                var repositoryConfig = new RepositoryConfiguration
                {
                    ConnectionString = AppSettingHelper.GetDbConnection()
                };

                for (var i = 0; i < 10; i++)
                {
                    var ts = new Thread(() => RunScan(repositoryConfig));
                    ts.Start();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Example #23
0
        public async System.Threading.Tasks.Task CreateNewAddressAsync()
        {
            Console.WriteLine("start");
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            Console.WriteLine("New Address");
            PersistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
            var connection = PersistenceFactory.GetDbConnection();

            _btcBus = new Vakapay.BitcoinBusiness.BitcoinBusiness(PersistenceFactory);
            var    bitcoinRepo   = PersistenceFactory.GetBitcoinAddressRepository(connection);
            string walletId      = CommonHelper.RandomString(15);
            var    resultCreated =
                await _btcBus.CreateAddressAsync <BitcoinAddress>(bitcoinRepo, RpcClass, walletId);

            Console.WriteLine(JsonHelper.SerializeObject(resultCreated));
            Assert.IsNotNull(resultCreated);
        }
Example #24
0
        public void UserInfo()
        {
            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 search =
                new Dictionary <string, string>
            {
                { "Email", "" }
            };
            var resultCreated = userBus.GetUserInfo(search);

            Console.WriteLine(JsonHelper.SerializeObject(resultCreated));
        }
Example #25
0
        public static void Main(string[] args)
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection(),
            };
            var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

            var helper = new VakacoinChainHelper(
                int.Parse(AppSettingHelper.GetVakacoinBlockInterval()),
                new VakacoinRpc(AppSettingHelper.GetVakacoinNode()),
                new VakacoinBusiness.VakacoinBusiness(persistenceFactory),
                new WalletBusiness.WalletBusiness(persistenceFactory),
                new SendMailBusiness.SendMailBusiness(persistenceFactory)
                );

            foreach (GetBlockResponse block in helper.StreamBlock())
            {
                helper.ParseTransaction(block);
            }
        }
Example #26
0
        static void Main(string[] args)
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };


            var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
            var ethereumWithdrawTransactionRepository =
                persistenceFactory.GetEthereumWithdrawTransactionRepository(persistenceFactory.GetDbConnection());

            try
            {
                for (var i = 0; i < 20; i++)
                {
                    var trans = new EthereumWithdrawTransaction
                    {
                        Amount       = 1,
                        Fee          = 0,
                        BlockNumber  = 0,
                        FromAddress  = null,
                        Hash         = null,
                        IsProcessing = 0,
//                        NetworkName = "ETH",
                        Status    = Status.STATUS_PENDING,
                        Version   = 0,
                        ToAddress = "0x13f022d72158410433cbd66f5dd8bf6d2d129924"
                    };
                    var resultInsert = ethereumWithdrawTransactionRepository.Insert(trans);
                    Console.WriteLine(JsonHelper.SerializeObject(resultInsert));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
        public void CreateRadomPendingTxsToWithdraw()
        {
            var repositoryConfig = new RepositoryConfiguration()
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            var persistence = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

            _walletBusiness =
                new Vakapay.WalletBusiness.WalletBusiness(persistence);


            var connection = persistence.GetDbConnection();
            var walletRepo = persistence.GetWalletRepository(connection);

            ReturnObject resultTest = null;

            for (int i = 0; i < 1000; i++)
            {
                var rndFrom    = new Random().Next(1, 10);
                var rndTo      = new Random().Next(1, 10);
                var fromWallet = walletRepo.FindByUserAndNetwork(rndFrom.ToString(), CryptoCurrency.ETH);

                while (rndFrom == rndTo)
                {
                    rndTo = new Random().Next(1, 10);
                }

                var toWalletAddr = walletRepo.FindByUserAndNetwork(rndTo.ToString(), CryptoCurrency.ETH);
                // TODO
                //				resultTest = _walletBusiness.Withdraw(fromWallet, toWalletAddr.Address, 1);
            }

            Console.WriteLine(JsonHelper.SerializeObject(resultTest));
            Assert.AreEqual(Status.STATUS_SUCCESS, resultTest.Status);
        }
Example #28
0
        public void FakePeningTransaction(int numOfTrans)
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

            _btcBus = new Vakapay.BitcoinBusiness.BitcoinBusiness(persistenceFactory);
            var trans = new BitcoinWithdrawTransaction
            {
                ToAddress = "2Muk22rW4opjTd18KA48bzHUqiG19ZUJDLb",
                Amount    = (decimal)0.0001
            };
            ReturnObject outPut = null;

            for (int i = 0; i < numOfTrans; i++)
            {
                outPut = _btcBus.FakePendingTransaction(trans);
            }
            Console.WriteLine(JsonHelper.SerializeObject(outPut));
            Assert.IsNotNull(outPut);
        }
Example #29
0
        public async System.Threading.Tasks.Task CreateNewAddressAsync()
        {
            Console.WriteLine("WTF");
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            Console.WriteLine("MAKE NEW");
            PersistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
            var connection = PersistenceFactory.GetDbConnection();

            _ethBus = new Vakapay.EthereumBusiness.EthereumBusiness(PersistenceFactory);
            using (var ethAddressRepos = PersistenceFactory.GetEthereumAddressRepository(connection))
            {
                string walletId = CommonHelper.RandomString(15);
                string pass     = CommonHelper.RandomString(15);
                var    outPut   =
                    await _ethBus.CreateAddressAsync <EthereumAddress>(ethAddressRepos, RpcClass, walletId, pass);

                Console.WriteLine(JsonHelper.SerializeObject(outPut));
                Assert.IsNotNull(outPut);
            }
        }
Example #30
0
        private static void Main(string[] args)
        {
            try
            {
                CacheHelper.DeleteCacheString("cache");

                var repositoryConfig = new RepositoryConfiguration
                {
                    ConnectionString = AppSettingHelper.GetDbConnection()
                };
                string rootAddress  = "0x12890d2cce102216644c59dae5baed380d84830c";
                string rootPassword = "******";
                EthereumRpc.SetAdminAddressPassword(rootAddress, rootPassword);
                for (var i = 0; i < 10; i++)
                {
                    var ts = new Thread(() => RunSend(repositoryConfig));
                    ts.Start();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }