15 #include <QMessageBox> 16 #include <QPushButton> 43 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>."));
46 setWindowTitle(tr(
"Encrypt wallet"));
52 ui->
warningLabel->setText(tr(
"This operation needs your wallet passphrase to unlock the wallet."));
57 setWindowTitle(tr(
"Unlock wallet"));
60 ui->
warningLabel->setText(tr(
"This operation needs your wallet passphrase to decrypt the wallet."));
65 setWindowTitle(tr(
"Decrypt wallet"));
68 setWindowTitle(tr(
"Change passphrase"));
69 ui->
warningLabel->setText(tr(
"Enter the old passphrase and new passphrase to the wallet."));
99 oldpass.assign(
ui->
passEdit1->text().toStdString().c_str());
100 newpass1.assign(
ui->
passEdit2->text().toStdString().c_str());
101 newpass2.assign(
ui->
passEdit3->text().toStdString().c_str());
108 if(newpass1.empty() || newpass2.empty())
113 QMessageBox::StandardButton
retval = QMessageBox::question(
this, tr(
"Confirm wallet encryption"),
114 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?"),
115 QMessageBox::Yes|QMessageBox::Cancel,
116 QMessageBox::Cancel);
117 if(
retval == QMessageBox::Yes)
119 if(newpass1 == newpass2)
123 QMessageBox::warning(
this, tr(
"Wallet encrypted"),
125 tr(
"Dash Core will close now to finish the encryption process. " 126 "Remember that encrypting your wallet cannot fully protect " 127 "your dashs from being stolen by malware infecting your computer.") +
129 tr(
"IMPORTANT: Any previous backups you have made of your wallet file " 130 "should be replaced with the newly generated, encrypted wallet file. " 131 "For security reasons, previous backups of the unencrypted wallet file " 132 "will become useless as soon as you start using the new, encrypted wallet.") +
134 QApplication::quit();
138 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
139 tr(
"Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
145 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
146 tr(
"The supplied passphrases do not match."));
158 QMessageBox::critical(
this, tr(
"Wallet unlock failed"),
159 tr(
"The passphrase entered for the wallet decryption was incorrect."));
169 QMessageBox::critical(
this, tr(
"Wallet decryption failed"),
170 tr(
"The passphrase entered for the wallet decryption was incorrect."));
178 if(newpass1 == newpass2)
182 QMessageBox::information(
this, tr(
"Wallet encrypted"),
183 tr(
"Wallet passphrase was successfully changed."));
188 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
189 tr(
"The passphrase entered for the wallet decryption was incorrect."));
194 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
195 tr(
"The supplied passphrases do not match."));
204 bool acceptable =
false;
219 ui->
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable);
225 if (
event->type() == QEvent::KeyPress) {
226 QKeyEvent *ke =
static_cast<QKeyEvent *
>(
event);
227 if (ke->key() == Qt::Key_CapsLock) {
231 ui->
capsLabel->setText(tr(
"Warning: The Caps Lock key is on!"));
236 return QWidget::event(
event);
247 if (
event->type() == QEvent::KeyPress) {
248 QKeyEvent *ke =
static_cast<QKeyEvent *
>(
event);
249 QString str = ke->text();
250 if (str.length() != 0) {
251 const QChar *psz = str.unicode();
252 bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0;
253 if ((fShift && *psz >=
'a' && *psz <=
'z') || (!fShift && *psz >=
'A' && *psz <=
'Z')) {
255 ui->
capsLabel->setText(tr(
"Warning: The Caps Lock key is on!"));
256 }
else if (psz->isLetter()) {
262 return QDialog::eventFilter(
object,
event);
268 edit->setText(QString(
" ").repeated(edit->text().size()));
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString(), bool fMixing=false)
static const int MAX_PASSPHRASE_SIZE
void secureClearPassFields()
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
static void SecureClearQLineEdit(QLineEdit *edit)
Ui::AskPassphraseDialog * ui
QDialogButtonBox * buttonBox
bool setWalletEncrypted(bool encrypted, const SecureString &passphrase)
AddressTableModel * parent
AskPassphraseDialog(Mode mode, QWidget *parent)
bool eventFilter(QObject *object, QEvent *event)
void setupUi(QDialog *AskPassphraseDialog)
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass)
void setModel(WalletModel *model)
QCheckBox * mixingOnlyCheckBox
bool event(QEvent *event)