private static void RunSend(RepositoryConfiguration repositoryConfig) { var repoFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig); var ethereumBusiness = new EthereumBusiness.EthereumBusiness(repoFactory); var connection = repoFactory.GetDbConnection(); try { while (true) { Console.WriteLine("Start Send Ethereum...."); var rpc = new EthereumRpc(AppSettingHelper.GetEthereumNode()); using (var ethereumRepo = repoFactory.GetEthereumWithdrawTransactionRepository(connection)) { var resultSend = ethereumBusiness.SendTransactionAsync(ethereumRepo, rpc); Console.WriteLine(JsonHelper.SerializeObject(resultSend.Result)); Console.WriteLine("Send Ethereum End..."); Thread.Sleep(1000); } } } catch (Exception e) { connection.Close(); Console.WriteLine(e.ToString()); } }
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()); } }
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); } }
public BaseActionFilter() { var repositoryConfig = new RepositoryConfiguration { ConnectionString = AppSettingHelper.GetDbConnection() }; _repositoryFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig); connection = _repositoryFactory.GetDbConnection(); }
public void Setup() { var repositoryConfig = new RepositoryConfiguration { ConnectionString = AppSettingHelper.GetDbConnection() }; var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig); // New DB connection var accountRepo = persistenceFactory.GetVakacoinAccountRepository(persistenceFactory.GetDbConnection()); }
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); } }
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()); } }
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()); } }
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); }
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); }
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); } }