public override async Task Execute() { try { using (var identifier = Prompt.GetPasswordAsSecureString("Identifier:", ConsoleColor.Yellow)) using (var password = Prompt.GetPasswordAsSecureString("Password:"******"wallets/{id.Value}/wallet"); var w = JsonConvert.SerializeObject(data); console.WriteLine(w); } } } } catch (Exception e) { logger.LogError(e, "Exception"); throw; } }
/// <summary> /// Adds the transaction. /// </summary> /// <returns>The transaction.</returns> /// <param name="identifier">Identifier.</param> /// <param name="password">Password.</param> /// <param name="transaction">Transaction.</param> public async Task AddTransaction(SecureString identifier, SecureString password, TransactionDto transaction) { if (identifier == null) { throw new ArgumentNullException(nameof(identifier)); } if (password == null) { throw new ArgumentNullException(nameof(password)); } if (transaction == null) { throw new ArgumentNullException(nameof(transaction)); } using (var insecureIdentifier = identifier.Insecure()) { var found = false; var data = await vaultService.GetDataAsync(identifier, password, $"wallets/{insecureIdentifier.Value}/wallet"); if (data.Data.TryGetValue("transactions", out object txs)) { foreach (JObject item in ((JArray)txs).Children().ToList()) { var hash = item.GetValue("Hash"); found = hash.Value <string>().Equals(transaction.Hash); } if (!found) { ((JArray)txs).Add(JObject.FromObject(transaction)); } } else { data.Data.Add("transactions", new List <TransactionDto> { transaction }); } await vaultService.SaveDataAsync(identifier, password, $"wallets/{insecureIdentifier.Value}/wallet", data.Data); } }
public override async Task Execute() { try { using (var identifier = Prompt.GetPasswordAsSecureString("Identifier:", ConsoleColor.Yellow)) using (var password = Prompt.GetPasswordAsSecureString("Password:"******"Address:", null, ConsoleColor.Red); using (var insecureIdentifier = identifier.Insecure()) using (var insecurePassword = password.Insecure()) { await vaultService.GetDataAsync(identifier, password, $"wallets/{insecureIdentifier.Value}/wallet"); } if (!string.IsNullOrEmpty(address)) { await Spinner.StartAsync("Processing receive payment ...", async spinner => { this.spinner = spinner; await actorService .From(password) .Identifier(identifier) .ReceivePayment(address); spinner.Text = "Fetching balance ..."; await Task.Delay(1500); await CheckBalance(identifier, password); spinner.Text = "Done ..."; }); } } } catch (Exception ex) { throw ex; } }
public override async Task Execute() { try { using (var identifier = Prompt.GetPasswordAsSecureString("Identifier:", ConsoleColor.Yellow)) using (var password = Prompt.GetPasswordAsSecureString("Password:"******"Amount:", null, ConsoleColor.Red); var address = Prompt.GetString("To:", null, ConsoleColor.Red); var memo = Prompt.GetString("Memo:", null, ConsoleColor.Green); var yesNo = Prompt.GetYesNo("Send redemption key to message pool?", true, ConsoleColor.Yellow); using (var insecureIdentifier = identifier.Insecure()) { await vaultService.GetDataAsync(identifier, password, $"wallets/{insecureIdentifier.Value}/wallet"); } if (double.TryParse(amount, out double t)) { JObject payment; await Spinner.StartAsync("Processing payment ...", async spinner => { this.spinner = spinner; spinner.Color = ConsoleColor.Blue; payment = await actorService .From(password) .Identifier(identifier) .Amount(t) .To(address) .Memo(memo) .SendPayment(yesNo); spinner.Text = "Fetching balance ..."; await Task.Delay(1500); await CheckBalance(identifier, password); spinner.Text = "Done ..."; if (yesNo.Equals(false)) { SaveRedemptionKeyLocal(spinner, payment); } else { var success = payment.GetValue("success"); var message = payment.GetValue("message"); if (success.ToObject <bool>().Equals(false)) { spinner.Fail(message.ToObject <string>()); } } }); } } } catch (Exception ex) { throw ex; } }