コード例 #1
0
 private void CreateWalletButton_Click(object sender, EventArgs e)
 {
     WalletPassword = passwordText.Text;
     Utilities.SetAppClosing(false);
     this.DialogResult = DialogResult.OK;
     Utilities.Close(this);
 }
コード例 #2
0
        private void CancelButton_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to cancel your Turtle Wallet creation?", "Cancel wallet creation?", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                Utilities.SetAppClosing(false);
                this.DialogResult = DialogResult.Cancel;
                Utilities.Close(this);
            }
        }
コード例 #3
0
        private void CreateWalletButton_Click(object sender, EventArgs e)
        {
            CreateWalletPrompt CWP = new CreateWalletPrompt();

            Utilities.Hide(this);
            var CWPreturn = CWP.ShowDialog();

            if (CWPreturn == DialogResult.OK)
            {
                WalletPath     = CWP.WalletPath;
                WalletPassword = CWP.WalletPassword;
                Utilities.SetAppClosing(false);
                this.DialogResult = DialogResult.OK;
                Utilities.Close(CWP);
                Utilities.Close(this);
            }
            this.Show();
        }
コード例 #4
0
        private void SelectWalletButton_Click(object sender, EventArgs e)
        {
            var            curDir           = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            OpenFileDialog findWalletDialog = new OpenFileDialog
            {
                InitialDirectory = curDir,
                Filter           = "wallet files (*.wallet)|*.wallet|All files (*.*)|*.*",
                FilterIndex      = 2,
                RestoreDirectory = true
            };

            if (findWalletDialog.ShowDialog() == DialogResult.OK)
            {
                if (System.IO.File.Exists(findWalletDialog.FileName))
                {
                    WalletPath = findWalletDialog.FileName;
                    var pPrompt = new passwordPrompt();
                    Utilities.Hide(this);
                    var pResult = pPrompt.ShowDialog();
                    if (pResult != DialogResult.OK)
                    {
                        findWalletDialog.Dispose();
                        Utilities.Close(pPrompt);
                        this.Show();
                        return;
                    }
                    else
                    {
                        WalletPassword = pPrompt.WalletPassword;
                        Utilities.Close(pPrompt);
                        Utilities.SetAppClosing(false);
                        this.DialogResult = DialogResult.OK;
                        Utilities.Close(this);
                    }
                }
            }
        }
コード例 #5
0
        private void CreateWallet()
        {
            var curDir      = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            var _walletFile = System.IO.Path.Combine(curDir, walletNameText.Text + ".wallet");

            if (walletNameText.Text == "")
            {
                MessageBox.Show("Please enter a valid wallet name", "Turtle Wallet Creation");
                return;
            }
            else if (walletNameText.Text.Any(c => !Char.IsLetterOrDigit(c)))
            {
                MessageBox.Show("Wallet name cannot contain special characters", "Turtle Wallet Creation");
                return;
            }
            else if (System.IO.File.Exists(_walletFile))
            {
                MessageBox.Show("A wallet with that name already exists! Choose a different name or choose the \"Select Existing Wallet\" option instead.", "Turtle Wallet Creation");
                return;
            }

            if (passwordText.Text == "")
            {
                MessageBox.Show("Please enter a valid password", "Turtle Wallet Creation");
                return;
            }
            else if (passwordText.Text.Length < 6)
            {
                MessageBox.Show("Please enter a password that is larger than 6 characters", "Turtle Wallet Creation");
                return;
            }

            if (passwordText.Text != passwordConfirmText.Text)
            {
                MessageBox.Show("Passwords do not match", "Turtle Wallet Creation");
                return;
            }

            var walletdexe = System.IO.Path.Combine(curDir, "walletd.exe");

            if (IsRunningOnMono())
            {
                walletdexe = System.IO.Path.Combine(curDir, "walletd");
            }

            if (!System.IO.File.Exists(walletdexe))
            {
                MessageBox.Show("The 'walletd' daemon is missing from the folder the wallet is currently running from! Please place 'walletd' next to your wallet exe and run again!", "Turtle Wallet Creation", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.Abort;
                Utilities.Close(this);
            }

            createProgressbar.Visible = true;
            StringBuilder tmpstdout = new StringBuilder();

            try
            {
                Process p = new Process();
                p.StartInfo.UseShellExecute        = false;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.CreateNoWindow         = true;
                p.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
                p.StartInfo.FileName  = walletdexe;
                p.StartInfo.Arguments = CLIEncoder.Encode(new string[] { "-w", _walletFile, "-p", passwordText.Text, "-g" });
                p.OutputDataReceived += (sender, args) => tmpstdout.AppendLine(args.Data);
                p.Start();
                p.BeginOutputReadLine();
                p.WaitForExit(10000);
                p.CancelOutputRead();

                if (!System.IO.File.Exists(_walletFile))
                {
                    MessageBox.Show("Wallet failed to create after communicating with daemon. Please reinstall the wallet, close any other wallets you may have open, and try again", "Turtle Wallet Creation", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.DialogResult = DialogResult.Abort;
                    Utilities.Close(this);
                }
                else
                {
                    WalletPath     = _walletFile;
                    WalletPassword = passwordText.Text;
                    MessageBox.Show("Wallet successfully created at: " + Environment.NewLine + _walletFile + Environment.NewLine + "IMPORTANT:" + Environment.NewLine + "As soon as the main GUI to the wallet opens, you should proceed to the 'BACKUP KEYS' tab to save your secret and view key in case of wallet failure in the future!", "Turtle Wallet Creation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Utilities.SetAppClosing(false);
                    this.DialogResult = DialogResult.OK;
                    Utilities.Close(this);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An exception occured while attempting to create the wallet." + Environment.NewLine + "Error:" + Environment.NewLine + ex.Message, "Turtle Wallet Creation", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.Abort;
                Utilities.Close(this);
            }
        }