public (string assetId, string address, string addressExtension, double minCashOut) GetBlockchainCashoutData(BlockchainSettings blockchain)
            {
                try
                {
                    var currentAsset = lykkePrivateApi.Assets.GetAssets().GetResponseObject().FirstOrDefault(a =>
                    {
                        if (a.BlockchainIntegrationLayerId != null)
                        {
                            return(a.BlockchainIntegrationLayerId.ToString().ToLower() == blockchain.Type.ToLower());
                        }
                        else
                        {
                            return(false);
                        }
                    });
                    var currentAssetId = currentAsset?.Id;
                    var minCashout     = currentAsset?.CashoutMinimalAmount;

                    blockchain.SignServiceUrl = blockchain.SignServiceUrl.TrimEnd('/');
                    blockchainSign            = new BlockchainSign(blockchain.SignServiceUrl + "/api");
                    WalletCreationResponse wallet = blockchainSign.PostWallet().GetResponseObject();

                    return(currentAssetId, wallet.PublicAddress, wallet.AddressContext, minCashout.Value);
                }
                catch (Exception e)
                {
                    return($"error with {blockchain.Type}", $"error with {blockchain.Type}", $"error with {blockchain.Type}", 0);
                }
            }
Ejemplo n.º 2
0
        protected Queue <WalletCreationResponse> Wallets()
        {
            lock (_lock)
            {
                if (result == null)
                {
                    result = new Queue <WalletCreationResponse>();

                    long maxWallets = 29;
                    while (maxWallets > 0)
                    {
                        var cycleWallets = new Queue <WalletCreationResponse>();

                        for (var i = 0; i < Math.Min(MAX_WALLETS_FOR_CASH_IN, maxWallets); i++)
                        {
                            var wallet = blockchainSign.PostWallet();
                            if (wallet.StatusCode != HttpStatusCode.OK)
                            {
                                throw new Exception($"Cant create wallet. Got: {wallet.StatusCode}.  {wallet.Content}");
                            }
                            cycleWallets.Enqueue(wallet.GetResponseObject());
                        }

                        cycleWallets.ToList().ForEach(w => result.Enqueue(w));

                        if (!SetBalanceWIthManyOutputs(result.ToList()))
                        {
                            cycleWallets.ToList().ForEach(w => AddCyptoToBalanceFromExternal(w.PublicAddress, w.PrivateKey, false));
                            cycleWallets.ToList().ForEach(w => WaitForBalance(w.PublicAddress));
                        }

                        maxWallets -= MAX_WALLETS_FOR_CASH_IN;
                    }
                }
                var balances = blockchainApi.Balances.GetBalances("500", null).GetResponseObject();

                result.ToList().ForEach(w =>
                {
                    TestContext.Out.WriteLine($"wallet {w.PublicAddress} balance: {balances.Items.FirstOrDefault(wallet => wallet.Address == w.PublicAddress)?.Balance}");
                });

                //after all

                if (blockchainApi.Capabilities.GetCapabilities().GetResponseObject().IsPublicAddressExtensionRequired.HasValue&&
                    blockchainApi.Capabilities.GetCapabilities().GetResponseObject().IsPublicAddressExtensionRequired.Value)
                {
                    result.ToList().ForEach(w =>
                    {
                        w.PrivateKey = HOT_WALLET_KEY;
                    });
                }
            }

            return(result);
        }