14 #include <QMessageBox>
15 #include <QPushButton>
40 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>."));
41 setWindowTitle(tr(
"Encrypt wallet"));
44 ui->
warningLabel->setText(tr(
"This operation needs your wallet passphrase to unlock the wallet."));
49 setWindowTitle(tr(
"Unlock wallet"));
52 ui->
warningLabel->setText(tr(
"This operation needs your wallet passphrase to decrypt the wallet."));
57 setWindowTitle(tr(
"Decrypt wallet"));
60 setWindowTitle(tr(
"Change passphrase"));
61 ui->
warningLabel->setText(tr(
"Enter the old and new passphrase to the wallet."));
95 oldpass.assign(
ui->
passEdit1->text().toStdString().c_str());
96 newpass1.assign(
ui->
passEdit2->text().toStdString().c_str());
97 newpass2.assign(
ui->
passEdit3->text().toStdString().c_str());
102 if(newpass1.empty() || newpass2.empty())
107 QMessageBox::StandardButton retval = QMessageBox::question(
this, tr(
"Confirm wallet encryption"),
108 tr(
"Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR BITCOINS</b>!") +
"<br><br>" + tr(
"Are you sure you wish to encrypt your wallet?"),
109 QMessageBox::Yes|QMessageBox::Cancel,
110 QMessageBox::Cancel);
111 if(retval == QMessageBox::Yes)
113 if(newpass1 == newpass2)
117 QMessageBox::warning(
this, tr(
"Wallet encrypted"),
119 tr(
"Bitcoin will close now to finish the encryption process. "
120 "Remember that encrypting your wallet cannot fully protect "
121 "your bitcoins from being stolen by malware infecting your computer.") +
123 tr(
"IMPORTANT: Any previous backups you have made of your wallet file "
124 "should be replaced with the newly generated, encrypted wallet file. "
125 "For security reasons, previous backups of the unencrypted wallet file "
126 "will become useless as soon as you start using the new, encrypted wallet.") +
128 QApplication::quit();
132 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
133 tr(
"Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
139 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
140 tr(
"The supplied passphrases do not match."));
151 QMessageBox::critical(
this, tr(
"Wallet unlock failed"),
152 tr(
"The passphrase entered for the wallet decryption was incorrect."));
162 QMessageBox::critical(
this, tr(
"Wallet decryption failed"),
163 tr(
"The passphrase entered for the wallet decryption was incorrect."));
171 if(newpass1 == newpass2)
175 QMessageBox::information(
this, tr(
"Wallet encrypted"),
176 tr(
"Wallet passphrase was successfully changed."));
181 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
182 tr(
"The passphrase entered for the wallet decryption was incorrect."));
187 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
188 tr(
"The supplied passphrases do not match."));
197 bool acceptable =
false;
211 ui->
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable);
217 if (event->type() == QEvent::KeyPress) {
218 QKeyEvent *ke =
static_cast<QKeyEvent *
>(
event);
219 if (ke->key() == Qt::Key_CapsLock) {
223 ui->
capsLabel->setText(tr(
"Warning: The Caps Lock key is on!"));
228 return QWidget::event(event);
239 if (event->type() == QEvent::KeyPress) {
240 QKeyEvent *ke =
static_cast<QKeyEvent *
>(
event);
241 QString str = ke->text();
242 if (str.length() != 0) {
243 const QChar *psz = str.unicode();
244 bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0;
245 if ((fShift && *psz >=
'a' && *psz <=
'z') || (!fShift && *psz >=
'A' && *psz <=
'Z')) {
247 ui->
capsLabel->setText(tr(
"Warning: The Caps Lock key is on!"));
248 }
else if (psz->isLetter()) {
254 return QDialog::eventFilter(
object, event);
void setupUi(QDialog *AskPassphraseDialog)
static const int MAX_PASSPHRASE_SIZE
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
QDialogButtonBox * buttonBox
AddressTableModel * parent
AskPassphraseDialog(Mode mode, QWidget *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)