Exemplo n.º 1
0
 private void LoadFormWallet()
 {
     if (!string.IsNullOrWhiteSpace(ucChooseYourWallet.Password))
     {
         FormWallet formWallet = new FormWallet(ucChooseYourWallet.Password, ucChooseYourWallet.FilePath);
         this.Hide();
         formWallet.Show();
     }
     else if (!string.IsNullOrWhiteSpace(ucWalletEncryption.GetPassword))
     {
         FormWallet formWallet = new FormWallet(ucWalletEncryption.GetPassword, ucChooseYourWallet.FilePath);
         this.Hide();
         formWallet.Show();
     }
     else
     {
         FormWallet formWallet = new FormWallet("", ucChooseYourWallet.FilePath);
         this.Hide();
         formWallet.Show();
     }
 }
Exemplo n.º 2
0
 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);
         }
     }
 }