public async Task <IActionResult> WalletReceivePayment([FromBody] ReceivePaymentDto receivePaymentDto) { double balance = 0d; try { if (receivePaymentDto.RedemptionMessage != null) { await actorService .MasterKey(receivePaymentDto.Credentials.Password.ToSecureString()) .Identifier(receivePaymentDto.Credentials.Identifier.ToSecureString()) .FromAddress(receivePaymentDto.FromAddress) .ReceivePaymentRedemptionKey(JsonConvert.SerializeObject(receivePaymentDto.RedemptionMessage)); } else { await actorService .MasterKey(receivePaymentDto.Credentials.Password.ToSecureString()) .Identifier(receivePaymentDto.Credentials.Identifier.ToSecureString()) .FromAddress(receivePaymentDto.FromAddress) .ReceivePayment(); } balance = await actorService.CheckBalance(); } catch (Exception ex) { balance = await actorService.CheckBalance(); return(new ObjectResult(new { error = ex.Message, statusCode = 500, balance = balance })); } return(new OkObjectResult(new { balance = balance })); }
public override async Task Execute() { using (var identifier = Prompt.GetPasswordAsSecureString("Identifier:", ConsoleColor.Yellow)) using (var password = Prompt.GetPasswordAsSecureString("Password:"******"Address:", null, ConsoleColor.Red); if (!string.IsNullOrEmpty(address)) { await Spinner.StartAsync("Processing receive payment(s) ...", async spinner => { this.spinner = spinner; await Task.Delay(500); try { await actorService .MasterKey(password) .Identifier(identifier) .FromAddress(address) .ReceivePayment(); } catch (Exception ex) { logger.LogError($"Message: {ex.Message}\n Stack: {ex.StackTrace}"); throw ex; } finally { var lastAmount = Convert.ToString(await walletService.LastTransactionAmount(identifier, password, TransactionType.Receive)); var balance = Convert.ToString(await actorService.CheckBalance()); spinner.Text = $"Received:{lastAmount } Available Balance: {balance}"; } }); } } }
public override async Task Execute() { using (var identifier = Prompt.GetPasswordAsSecureString("Identifier:", ConsoleColor.Yellow)) using (var password = Prompt.GetPasswordAsSecureString("Password:"******"To:", null, ConsoleColor.Red); var amount = Prompt.GetString("Amount:", null, ConsoleColor.Red); var memo = Prompt.GetString("Memo:", null, ConsoleColor.Green); var yesNo = Prompt.GetYesNo("Send redemption key to message pool?", true, ConsoleColor.Yellow); if (double.TryParse(amount, out double t)) { await Spinner.StartAsync("Processing payment ...", async spinner => { this.spinner = spinner; try { var sent = await actorService .MasterKey(password) .Identifier(identifier) .Amount(t) .ToAddress(address) .Memo(memo) .SendPayment(); if (sent.Equals(false)) { var failedMessage = JsonConvert.SerializeObject(actorService.GetLastError().GetValue("message")); logger.LogCritical(failedMessage); spinner.Fail(failedMessage); return; } switch (yesNo) { case true: var networkMessage = await actorService.SendPaymentMessage(true); var success = networkMessage.GetValue("success").ToObject <bool>(); if (success.Equals(false)) { spinner.Fail(JsonConvert.SerializeObject(networkMessage.GetValue("message"))); } break; case false: var localMessage = await actorService.SendPaymentMessage(false); SaveRedemptionKeyLocal(localMessage); break; } } catch (Exception ex) { logger.LogError(ex.StackTrace); throw ex; } finally { spinner.Text = $"Available Balance: {Convert.ToString(await actorService.CheckBalance())}"; } }); } } }