private void btnGenerateAddresses_Click(object sender, EventArgs e)
        {
            if (Generating)
            {
                StopRequested             = true;
                btnGenerateAddresses.Text = "Stopping...";
                return;
            }

            if (rdoEncrypted.Checked && txtTextInput.Text == "")
            {
                MessageBox.Show("An encryption passphrase is required. Choose a different option if you don't want encrypted keys.",
                                "Passphrase missing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (rdoDeterministicWallet.Checked && txtTextInput.Text == "")
            {
                MessageBox.Show("A deterministic seed is required.  If you do not intend to create a deterministic " +
                                "wallet or know what one is used for, it is recommended you choose one of the other options.  An inappropriate seed can result " +
                                "in the unexpected theft of funds.",
                                "Seed missing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (rdoTwoFactor.Checked)
            {
                // Read the clipboard for intermediate codes
                List <Bip38Intermediate> intermediates = ScanClipboardForIntermediateCodes();
                if (intermediates.Count == 0)
                {
                    MessageBox.Show("No valid intermediate codes were found on the clipboard.  Intermediate codes are typically " +
                                    "sent to you from someone else desiring paper wallets, or from your mobile phone.  Copy the received intermediate " +
                                    "codes to the clipboard, and try again.  Address Generator automatically detects valid intermediate codes and ignores " +
                                    "everything else on the clipboard", "No intermediate codes found", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                intermediatesForGeneration = intermediates.ToArray();
                intermediateIdx            = 0;
            }
            else
            {
                intermediatesForGeneration = null;
            }


            GenerationThread    = new Thread(new ThreadStart(GenerationThreadProcess));
            RemainingToGenerate = (int)numGenCount.Value;
            UserText            = txtTextInput.Text;
            RetainPrivateKeys   = chkRetainPrivKey.Checked;

            if (rdoDeterministicWallet.Checked)
            {
                GenChoice = GenChoices.Deterministic;
            }
            if (rdoEncrypted.Checked)
            {
                GenChoice = GenChoices.Encrypted;
                // intermediate codes start with "passphrasek" thru "passphrases"
                string ti = txtTextInput.Text.Trim();
                txtTextInput.UseSystemPasswordChar = true;
            }
            if (rdoMiniKeys.Checked)
            {
                GenChoice = GenChoices.Minikey;
            }
            if (rdoRandomWallet.Checked)
            {
                GenChoice = GenChoices.WIF;
            }
            if (rdoTwoFactor.Checked)
            {
                GenChoice = GenChoices.TwoFactor;
            }

            timer1.Interval           = 250;
            timer1.Enabled            = true;
            Generating                = true;
            GeneratingEnded           = false;
            StopRequested             = false;
            btnGenerateAddresses.Text = "Cancel";
            SetControlsEnabled(false);
            toolStripProgressBar1.Visible = true;
            GenerationThread.Start();
        }
        private void btnGenerateAddresses_Click(object sender, EventArgs e)
        {
            if (Generating) {
                StopRequested = true;
                btnGenerateAddresses.Text = "Stopping...";
                return;
            }

            if (rdoEncrypted.Checked && txtTextInput.Text == "") {
                MessageBox.Show("An encryption passphrase is required. Choose a different option if you don't want encrypted keys.",
                    "Passphrase missing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (rdoDeterministicWallet.Checked && txtTextInput.Text == "") {
                MessageBox.Show("A deterministic seed is required.  If you do not intend to create a deterministic " +
                    "wallet or know what one is used for, it is recommended you choose one of the other options.  An inappropriate seed can result " +
                    "in the unexpected theft of funds.",
                    "Seed missing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (rdoTwoFactor.Checked) {
                // Read the clipboard for intermediate codes
                List<Bip38Intermediate> intermediates = ScanClipboardForIntermediateCodes();
                if (intermediates.Count == 0) {
                    MessageBox.Show("No valid intermediate codes were found on the clipboard.  Intermediate codes are typically " +
                        "sent to you from someone else desiring paper wallets, or from your mobile phone.  Copy the received intermediate " +
                        "codes to the clipboard, and try again.  Address Generator automatically detects valid intermediate codes and ignores " +
                        "everything else on the clipboard", "No intermediate codes found", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                intermediatesForGeneration = intermediates.ToArray();
                intermediateIdx = 0;

            } else {
                intermediatesForGeneration = null;
            }

            GenerationThread = new Thread(new ThreadStart(GenerationThreadProcess));
            RemainingToGenerate = (int)numGenCount.Value;
            UserText = txtTextInput.Text;
            RetainPrivateKeys = chkRetainPrivKey.Checked;

            if (rdoDeterministicWallet.Checked) GenChoice = GenChoices.Deterministic;
            if (rdoEncrypted.Checked) {
                GenChoice = GenChoices.Encrypted;
                // intermediate codes start with "passphrasek" thru "passphrases"
                string ti = txtTextInput.Text.Trim();
                txtTextInput.UseSystemPasswordChar = true;
            }
            if (rdoMiniKeys.Checked) GenChoice = GenChoices.Minikey;
            if (rdoRandomWallet.Checked) GenChoice = GenChoices.WIF;
            if (rdoTwoFactor.Checked) {
                GenChoice = GenChoices.TwoFactor;
            }

            timer1.Interval = 250;
            timer1.Enabled = true;
            Generating = true;
            GeneratingEnded = false;
            StopRequested = false;
            btnGenerateAddresses.Text = "Cancel";
            SetControlsEnabled(false);
            toolStripProgressBar1.Visible = true;
            GenerationThread.Start();
        }
Exemplo n.º 3
0
        private void btnGenerateAddresses_Click(object sender, EventArgs e)
        {
            if (Generating) {
                StopRequested = true;
                btnGenerateAddresses.Text = "Stopping...";
                return;
            }

            if (rdoEncrypted.Checked && txtTextInput.Text == "") {
                MessageBox.Show("An encryption passphrase is required. Choose a different option if you don't want encrypted keys.",
                    "Passphrase missing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (rdoDeterministicWallet.Checked && txtTextInput.Text == "") {
                MessageBox.Show("A deterministic seed is required.  If you do not intend to create a deterministic " +
                    "wallet or know what one is used for, it is recommended you choose one of the other options.  An inappropriate seed can result " +
                    "in the unexpected theft of funds.",
                    "Seed missing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            GenerationThread = new Thread(new ThreadStart(GenerationThreadProcess));
            RemainingToGenerate = (int)numGenCount.Value;
            UserText = txtTextInput.Text;
            RetainPrivateKeys = chkRetainPrivKey.Checked;

            if (rdoDeterministicWallet.Checked) GenChoice = GenChoices.Deterministic;
            if (rdoEncrypted.Checked) {
                GenChoice = GenChoices.Encrypted;
                // intermediate codes start with "passphrasek" thru "passphrases"
                string ti = txtTextInput.Text.Trim();
                if (txtTextInput.Text.Length > 40 && ti.CompareTo("passphrasek") > 0 && ti.CompareTo("passphraset") < 0) {
                    Bip38Intermediate inter = null;
                    // try using it as an intermediate
                    try {
                        inter = new Bip38Intermediate(txtTextInput.Text.Trim(), Bip38Intermediate.Interpretation.IntermediateCode);
                        // if this is an actual intermediate code, ensure surrounding whitespace isn't preserved.
                        txtTextInput.Text = txtTextInput.Text.Trim();
                    } catch {
                        var r = MessageBox.Show("The passphrase resembles an Intermediate Code, but isn't one. " +
                        "If this is supposed to be an intermediate code, it is invalid, malformed, or has an error. " +
                            "If you're attempting to generate from an intermediate code, the resulting keys will not work as expected. " +
                            "Do you want to continue?",
                            "Invalid intermediate code", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

                        if (r == System.Windows.Forms.DialogResult.Cancel) {
                            return;

                        }
                    }
                    if (inter != null) {
                        MessageBox.Show("Intermediate Code accepted.  " +
                            "Intermediate Codes can be used for generating encrypted keys, but not for decrypting them. " +
                            "You will only be able to decrypt generated keys with " +
                            "the original passphrase that was used to create the Intermediate Code.", "Intermediate Code accepted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                txtTextInput.UseSystemPasswordChar = true;
            }
            if (rdoMiniKeys.Checked) GenChoice = GenChoices.Minikey;
            if (rdoRandomWallet.Checked) GenChoice = GenChoices.WIF;

            timer1.Interval = 250;
            timer1.Enabled = true;
            Generating = true;
            GeneratingEnded = false;
            StopRequested = false;
            btnGenerateAddresses.Text = "Cancel";
            SetControlsEnabled(false);
            toolStripProgressBar1.Visible = true;
            GenerationThread.Start();
        }