Example #1
0
        private void createWalletBtn_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 (PingHost(node2[1], Convert.ToInt32(node[1])))
            {
                Config.Connected_Node = node2[1] + ":" + node[1];

                CreateWallet createWallet = new CreateWallet();
                createWallet.daemonHost = node2[1];
                createWallet.daemonPort = Convert.ToInt32(node[1]);
                createWallet.filename   = walletFile.Text;
                createWallet.password   = walletPassword.Text;

                string createWalletJson = JsonConvert.SerializeObject(createWallet);
                string response         = ApiClient.HTTP(createWalletJson, "/wallet/create", "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 create a wallet.");
                }
                else if (response == "")
                { // If success
                    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 createWalletBtn_Click(object sender, EventArgs e)
        {
            CreateWallet createWallet = new CreateWallet();

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

            string createWalletJson = JsonConvert.SerializeObject(createWallet);
            string response         = ApiClient.HTTP(createWalletJson, "/wallet/create", "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("Wallet created");
                this.Hide();

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