public void AddItem(KeyCollectionItem item)
 {
     Items.Add(item);
     if (ItemAdded != null)
     {
         ItemAdded.Invoke(item);
     }
 }
 private void newAddressToolStripMenuItem_Click(object sender, EventArgs e)
 {
     KeyPair kp = KeyPair.Create(ExtraEntropy.GetEntropy());
     KeyCollectionItem item = new KeyCollectionItem(kp);
     KeyCollection.AddItem(item);
 }
 void KeyCollection_ItemAdded(KeyCollectionItem item)
 {
     ListViewItem lvi = new ListViewItem(new string[] { item.ToString(), item.PrivateKeyKind, "0.00" });
     lvi.Tag = item;
     lvi.Checked = true;
     listView1.Items.Add(lvi);
     UpdateStatusLabel();
 }
        /// <summary>
        /// Code which is actually run on the generation thread.
        /// </summary>
        private void GenerationThreadProcess()
        {
            Bip38Intermediate intermediate = null;
            if (GenChoice == GenChoices.Encrypted) {
                intermediate = new Bip38Intermediate(UserText, Bip38Intermediate.Interpretation.Passphrase);
            }

            int detcount = 1;

            while (RemainingToGenerate > 0 && StopRequested == false) {
                KeyCollectionItem newitem = null;
                switch (GenChoice) {
                    case GenChoices.Minikey:
                        MiniKeyPair mkp = MiniKeyPair.CreateRandom(ExtraEntropy.GetEntropy());
                        string s = mkp.AddressBase58; // read the property to entice it to compute everything
                        newitem = new KeyCollectionItem(mkp);
                        break;
                    case GenChoices.WIF:
                        KeyPair kp = KeyPair.Create(ExtraEntropy.GetEntropy());
                        s = kp.AddressBase58;
                        newitem = new KeyCollectionItem(kp);
                        break;
                    case GenChoices.Deterministic:
                        kp = KeyPair.CreateFromString(UserText + detcount);
                        detcount++;
                        s = kp.AddressBase58;
                        newitem = new KeyCollectionItem(kp);
                        break;
                    case GenChoices.Encrypted:
                        Bip38KeyPair ekp = new Bip38KeyPair(intermediate);
                        newitem = new KeyCollectionItem(ekp);
                        break;
                    case GenChoices.TwoFactor:
                        ekp = new Bip38KeyPair(intermediatesForGeneration[intermediateIdx++]);
                        if (intermediateIdx >= intermediatesForGeneration.Length) intermediateIdx = 0;
                        newitem = new KeyCollectionItem(ekp);
                        break;
                }

                lock (GeneratedItems) {
                    GeneratedItems.Add(newitem);
                    RemainingToGenerate--;
                }
            }
            GeneratingEnded = true;
        }
 public void AddItem(KeyCollectionItem item)
 {
     Items.Add(item);
     if (ItemAdded != null) ItemAdded.Invoke(item);
 }
 private void AddKey(byte addressType)
 {
     KeyPair kp = KeyPair.Create(ExtraEntropy.GetEntropy(), false, addressType);
     KeyCollectionItem item = new KeyCollectionItem(kp);
     KeyCollection.AddItem(item);
 }