Пример #1
0
        private void btnDecode_Click(object sender, EventArgs e)
        {
            MofN mn = new MofN();

            for (int i = 0; i < 8; i++) {
                TextBox t = GetPartBox(i);
                string p = t.Text.Trim();

                if (p == "" || (mn.PartsAccepted >= mn.PartsNeeded && mn.PartsNeeded > 0)) {
                    t.BackColor = System.Drawing.Color.White;
                } else {
                    string result = mn.AddKeyPart(p);
                    if (result == null) {
                        t.BackColor = System.Drawing.Color.LightGreen;
                    } else {
                        t.BackColor = System.Drawing.Color.Pink;
                    }
                }
            }

            if (mn.PartsAccepted >= mn.PartsNeeded && mn.PartsNeeded > 0) {
                mn.Decode();
                txtPrivKey.Text = mn.BitcoinPrivateKey;
                txtAddress.Text = mn.BitcoinAddress;
            } else {
                MessageBox.Show("Not enough valid parts were present to decode an address.");
            }
        }
Пример #2
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            if (numPartsNeeded.Value > numPartsToGenerate.Value) {
                MessageBox.Show("Number of parts needed exceeds number of parts to generate.");
                return;
            }

            for (int i = 0; i < 8; i++) {
                TextBox t = GetPartBox(i);
                t.Text = "";
                t.BackColor = System.Drawing.Color.White;
            }

            MofN mn = new MofN();

            if (targetPrivKey == null) {
                mn.Generate((int)numPartsNeeded.Value, (int)numPartsToGenerate.Value);
            } else {
                mn.Generate((int)numPartsNeeded.Value, (int)numPartsToGenerate.Value, targetPrivKey);
            }

            int j = 0;
            foreach (string kp in mn.GetKeyParts()) {
                GetPartBox(j++).Text = kp;
            }

            txtPrivKey.Text = mn.BitcoinPrivateKey ?? "?";
            txtAddress.Text = mn.BitcoinAddress ?? "?";
        }