public override async Task <SendReply> Send(SendRequest request, ServerCallContext context) { try { var client = LyraRestClient.Create(_config["network"], Environment.OSVersion.ToString(), "LyraBroker", "1.0"); var wallet = new TransitWallet(request.PrivateKey, client); var result = await wallet.SendAsync((decimal)request.Amount, request.DestAccountId, request.Ticker); if (result == Lyra.Core.Blocks.APIResultCodes.Success) { return(new SendReply { Success = true, SendHash = wallet.LastTxHash }); } } catch (Exception ex) { _logger.LogWarning("In OpenWallet: " + ex.ToString()); } return(new SendReply { Success = false, SendHash = "" }); }
public async Task <SendResult> Send(string privateKey, double amount, string destAccountId, string ticker) { try { var client = LyraRestClient.Create(_config["network"], Environment.OSVersion.ToString(), "LyraBroker", "1.0"); var wallet = new TransitWallet(privateKey, client); var result = await wallet.SendAsync((decimal)amount, destAccountId, ticker); if (result == Lyra.Core.Blocks.APIResultCodes.Success) { return(new SendResult { Success = true, SendHash = wallet.LastTxHash }); } } catch (Exception ex) { _logger.LogWarning("In OpenWallet: " + ex.ToString()); } return(new SendResult { Success = false, SendHash = "" }); }
public override async Task <GetBalanceReply> GetBalance(GetBalanceRequest request, ServerCallContext context) { try { var client = LyraRestClient.Create(_config["network"], Environment.OSVersion.ToString(), "LyraBroker", "1.0"); var wallet = new TransitWallet(request.PrivateKey, client); var result = await wallet.ReceiveAsync(); if (result == Lyra.Core.Blocks.APIResultCodes.Success) { var blances = await wallet.GetBalanceAsync(); if (blances != null) { var msg = new GetBalanceReply { AccountId = wallet.AccountId }; foreach (var kvp in blances) { msg.Balances.Add(new LyraBalance { Ticker = kvp.Key, Balance = kvp.Value / 100000000 }); } return(msg); } } } catch (Exception ex) { _logger.LogWarning("In OpenWallet: " + ex.ToString()); } return(new GetBalanceReply()); }
public async Task <BalanceInfo> GetBalance(string privateKey) { try { var client = LyraRestClient.Create(_config["network"], Environment.OSVersion.ToString(), "LyraBroker", "1.0"); var wallet = new TransitWallet(privateKey, client); var result = await wallet.ReceiveAsync(); if (result == Lyra.Core.Blocks.APIResultCodes.Success) { var blances = await wallet.GetBalanceAsync(); if (blances != null) { var msg = new BalanceInfo { AccountId = wallet.AccountId }; var list = new List <LyraBalance>(); foreach (var kvp in blances) { list.Add(new LyraBalance { Ticker = kvp.Key, Balance = kvp.Value / 100000000 }); } msg.Balances = list.ToArray(); return(msg); } } } catch (Exception ex) { _logger.LogWarning("In OpenWallet: " + ex.ToString()); } return(new BalanceInfo()); }