6 #if defined(HAVE_CONFIG_H) 7 #include <config/dash-config.h> 11 #include <qt/forms/ui_askpassphrasedialog.h> 20 #include <QMessageBox> 21 #include <QPushButton> 38 ui->passEdit1->setMinimumSize(
ui->passEdit1->sizeHint());
39 ui->passEdit2->setMinimumSize(
ui->passEdit2->sizeHint());
40 ui->passEdit3->setMinimumSize(
ui->passEdit3->sizeHint());
47 ui->passEdit1->installEventFilter(
this);
48 ui->passEdit2->installEventFilter(
this);
49 ui->passEdit3->installEventFilter(
this);
54 ui->warningLabel->setText(tr(
"Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>ten or more random characters</b>, or <b>eight or more words</b>."));
55 ui->passLabel1->hide();
56 ui->passEdit1->hide();
57 setWindowTitle(tr(
"Encrypt wallet"));
60 ui->warningLabel->setText(tr(
"This operation needs your wallet passphrase to unlock the wallet."));
61 ui->passLabel2->hide();
62 ui->passEdit2->hide();
63 ui->passLabel3->hide();
64 ui->passEdit3->hide();
65 setWindowTitle(tr(
"Unlock wallet for mixing only"));
68 ui->warningLabel->setText(tr(
"This operation needs your wallet passphrase to unlock the wallet."));
69 ui->passLabel2->hide();
70 ui->passEdit2->hide();
71 ui->passLabel3->hide();
72 ui->passEdit3->hide();
73 setWindowTitle(tr(
"Unlock wallet"));
76 ui->warningLabel->setText(tr(
"This operation needs your wallet passphrase to decrypt the wallet."));
77 ui->passLabel2->hide();
78 ui->passEdit2->hide();
79 ui->passLabel3->hide();
80 ui->passEdit3->hide();
81 setWindowTitle(tr(
"Decrypt wallet"));
84 setWindowTitle(tr(
"Change passphrase"));
85 ui->warningLabel->setText(tr(
"Enter the old passphrase and new passphrase to the wallet."));
89 connect(
ui->toggleShowPasswordButton, SIGNAL(toggled(
bool)),
this, SLOT(
toggleShowPassword(
bool)));
103 this->
model = _model;
116 oldpass.assign(
ui->passEdit1->text().toStdString().c_str());
117 newpass1.assign(
ui->passEdit2->text().toStdString().c_str());
118 newpass2.assign(
ui->passEdit3->text().toStdString().c_str());
125 if(newpass1.empty() || newpass2.empty())
130 QMessageBox::StandardButton retval = QMessageBox::question(
this, tr(
"Confirm wallet encryption"),
131 tr(
"Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR DASH</b>!") +
"<br><br>" + tr(
"Are you sure you wish to encrypt your wallet?"),
132 QMessageBox::Yes|QMessageBox::Cancel,
133 QMessageBox::Cancel);
134 if(retval == QMessageBox::Yes)
136 if(newpass1 == newpass2)
141 QMessageBox::warning(
this, tr(
"Wallet encrypted"),
143 tr(
"%1 will close now to finish the encryption process. " 144 "Remember that encrypting your wallet cannot fully protect " 145 "your funds from being stolen by malware infecting your computer.").arg(tr(PACKAGE_NAME)) +
147 tr(
"IMPORTANT: Any previous backups you have made of your wallet file " 148 "should be replaced with the newly generated, encrypted wallet file. " 149 "Previous backups of the unencrypted wallet file contain the same HD seed and " 150 "still have full access to all your funds just like the new, encrypted wallet.") +
153 QMessageBox::warning(
this, tr(
"Wallet encrypted"),
155 tr(
"%1 will close now to finish the encryption process. " 156 "Remember that encrypting your wallet cannot fully protect " 157 "your funds from being stolen by malware infecting your computer.").arg(tr(PACKAGE_NAME)) +
159 tr(
"IMPORTANT: Any previous backups you have made of your wallet file " 160 "should be replaced with the newly generated, encrypted wallet file. " 161 "For security reasons, previous backups of the unencrypted wallet file " 162 "will become useless as soon as you start using the new, encrypted wallet.") +
165 QApplication::quit();
169 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
170 tr(
"Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
176 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
177 tr(
"The supplied passphrases do not match."));
189 QMessageBox::critical(
this, tr(
"Wallet unlock failed"),
190 tr(
"The passphrase entered for the wallet decryption was incorrect."));
200 QMessageBox::critical(
this, tr(
"Wallet decryption failed"),
201 tr(
"The passphrase entered for the wallet decryption was incorrect."));
209 if(newpass1 == newpass2)
213 QMessageBox::information(
this, tr(
"Wallet encrypted"),
214 tr(
"Wallet passphrase was successfully changed."));
219 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
220 tr(
"The passphrase entered for the wallet decryption was incorrect."));
225 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
226 tr(
"The supplied passphrases do not match."));
235 bool acceptable =
false;
239 acceptable = !
ui->passEdit2->text().isEmpty() && !
ui->passEdit3->text().isEmpty();
244 acceptable = !
ui->passEdit1->text().isEmpty();
247 acceptable = !
ui->passEdit1->text().isEmpty() && !
ui->passEdit2->text().isEmpty() && !
ui->passEdit3->text().isEmpty();
250 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable);
256 if (
event->type() == QEvent::KeyPress) {
257 QKeyEvent *ke =
static_cast<QKeyEvent *
>(
event);
258 if (ke->key() == Qt::Key_CapsLock) {
262 ui->capsLabel->setText(tr(
"Warning: The Caps Lock key is on!"));
264 ui->capsLabel->clear();
267 return QWidget::event(
event);
272 ui->toggleShowPasswordButton->setDown(show);
273 const auto mode = show ? QLineEdit::Normal : QLineEdit::Password;
274 ui->passEdit1->setEchoMode(
mode);
275 ui->passEdit2->setEchoMode(
mode);
276 ui->passEdit3->setEchoMode(
mode);
287 if (
event->type() == QEvent::KeyPress) {
288 QKeyEvent *ke =
static_cast<QKeyEvent *
>(
event);
289 QString str = ke->text();
290 if (str.length() != 0) {
291 const QChar *psz = str.unicode();
292 bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0;
293 if ((fShift && *psz >=
'a' && *psz <=
'z') || (!fShift && *psz >=
'A' && *psz <=
'Z')) {
295 ui->capsLabel->setText(tr(
"Warning: The Caps Lock key is on!"));
296 }
else if (psz->isLetter()) {
298 ui->capsLabel->clear();
302 return QDialog::eventFilter(
object,
event);
308 edit->setText(QString(
" ").repeated(edit->text().size()));
static const int MAX_PASSPHRASE_SIZE
bool event(QEvent *event)
Ask passphrase and unlock only for mixing.
void setFont(const std::vector< QWidget *> &vecWidgets, FontWeight weight, int nPointSize, bool fItalic)
Workaround to set correct font styles in all themes since there is a bug in macOS which leads to issu...
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Ask passphrase twice and encrypt.
static void SecureClearQLineEdit(QLineEdit *edit)
void toggleShowPassword(bool)
void updateFonts()
Update the font of all widgets where a custom font has been set with GUIUtil::setFont.
Ask passphrase and unlock.
Ui::AskPassphraseDialog * ui
void secureClearPassFields()
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass)
AskPassphraseDialog(Mode mode, QWidget *parent)
void disableMacFocusRect(const QWidget *w)
Disable the OS default focus rect for macOS because we have custom focus rects set in the css files...
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.
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString(), bool fMixing=false)
void setModel(WalletModel *model)