6#include <qt/forms/ui_askpassphrasedialog.h>
20 QDialog(parent,
GUIUtil::dialog_flags),
27 ui->passEdit1->setMinimumSize(
ui->passEdit1->sizeHint());
28 ui->passEdit2->setMinimumSize(
ui->passEdit2->sizeHint());
29 ui->passEdit3->setMinimumSize(
ui->passEdit3->sizeHint());
36 ui->passEdit1->installEventFilter(
this);
37 ui->passEdit2->installEventFilter(
this);
38 ui->passEdit3->installEventFilter(
this);
43 ui->warningLabel->setText(
tr(
"Enter the new passphrase for the wallet.<br/>Please use a passphrase of <b>ten or more random characters</b>, or <b>eight or more words</b>."));
44 ui->passLabel1->hide();
45 ui->passEdit1->hide();
50 ui->warningLabel->setText(
tr(
"This operation needs your wallet passphrase to unlock the wallet."));
51 ui->passLabel2->hide();
52 ui->passEdit2->hide();
53 ui->passLabel3->hide();
54 ui->passEdit3->hide();
59 ui->warningLabel->setText(
tr(
"Enter the old passphrase and new passphrase for the wallet."));
106 tr(
"Confirm wallet encryption"),
107 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?"),
108 QMessageBox::Cancel | QMessageBox::Yes,
this);
112 QMessageBox::StandardButton retval = (QMessageBox::StandardButton)
msgBoxConfirm.exec();
113 if(retval == QMessageBox::Yes)
118 "your bitcoins from being stolen by malware infecting your computer.");
122 tr(
"Wallet to be encrypted"),
125 tr(
"Are you sure you wish to encrypt your wallet?") +
127 QMessageBox::Cancel | QMessageBox::Yes,
this);
129 QMessageBox::StandardButton retval = (QMessageBox::StandardButton)
msgBoxWarning.exec();
130 if (retval == QMessageBox::Cancel) {
137 QMessageBox::warning(
this,
tr(
"Wallet encrypted"),
141 tr(
"IMPORTANT: Any previous backups you have made of your wallet file "
142 "should be replaced with the newly generated, encrypted wallet file. "
143 "For security reasons, previous backups of the unencrypted wallet file "
144 "will become useless as soon as you start using the new, encrypted wallet.") +
147 QMessageBox::critical(
this,
tr(
"Wallet encryption failed"),
148 tr(
"Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
155 QMessageBox::critical(
this,
tr(
"Wallet encryption failed"),
156 tr(
"The supplied passphrases do not match."));
163 QMessageBox::critical(
this,
tr(
"Wallet unlock failed"), QString::fromStdString(
unlocked.error().message.translated));
170 }
catch (
const std::runtime_error&
e) {
171 QMessageBox::critical(
this,
tr(
"Wallet unlock failed"),
e.what());
182 QMessageBox::information(
this,
tr(
"Wallet encrypted"),
183 tr(
"Wallet passphrase was successfully changed."));
186 QMessageBox::critical(
this,
tr(
"Passphrase change failed"), QString::fromStdString(
changed.error().message.translated));
191 QMessageBox::critical(
this,
tr(
"Wallet encryption failed"),
192 tr(
"The supplied passphrases do not match."));
205 acceptable = !
ui->passEdit2->text().isEmpty() && !
ui->passEdit3->text().isEmpty();
212 acceptable = !
ui->passEdit1->text().isEmpty() && !
ui->passEdit2->text().isEmpty() && !
ui->passEdit3->text().isEmpty();
215 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
acceptable);
221 if (
event->type() == QEvent::KeyPress) {
223 if (
ke->key() == Qt::Key_CapsLock) {
227 ui->capsLabel->setText(
tr(
"Warning: The Caps Lock key is on!"));
229 ui->capsLabel->clear();
232 return QWidget::event(
event);
237 ui->toggleShowPasswordButton->setDown(
show);
238 const auto mode =
show ? QLineEdit::Normal : QLineEdit::Password;
239 ui->passEdit1->setEchoMode(
mode);
240 ui->passEdit2->setEchoMode(
mode);
241 ui->passEdit3->setEchoMode(
mode);
252 if (
event->type() == QEvent::KeyPress) {
255 if (str.length() != 0) {
257 bool fShift = (
ke->modifiers() & Qt::ShiftModifier) != 0;
260 ui->capsLabel->setText(
tr(
"Warning: The Caps Lock key is on!"));
261 }
else if (
psz->isLetter()) {
263 ui->capsLabel->clear();
267 return QDialog::eventFilter(
object,
event);
static void SecureClearQLineEdit(QLineEdit *edit)
#define Assume(val)
Assume is the identity function.
Multifunctional dialog to ask for passphrases.
void secureClearPassFields()
SecureString * m_passphrase_out
AskPassphraseDialog(Mode mode, QWidget *parent, SecureString *passphrase_out=nullptr)
void toggleShowPassword(bool)
void setModel(WalletModel *model)
bool eventFilter(QObject *object, QEvent *event) override
bool event(QEvent *event) override
@ Unlock
Ask passphrase and unlock.
@ Encrypt
Ask passphrase twice and encrypt.
@ ChangePass
Ask old passphrase + new passphrase twice.
@ UnlockMigration
Ask passphrase for unlocking during migration.
Ui::AskPassphraseDialog * ui
Interface to Bitcoin wallet from Qt view code.
util::Expected< void, wallet::WalletError > changePassphrase(const SecureString &oldPass, const SecureString &newPass)
bool setWalletEncrypted(const SecureString &passphrase)
interfaces::Wallet & wallet() const
constexpr int MAX_PASSPHRASE_SIZE
Utility functions used by the Bitcoin Qt UI.
void handleCloseWindowShortcut(QWidget *w)
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
is a home for public enum and struct type definitions that are used by internally by wallet code,...