Beispiel #1
0
        private async Task DistFundsTimeAsync(Address a1, string fromHouseAddress)
        {
            List <string> randomDividedAmounts = Utilities.GetDistributions(random, a1.AmountToSend);

            foreach (string da in randomDividedAmounts)
            {
                int sleep = random.Next(1, 10);
                Console.WriteLine("Waiting {0} seconds before distributing {1} jobcoins to {2}", sleep, da, a1.SubmittedAddr);
                Thread.Sleep(sleep * 1000);
                SimpleTrans final = new SimpleTrans {
                    amount = da, fromAddress = fromHouseAddress, toAddress = a1.SubmittedAddr
                };
                await PostHouseAmountAsync(final);
            }

            SimpleSend submitaddr = new SimpleSend {
                Amount = "", DepositAddress = a1.DepositAddress, Status = 3
            };

            await PutAddressesAsync(submitaddr);

            if (randomDividedAmounts.Count > 0)
            {
                Console.WriteLine("Distribution to Account {0} Completed", a1.SubmittedAddr);
            }
        }
Beispiel #2
0
        public async Task PutAddressesAsync(SimpleSend submitaddr)
        {
            using (var client = new HttpClient())
            {
                try
                {
                    client.BaseAddress = new Uri(restURLEndpoint);
                    var stringContent = new StringContent(JsonConvert.SerializeObject(submitaddr), Encoding.UTF8, "application/json");
                    var response      = await client.PutAsync("/api/depositaddress", stringContent);

                    response.EnsureSuccessStatusCode();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }
        }
Beispiel #3
0
        public async void Start(string commissionAccountName, string houseAccountName)
        {
            try
            {
                Console.WriteLine("Begin Polling Network");
                while (!this.serverCancel.IsCancellationRequested)
                {
                    await Task.Run(async() =>
                    {
                        Thread.Sleep(500);
                        Console.WriteLine("Scanning for Queued Forward Addresses");
                        List <Address> addresses = await this.GetAddressesAsync(1);
                        Console.WriteLine("Retrieved {0} Newly Queued Forward Addresses", addresses.Count());
                        Thread.Sleep(500);
                        Console.WriteLine("Scanning for Transactions on the JobCoin Network");
                        List <Transaction> transactions = await this.GetTransactionsAsync();
                        var nameInOne = transactions.Where(t2 => addresses.Any(t1 => t2.toAddress.Contains(t1.DepositAddress)));
                        Console.WriteLine("Retrieved {0} Transactions with funds sent to Generated Deposit Addresses", nameInOne.Count());
                        foreach (var n in nameInOne)
                        {
                            string newAmount      = await SendToHouseAsync(n.amount, n.fromAddress, commissionAccountName, houseAccountName, n.toAddress);
                            SimpleSend submitaddr = new SimpleSend {
                                Amount = newAmount, DepositAddress = n.toAddress, Status = 2
                            };
                            await PutAddressesAsync(submitaddr);
                        }

                        await DoleFromHouseAsync(houseAccountName);
                    });
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }