void OnFileExportKeys(object sender, RoutedEventArgs e) { if (!EnsurePassphraseUnlock()) { return; } var w = SelectedWalletNotNull().Wallet; var d = new SaveFileDialog(); d.InitialDirectory = Eng.AppDataDirectory; d.Filter = "BIP38 format (encrypted)|*.bip38|Wallet Import Format (unencrypted)|*.wif"; d.FileName = w.CurrencyName + "-keys"; if (Dialog.ShowDialog(d, this)) { string password = null; if (d.FilterIndex == 1) { var dlg = new FormPassphrase(); dlg.labelOldPassword.Visibility = Visibility.Hidden; dlg.textOldPassword.Visibility = Visibility.Hidden; if (!Dialog.ShowDialog(dlg, this)) { return; } password = dlg.textPassword.Password.Normalize(NormalizationForm.FormC); } else if (!AskUnencryptedExportWarning()) { return; } w.ExportKeys(password, d.FileName); // async operation } }
private void OnChangeWalletPassword(object sender, RoutedEventArgs e) { var dlg = new FormPassphrase(); dlg.labelOldPassword.Visibility = Visibility.Visible; dlg.textOldPassword.Visibility = Visibility.Visible; dlg.textOldPassword.Focus(); if (Dialog.ShowDialog(dlg, this)) { Eng.ChangePassword(dlg.textOldPassword.Text.Normalize(NormalizationForm.FormC), dlg.textPassword.Password.Normalize(NormalizationForm.FormC)); } }
void OnFileImport(object sender, RoutedEventArgs e) { if (!EnsurePassphraseUnlock()) { return; } var wf = SelectedWalletNotNull(); var d = new OpenFileDialog(); d.InitialDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), wf.Wallet.CurrencyName); d.Filter = "Bitcoin Wallet format|wallet.dat|BIP38 keys (encrypted)|*.bip38|Wallet Import Format keys|*.wif"; d.FileName = "wallet.dat"; if (Dialog.ShowDialog(d, this)) { string password = ""; while (true) { try { switch (d.FilterIndex) { case 1: wf.Wallet.ImportWallet(d.FileName, password); break; case 2: case 3: foreach (var key in File.ReadAllLines(d.FileName)) { wf.Wallet.ImportPrivateKey(key.Trim(), password); } break; } break; } catch (Exception ex) { if (ex.HResult != (int)Err.InvalidPassword) { throw; } var dlg = new FormPassphrase(); dlg.labelRetype.Visibility = Visibility.Hidden; dlg.textRetype.Visibility = Visibility.Hidden; dlg.Title = "Enter Passphrase for imported Keys or Wallet"; if (!Dialog.ShowDialog(dlg, this)) { break; } password = dlg.textPassword.Password.Normalize(NormalizationForm.FormC); } } } }
public bool EnsurePassphraseUnlock() { if (Eng.NeedPassword) { var dlg = new FormPassphrase(); dlg.labelRetype.Visibility = Visibility.Hidden; dlg.textRetype.Visibility = Visibility.Hidden; dlg.Title = "Wallet Password"; if (Dialog.ShowDialog(dlg, this)) { Eng.SetPassword(dlg.textPassword.Password.Normalize(NormalizationForm.FormC)); } else { return(false); } } return(true); }
private void OnFileImport(object sender, RoutedEventArgs e) { // Eng.Password = "******"; //!!!D // Eng.ImportWallet("C:\\work\\coin\\wallet.dat", "123"); //!!D // return; //!!D if (!EnsurePassphraseUnlock()) { return; } var wf = SelectedWalletNotNull(); var d = new OpenFileDialog(); d.InitialDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), wf.Wallet.CurrencyName); d.Filter = "Bitcoin Wallet format|wallet.dat|All Files|*.*"; d.FileName = "wallet.dat"; if (Dialog.ShowDialog(d, this)) { string password = ""; while (true) { try { wf.Wallet.ImportWallet(d.FileName, password); break; } catch (Exception) { var dlg = new FormPassphrase(); dlg.labelRetype.Visibility = Visibility.Hidden; dlg.textRetype.Visibility = Visibility.Hidden; dlg.Title = "Enter Passphrase for imported wallet.dat"; if (!Dialog.ShowDialog(dlg, this)) { break; } password = dlg.textPassword.Password; } } } }
private void OnFileImport(object sender, RoutedEventArgs e) { // Eng.Password = "******"; //!!!D // Eng.ImportWallet("C:\\work\\coin\\wallet.dat", "123"); //!!D // return; //!!D if (!EnsurePassphraseUnlock()) return; var d = new OpenFileDialog(); d.InitialDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Bitcoin"); d.Filter = "Bitcoin Wallet format|wallet.dat|All Files|*.*"; d.FileName = "wallet.dat"; if (Dialog.ShowDialog(d, this)) { string password = ""; while (true) { try { Eng.ImportWallet(d.FileName, password); break; } catch (Exception) { var dlg = new FormPassphrase(); dlg.labelRetype.Visibility = Visibility.Hidden; dlg.textRetype.Visibility = Visibility.Hidden; dlg.Title = "Enter Passphrase for imported wallet.dat"; if (!Dialog.ShowDialog(dlg, this)) break; password = dlg.textPassword.Password; } } } }
private void OnChangeWalletPassword(object sender, RoutedEventArgs e) { var dlg = new FormPassphrase(); dlg.labelOldPassword.Visibility = Visibility.Visible; dlg.textOldPassword.Visibility = Visibility.Visible; dlg.textOldPassword.Focus(); if (Dialog.ShowDialog(dlg, this)) { Eng.ChangePassword(dlg.textOldPassword.Text, dlg.textPassword.Password); } }
public bool EnsurePassphraseUnlock() { if (Eng.NeedPassword) { var dlg = new FormPassphrase(); dlg.labelRetype.Visibility = Visibility.Hidden; dlg.textRetype.Visibility = Visibility.Hidden; dlg.Title = "Wallet Password"; if (Dialog.ShowDialog(dlg, this)) { Eng.Password = dlg.textPassword.Password; } else return false; } return true; }