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 = ""
            });
        }
Esempio n. 2
0
        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 = ""
            });
        }