2 #include "ui_askpassphrasedialog.h"
19 ui->passEdit1->setMaxLength(MAX_PASSPHRASE_SIZE);
20 ui->passEdit2->setMaxLength(MAX_PASSPHRASE_SIZE);
21 ui->passEdit3->setMaxLength(MAX_PASSPHRASE_SIZE);
24 ui->passEdit1->installEventFilter(
this);
25 ui->passEdit2->installEventFilter(
this);
26 ui->passEdit3->installEventFilter(
this);
31 ui->passLabel1->hide();
32 ui->passEdit1->hide();
33 ui->warningLabel->setText(tr(
"Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>10 or more random characters</b>, or <b>eight or more words</b>."));
34 setWindowTitle(tr(
"Encrypt wallet"));
37 ui->warningLabel->setText(tr(
"This operation needs your wallet passphrase to unlock the wallet."));
38 ui->passLabel2->hide();
39 ui->passEdit2->hide();
40 ui->passLabel3->hide();
41 ui->passEdit3->hide();
42 setWindowTitle(tr(
"Unlock wallet"));
45 ui->warningLabel->setText(tr(
"This operation needs your wallet passphrase to decrypt the wallet."));
46 ui->passLabel2->hide();
47 ui->passEdit2->hide();
48 ui->passLabel3->hide();
49 ui->passEdit3->hide();
50 setWindowTitle(tr(
"Decrypt wallet"));
53 setWindowTitle(tr(
"Change passphrase"));
54 ui->warningLabel->setText(tr(
"Enter the old and new passphrase to the wallet."));
67 ui->passEdit1->setText(QString(
" ").repeated(
ui->passEdit1->text().size()));
68 ui->passEdit2->setText(QString(
" ").repeated(
ui->passEdit2->text().size()));
69 ui->passEdit3->setText(QString(
" ").repeated(
ui->passEdit3->text().size()));
83 oldpass.reserve(MAX_PASSPHRASE_SIZE);
84 newpass1.reserve(MAX_PASSPHRASE_SIZE);
85 newpass2.reserve(MAX_PASSPHRASE_SIZE);
88 oldpass.assign(
ui->passEdit1->text().toStdString().c_str());
89 newpass1.assign(
ui->passEdit2->text().toStdString().c_str());
90 newpass2.assign(
ui->passEdit3->text().toStdString().c_str());
95 if(newpass1.empty() || newpass2.empty())
100 QMessageBox::StandardButton retval = QMessageBox::question(
this, tr(
"Confirm wallet encryption"),
101 tr(
"Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR FEATHERCOINS</b>!") +
"<br><br>" + tr(
"Are you sure you wish to encrypt your wallet?"),
102 QMessageBox::Yes|QMessageBox::Cancel,
103 QMessageBox::Cancel);
104 if(retval == QMessageBox::Yes)
106 if(newpass1 == newpass2)
110 QMessageBox::warning(
this, tr(
"Wallet encrypted"),
112 tr(
"Feathercoin will close now to finish the encryption process. "
113 "Remember that encrypting your wallet cannot fully protect "
114 "your feathercoins from being stolen by malware infecting your computer.") +
116 tr(
"IMPORTANT: Any previous backups you have made of your wallet file "
117 "should be replaced with the newly generated, encrypted wallet file. "
118 "For security reasons, previous backups of the unencrypted wallet file "
119 "will become useless as soon as you start using the new, encrypted wallet.") +
121 QApplication::quit();
125 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
126 tr(
"Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
132 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
133 tr(
"The supplied passphrases do not match."));
144 QMessageBox::critical(
this, tr(
"Wallet unlock failed"),
145 tr(
"The passphrase entered for the wallet decryption was incorrect."));
155 QMessageBox::critical(
this, tr(
"Wallet decryption failed"),
156 tr(
"The passphrase entered for the wallet decryption was incorrect."));
164 if(newpass1 == newpass2)
168 QMessageBox::information(
this, tr(
"Wallet encrypted"),
169 tr(
"Wallet passphrase was successfully changed."));
174 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
175 tr(
"The passphrase entered for the wallet decryption was incorrect."));
180 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
181 tr(
"The supplied passphrases do not match."));
190 bool acceptable =
false;
194 acceptable = !
ui->passEdit2->text().isEmpty() && !
ui->passEdit3->text().isEmpty();
198 acceptable = !
ui->passEdit1->text().isEmpty();
201 acceptable = !
ui->passEdit1->text().isEmpty() && !
ui->passEdit2->text().isEmpty() && !
ui->passEdit3->text().isEmpty();
204 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable);
210 if (event->type() == QEvent::KeyPress) {
211 QKeyEvent *ke =
static_cast<QKeyEvent *
>(
event);
212 if (ke->key() == Qt::Key_CapsLock) {
216 ui->capsLabel->setText(tr(
"Warning: The Caps Lock key is on!"));
218 ui->capsLabel->clear();
221 return QWidget::event(event);
232 if (event->type() == QEvent::KeyPress) {
233 QKeyEvent *ke =
static_cast<QKeyEvent *
>(
event);
234 QString str = ke->text();
235 if (str.length() != 0) {
236 const QChar *psz = str.unicode();
237 bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0;
238 if ((fShift && *psz >=
'a' && *psz <=
'z') || (!fShift && *psz >=
'A' && *psz <=
'Z')) {
240 ui->capsLabel->setText(tr(
"Warning: The Caps Lock key is on!"));
241 }
else if (psz->isLetter()) {
243 ui->capsLabel->clear();
247 return QDialog::eventFilter(
object, event);
bool event(QEvent *event)
Ask passphrase twice and encrypt.
Ask passphrase and unlock.
Ui::AskPassphraseDialog * ui
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass)
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
AskPassphraseDialog(Mode mode, QWidget *parent=0)
AddressTableModel * parent
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString())
Interface to Bitcoin wallet from Qt view code.
Multifunctional dialog to ask for passphrases.
bool setWalletEncrypted(bool encrypted, const SecureString &passphrase)
Ask passphrase and decrypt wallet.
bool eventFilter(QObject *object, QEvent *event)
Ask old passphrase + new passphrase twice.
void setModel(WalletModel *model)