Example #1
0
        private void updateStat()
        {
            try
            {
                info = CoinService.GetInfo();
                string inputsCount = CoinService.ListUnspent().Count().ToString();

                string masternodeCount = CoinService.GetMasternode("count");

                balanceLabel.Text        = info.Balance.ToString() + " BMO";
                currentAddressLabel.Text = CoinService.GetAccountAddress(Properties.Settings.Default.account).ToString();
                peersCountLabel.Text     = "Peers: " + CoinService.GetPeerInfo().Count().ToString();
                stakeLinkLabel.Text      = info.Stake.ToString() + " BMO";
                //connectionsLabel.Text = "Connections: " + info.Connections.ToString();
                syncLabel.Text        = "Sync: " + info.Blocks + "b.";
                pVerLabel.Text        = info.Version;
                mnCounLabel.Text      = "MN count: " + masternodeCount;
                inputsCountLabel.Text = inputsCount;

                string applicationDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Bitmonk";
                string configFile          = applicationDataPath + "\\masternode.conf";

                if (!File.Exists(configFile))
                {
                    File.Copy("masternode.conf-example", applicationDataPath + "\\masternode.conf");
                }

                myMnsCountLabel.Text = File.ReadAllLines(configFile).Count().ToString();

                if (lastCheckBalance != balanceLabel.Text)
                {
                    updateTransactionsList();
                }

                lastCheckBalance = balanceLabel.Text;
            }
            catch (BitcoinLib.ExceptionHandling.Rpc.RpcException exc)
            {
                if (exc.Source != null)
                {
                    logMessageLabel.Text = exc.Message;
                    Console.WriteLine("RpcException source: {0}", exc.Source);
                }
            }
            catch (BitcoinLib.ExceptionHandling.Rpc.RpcInternalServerErrorException exc)
            {
                if (exc.Source != null)
                {
                    logMessageLabel.Text = exc.Message;
                    Console.WriteLine("RpcInternalServerErrorException source: {0}", exc.Source);
                }
            }
            catch (WebException exc)
            {
                if (exc.Source != null)
                {
                    logMessageLabel.Text = exc.Message;
                    Console.WriteLine("WebException source: {0}", exc.Source);
                }
            }
        }