Example #1
0
        private void openWalletBtn_Click(object sender, EventArgs e)
        {
            /// Split ip and port on selected node
            string[] node  = nodeList.Text.Split(':');
            string[] node2 = node[0].Split(' ');

            // If ping to daemon is successfull
            if (Functions.PingHost(node2[1], Convert.ToInt32(node[1])))
            {
                Config.Connected_Node = node2[1] + ":" + node[1];

                // Open wallet
                WalletOpen walletOpen = new WalletOpen();
                walletOpen.daemonHost = node2[1];
                walletOpen.daemonPort = Convert.ToInt32(node[1]);
                walletOpen.filename   = walletFile.Text;
                walletOpen.password   = walletPassword.Text;

                string walletOpenJson = JsonConvert.SerializeObject(walletOpen);
                string response       = ApiClient.HTTP(walletOpenJson, "/wallet/open", "POST");

                if (response.StartsWith("{"))
                { // If reply is Json
                    JObject JsonParse    = JObject.Parse(response);
                    int     errorCode    = (int)JsonParse["errorCode"];
                    string  errorMessage = (string)JsonParse["errorMessage"];
                    MessageBox.Show(errorMessage);
                }
                else if (response == "403")
                {                                            // If wallet already opened
                    ApiClient.HTTP("", "/wallet", "DELETE"); // Logout of wallet in API
                    MessageBox.Show("There was still a wallet loaded. It has been unloaded now. Please try again to open a wallet.");
                }
                else if (response == "")
                { // If success
                    //MessageBox.Show("Logged in");
                    this.Hide();

                    Wallet wallet = new Wallet();
                    wallet.Show();
                }
                else
                { // Other
                    MessageBox.Show(response);
                }
            }
            else
            {
                MessageBox.Show("Could not connect to node. Make sure your daemon is running or try a different node.");
            }
        }
Example #2
0
        private void openWalletBtn_Click(object sender, EventArgs e)
        {
            WalletOpen walletOpen = new WalletOpen();

            walletOpen.daemonHost = "spookypool.nl";
            walletOpen.daemonPort = 11421;
            walletOpen.filename   = walletFile.Text;
            walletOpen.password   = walletPassword.Text;

            string walletOpenJson = JsonConvert.SerializeObject(walletOpen);
            string response       = ApiClient.HTTP(walletOpenJson, "/wallet/open", "POST");

            if (response.StartsWith("{"))   // If reply is Json
            {
                JObject JsonParse    = JObject.Parse(response);
                int     errorCode    = (int)JsonParse["errorCode"];
                string  errorMessage = (string)JsonParse["errorMessage"];
                MessageBox.Show(errorMessage);
            }
            else if (response == "403")     // If wallet already opened
            {
                MessageBox.Show("There is already a wallet opened.");
            }
            else if (response == "")    // If success
            {
                MessageBox.Show("Logged in");
                this.Hide();

                Wallet wallet = new Wallet();
                wallet.Show();
            }
            else   // Other
            {
                MessageBox.Show(response);
            }
        }