private void CancelButton_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are you sure you want to cancel your Turtle Wallet import?", "Cancel wallet import?", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Utilities.SetDialogResult(this, DialogResult.Cancel); Utilities.Close(this); } }
private void PasswordText_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (passwordText.Text != "" && passwordText.Text.Length > 6) { WalletPassword = passwordText.Text; Utilities.SetDialogResult(this, DialogResult.OK); Utilities.Close(this); } } }
private void ImportWalletButton_Click(object sender, EventArgs e) { ImportWalletPrompt IWP = new ImportWalletPrompt(); Utilities.Hide(this); var IWPreturn = IWP.ShowDialog(); if (IWPreturn == DialogResult.OK) { WalletPath = IWP.ImportWalletPath; WalletPassword = IWP.ImportWalletPassword; Utilities.SetDialogResult(this, DialogResult.OK); Utilities.Close(IWP); Utilities.Close(this); } this.Show(); }
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.SetDialogResult(this, DialogResult.OK); Utilities.Close(CWP); Utilities.Close(this); } this.Show(); }
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.SetDialogResult(this, DialogResult.OK); Utilities.Close(this); } } } }
private void ImportWallet() { 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", "bitcoin nova Wallet Import"); return; } else if (walletNameText.Text.Any(c => !Char.IsLetterOrDigit(c))) { MessageBox.Show("Wallet name cannot contain special characters", "bitcoin nova Wallet Import"); 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.", "bitcoin nova Wallet Import"); return; } if (passwordText.Text == "") { MessageBox.Show("Please enter a valid password", "bitcoin nova Wallet Import"); return; } else if (passwordText.Text.Length < 6) { MessageBox.Show("Please enter a password that is larger than 6 characters", "bitcoin nova Wallet Import"); return; } else if (passwordText.Text.Length > 150) { MessageBox.Show("Passwords cannot be longer than 150 characters!", "bitcoin nova Wallet Import"); return; } if (passwordText.Text != passwordConfirmText.Text) { MessageBox.Show("Passwords do not match", "bitcoin nova Wallet Import"); return; } if (viewSecretKeyText.Text.Length != 64 || spendSecretKeyText.Text.Length != 64) { MessageBox.Show("View key or spend key is incorrect length! Should be 64 characters long.", "bitcoin nova Wallet Import"); 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!", "bitcoin nova Wallet Import", MessageBoxButtons.OK, MessageBoxIcon.Error); Utilities.SetDialogResult(this, DialogResult.Abort); Utilities.Close(this); } importProgressbar.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, "--view-key", viewSecretKeyText.Text, "--spend-key", spendSecretKeyText.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 import after communicating with daemon. Please ensure your secret keys are correct, and open walletd.log for more information on what went wrong, if it exists.", "bitcoin nova Wallet Import", MessageBoxButtons.OK, MessageBoxIcon.Error); Utilities.SetDialogResult(this, DialogResult.Abort); Utilities.Close(this); } else { ImportWalletPath = _walletFile; ImportWalletPassword = passwordText.Text; MessageBox.Show("Wallet successfully imported at: " + Environment.NewLine + _walletFile, "bitcoin nova Wallet Import", MessageBoxButtons.OK, MessageBoxIcon.Information); Utilities.SetDialogResult(this, DialogResult.OK); Utilities.Close(this); } } catch (Exception ex) { MessageBox.Show("An exception occured while attempting to import the wallet." + Environment.NewLine + "Error:" + Environment.NewLine + ex.Message, "bitcoin nova Wallet Import", MessageBoxButtons.OK, MessageBoxIcon.Error); Utilities.SetDialogResult(this, DialogResult.Abort); Utilities.Close(this); } }
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; } else if (passwordText.Text.Length > 150) { MessageBox.Show("Passwords cannot be longer than 150 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); Utilities.SetDialogResult(this, 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); Utilities.SetDialogResult(this, 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.SetDialogResult(this, 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); Utilities.SetDialogResult(this, DialogResult.Abort); Utilities.Close(this); } }
private void CreateWalletButton_Click(object sender, EventArgs e) { WalletPassword = passwordText.Text; Utilities.SetDialogResult(this, DialogResult.OK); Utilities.Close(this); }