/// <summary> /// Geting the number of confirmations /// </summary> /// <param name="address"></param> /// <returns></returns> public async Task <ActionResult> StatusAsync(String address) { //Proverka na statusot na transakcijata //go proveruvame saldoto za ovaa adresa StatusOfTransaction statusOfTransaction = new StatusOfTransaction(); statusOfTransaction.AddressForPayment = address; //saldo so 0 potvrdi String path = "addressbalance/" + address + "?confirmations=0"; BallanceOfAddress ballance = await GetBalanceOfAddressWithConfirmations(path); if (ballance.getBalanceAsEuro() == 0) { statusOfTransaction.Balance = ballance; statusOfTransaction.BitcoinsSent = false; statusOfTransaction.BlockConfirmations = 0; return(View(statusOfTransaction)); } //saldo so 1 potvrda path = "addressbalance/" + address + "?confirmations=1"; ballance = await GetBalanceOfAddressWithConfirmations(path); if (ballance.getBalanceAsEuro() == 0) { statusOfTransaction.Balance = ballance; statusOfTransaction.BitcoinsSent = true; statusOfTransaction.BlockConfirmations = 0; return(View(statusOfTransaction)); } //saldo so 2 potvrdi path = "addressbalance/" + address + "?confirmations=2"; ballance = await GetBalanceOfAddressWithConfirmations(path); if (ballance.getBalanceAsEuro() == 0) { statusOfTransaction.Balance = ballance; statusOfTransaction.BitcoinsSent = true; statusOfTransaction.BlockConfirmations = 1; return(View(statusOfTransaction)); } //saldo so 3 potvrdi path = "addressbalance/" + address + "?confirmations=3"; ballance = await GetBalanceOfAddressWithConfirmations(path); if (ballance.getBalanceAsEuro() == 0) { statusOfTransaction.Balance = ballance; statusOfTransaction.BitcoinsSent = true; statusOfTransaction.BlockConfirmations = 2; return(View(statusOfTransaction)); } statusOfTransaction.Balance = ballance; statusOfTransaction.BitcoinsSent = true; statusOfTransaction.BlockConfirmations = 3; return(View(statusOfTransaction)); }
static async Task <BallanceOfAddress> GetBalanceOfAddress(String path) { //prakjanje na http baranje i prevzimanje na podatoci vo vrska so saldoto na konkretnata adresa BallanceOfAddress ballance = null; HttpResponseMessage httpResponseMessage = await client.GetAsync(ControllerNameForPay + path).ConfigureAwait(false); if (httpResponseMessage.IsSuccessStatusCode) { ballance = await httpResponseMessage.Content.ReadAsAsync <BallanceOfAddress>(); } return(ballance); }
/// <summary> /// Get ballance of an address wiht the number of confirmations /// </summary> /// <param name="path"></param> /// <returns></returns> static async Task <BallanceOfAddress> GetBalanceOfAddressWithConfirmations(String path) { //prakjanje na http baranje i prevzimanje na podatoci vo vrska so saldoto na konkretnata adresa BallanceOfAddress ballance = new BallanceOfAddress(); HttpResponseMessage httpResponseMessage = await clientSimpleApi.GetAsync(path).ConfigureAwait(false); if (httpResponseMessage.IsSuccessStatusCode) { ballance.Balance = Convert.ToInt32(await httpResponseMessage.Content.ReadAsStringAsync()); } return(ballance); }