}     //end of public async Task<string> CreateAccount(string walletName, string password)

        /// <summary>
        /// Gets The Physical Wallet File Paths
        /// </summary>
        public async Task <GetWalletFilesResponse> GetWalletFiles()
        {
            try
            {
                GetWalletFilesResponse response = await base.SendGet <GetWalletFilesResponse>("api/Wallet/files");

                Guard.Null(response, nameof(response), "'api/Wallet/files' API Response Was Null!");

                return(response);
            }
            catch (Exception ex)
            {
                Logger.Fatal($"An Error '{ex.Message}' Occured When Getting Wallet File Paths!!", ex);

                throw;
            }
        }//end of public async Task<GetWalletFilesResponse> GetWalletFiles()
Example #2
0
        //Obtains Data that is NOT likely to change!
        public async void UpdateStaticData()
        {
            //are we connected??
            if (ConnectionMethod == ConnectionType.Disconnected)
            {
                logger.LogInformation(
                    $"Node '{Name}' ({Address}:{Port}), Aborting 'Static Data' Update.  Internal State Is Disconnected!");
                return;
            } //end of if(ConnectionMethod == ConnectionType.Disconnected)

            try
            {
                GetWalletFilesResponse filesData = await restClient.GetWalletFiles();

                if (filesData == null)
                {
                    errorFsInfo = true; //an error occured, this data is relied upon in the "RefreshNodeData" Method
                    logger.LogInformation(
                        $"Node '{Name}' ({Address}:{Port}), An Error Occured When Getting Node File Information!");
                }
                else
                {
                    WalletPath  = filesData.walletsPath;
                    WalletFiles = new List <string>(filesData.walletsFiles);

                    foreach (string wallet in WalletFiles)
                    {
                        //parse MyWallet.wallet.json  to "MyWallet"
                        string walletName = wallet.Substring(0, wallet.IndexOf("."));

                        //Get a list of accounts
                        List <string> walletAccounts = await restClient.GetWalletAccounts(walletName);

                        if (walletAccounts == null)
                        {
                            logger.LogInformation(
                                $"An Error Occured When Trying To Get Wallet Accounts For Wallet '{walletName}'");
                        }

                        if (walletAccounts.Count > 0)
                        {
                            //Are there already present wallets? if so overwrite the data, if not then lets add a new record
                            if (WalletAccounts.ContainsKey(walletName))
                            {
                                WalletAccounts[walletName] = walletAccounts;
                            }
                            else
                            {
                                WalletAccounts.Add(walletName, walletAccounts);
                            }
                        } //end of if(walletAccounts.Count > 0)
                    }     //end of foreach

                    errorFsInfo = false;
                } //end of if-else if (filesData == null)
            }
            catch (HttpRequestException ex) //API is not accessible or responding
            {
                OnDisconnected(Address, Port);
                logger.LogInformation(
                    $"Node '{Name}' ({Address}:{Port}) Something Happened & The Node API Is Not Accessible", ex);
            }
            catch (Exception ex)
            {
                logger.LogInformation(
                    $"Node '{Name}' ({Address}:{Port}) An Error Occured When Polling For Static Data!", ex);
            } //end of try-catch
        }     //end of private async void GetStaticData()