예제 #1
0
        private static async Task RunExample()
        {
            // Users running the GUI must set server=1 in gridcoinresearch.conf
            // to enable the RPC server.
            var client = new GridcoinClient(
                "127.0.0.1",
                "gridcoinrpc", // rpcuser from gridcoinresearch.conf
                "password");   // rpcpassword from gridcoinresearch.conf

            try
            {
                ServerInfo info = await client.GetInfo();

                Console.Write("Version: ");
                Console.WriteLine(info.Version);
                Console.Write("Balance: ");
                Console.WriteLine(info.Balance);

                long height = await client.GetBlockCount();

                Console.Write("Height:  ");
                Console.WriteLine(height);
            }
            catch (IOException e)
            {
                Console.Write("Network error: ");
                Console.WriteLine(e.Message);
            }
            catch (HttpRequestException e)
            {
                Console.Write("Request error: ");
                Console.WriteLine(e.Message);
            }
            catch (SerializationException e)
            {
                Console.Write("Serialization format error: ");
                Console.WriteLine(e.Message);
            }
            catch (RpcException e)
            {
                Console.Write("RPC error: Code: ");
                Console.WriteLine(e.Code);
                Console.WriteLine(e.Message);
            }
            catch (Exception e)
            {
                Console.Write("Unknown error: ");
                Console.WriteLine(e);
            }
        }