private void saveButton_Click(object sender, EventArgs e) { if (inputReceiving.Text != "") { MyFile myFile = new MyFile(); string text = myFile.ReadFile(path); string[] splitted = text.Split(' '); if (splitted.Length != 12) { Aes aes = new Aes(); WalletDotDat walletDotDat = new WalletDotDat(); //aes.Decrypt(f.ReadFile(ucChooseYourWallet.FilePath), ucChooseYourWallet.Password) walletDotDat.FromString(aes.Decrypt(text, password)); walletDotDat.addPrivateKey(bitcoinSecret); MessageBox.Show(walletDotDat.ToString()); myFile.SaveEncryptedFile(walletDotDat.ToString(), password, path); } else { WalletDotDat walletDotDat = new WalletDotDat(); walletDotDat.FromString(myFile.ReadFile(path)); walletDotDat.addPrivateKey(bitcoinSecret); myFile.SaveUnecryptedFile(walletDotDat.ToString(), path); } } else { MessageBox.Show("Generate adress and input needed info!"); } }
private void inputNext_Click(object sender, EventArgs e) { if (outputPanel.Controls.Contains(ucChooseYourWallet)) { if (ucChooseYourWallet.Availability) { LoadUserControlKeystore(); } else { if (ucChooseYourWallet.Encrypted) { LoadEncryptedWallet(); } else { LoadUnecryptedWallet(); } } } else if (outputPanel.Controls.Contains(ucKeystore)) { if (ucKeystore.selected == "new") { LoadUserControlSeedGeneration(); } else if (ucKeystore.selected == "restore") { LoadUserControlRestore(); } } else if (outputPanel.Controls.Contains(ucRestore)) { bool isValidSeed = false; ExtKey extKey = null; List <BitcoinSecret> bs; if (ucRestore.phrase != "") { try { extKey = Wallet.generateMasterAdress(ucRestore.phrase); isValidSeed = true; } catch { isValidSeed = false; MessageBox.Show("Seed is invalid!"); } WalletDotDat walletDotDat = new WalletDotDat(); if (isValidSeed) { MyFile myFile = new MyFile(); walletDotDat.mnemonics = ucRestore.phrase; bs = Wallet.Restore(extKey); foreach (BitcoinSecret bits in bs) { walletDotDat.addPrivateKey(bits); } if (ucRestore.password == "") { myFile.SaveUnecryptedFile(walletDotDat.ToString(), ucChooseYourWallet.FilePath); } else { myFile.SaveEncryptedFile(walletDotDat.ToString(), ucRestore.password, ucChooseYourWallet.FilePath); } FormWallet formWallet = new FormWallet(ucRestore.password, ucChooseYourWallet.FilePath); this.Hide(); formWallet.ShowDialog(); } } else { MessageBox.Show("Seed is invalid!"); } } else if (outputPanel.Controls.Contains(ucSeedGeneration)) { LoadUserControlSeedConfirmation(); } else if (outputPanel.Controls.Contains(ucSeedConfirmation)) { Wallet wallet = new Wallet(); if (wallet.ConfirmSeed(outputSeed, ucSeedConfirmation.GetSeed)) { LoadUserControlWalletEncryption(); } else { MessageBox.Show("The seed you entered is incorrect.", "BitcoinWallet", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (outputPanel.Controls.Contains(ucWalletEncryption)) { if (ucWalletEncryption.GetPassword == ucWalletEncryption.GetConfirmPassword) { if (string.IsNullOrWhiteSpace(ucWalletEncryption.GetPassword)) { FinishCreatingFile("unecrypted", ucChooseYourWallet.FilePath); } else { FinishCreatingFile("ecrypted", ucChooseYourWallet.FilePath); } } else { MessageBox.Show("Passwords do not match.", "BitcoinWallet", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }