Exemple #1
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());
            }
        }
Exemple #2
0
        public static bool ValidateAddress(string address, string networkName)
        {
            switch (networkName)
            {
            case CryptoCurrency.BTC:
                return(BlockchainHeper.IsBitcoinAddress(address));

            case CryptoCurrency.ETH:
                return(BlockchainHeper.IsEthereumAddress(address));

            case CryptoCurrency.VAKA:
                var vakacoinRpc = new VakacoinRpc(AppSettingHelper.GetVakacoinNode());
                return(vakacoinRpc.CheckAccountExist(address));

            default:
                throw new Exception("Network name not define!");
            }
        }
Exemple #3
0
 public void Setup()
 {
     _rpc = new VakacoinRpc("http://127.0.0.1:8000");
 }
Exemple #4
0
        private ReturnObject ValidateNetworkStatus(string walletNetworkName)
        {
            //            throw new NotImplementedException();

            /*
             * 1. Validate Bitcoin Network Status
             * 2. Validate Ethereum Network Status
             * 3. Validate Vakacoin Network Status
             *
             * Return network error in result.Message
             */

            // 3. Validate Vakacoin Network Status

            try
            {
                ReturnObject getInfoResult;
                switch (walletNetworkName)
                {
                case CryptoCurrency.BTC:
                    var bitcoinRpc = new BitcoinRpc(AppSettingHelper.GetBitcoinNode(),
                                                    AppSettingHelper.GetBitcoinRpcAuthentication());

                    getInfoResult = bitcoinRpc.GetInfo();

                    if (getInfoResult.Status == Status.STATUS_ERROR)
                    {
                        return(new ReturnObject()
                        {
                            Status = Status.STATUS_ERROR,
                            Message = "Bitcoin network error: " + getInfoResult.Message
                        });
                    }

                    break;

                case CryptoCurrency.ETH:
                    var ethRpc      = new EthereumRpc(AppSettingHelper.GetEthereumNode());
                    var blockNumber = ethRpc.GetBlockNumber();

                    if (blockNumber.Status == Status.STATUS_ERROR)
                    {
                        return(new ReturnObject()
                        {
                            Status = Status.STATUS_ERROR,
                            Message = "Ethereum network error: " + blockNumber.Message
                        });
                    }

                    break;

                case CryptoCurrency.VAKA:
                    var vakacoinRpc = new VakacoinRpc(AppSettingHelper.GetVakacoinNode());
                    getInfoResult = vakacoinRpc.GetInfo();

                    if (getInfoResult.Status == Status.STATUS_ERROR)
                    {
                        return(new ReturnObject()
                        {
                            Status = Status.STATUS_ERROR,
                            Message = "Vakacoin network error: " + getInfoResult.Message
                        });
                    }

                    break;

                default:
                    return(new ReturnObject()
                    {
                        Status = Status.STATUS_ERROR,
                        Message = "Undefined network name!"
                    });
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(new ReturnObject()
            {
                Status = Status.STATUS_SUCCESS
            });
        }