24 model(nullptr), fCapsLock(false), m_passphrase_out(passphrase_out) {
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);
42 ui->warningLabel->setText(
43 tr(
"Enter the new passphrase for the wallet.<br/>Please use a "
44 "passphrase of <b>ten or more random characters</b>, or "
45 "<b>eight or more words</b>."));
46 ui->passLabel1->hide();
47 ui->passEdit1->hide();
48 setWindowTitle(tr(
"Encrypt wallet"));
51 ui->warningLabel->setText(tr(
"This operation needs your wallet "
52 "passphrase to unlock the wallet."));
53 ui->passLabel2->hide();
54 ui->passEdit2->hide();
55 ui->passLabel3->hide();
56 ui->passEdit3->hide();
57 setWindowTitle(tr(
"Unlock wallet"));
60 setWindowTitle(tr(
"Change passphrase"));
61 ui->warningLabel->setText(tr(
62 "Enter the old passphrase and new passphrase for the wallet."));
66 connect(
ui->toggleShowPasswordButton, &QPushButton::toggled,
this,
68 connect(
ui->passEdit1, &QLineEdit::textChanged,
this,
70 connect(
ui->passEdit2, &QLineEdit::textChanged,
this,
72 connect(
ui->passEdit3, &QLineEdit::textChanged,
this,
98 oldpass.assign(
ui->passEdit1->text().toStdString().c_str());
99 newpass1.assign(
ui->passEdit2->text().toStdString().c_str());
100 newpass2.assign(
ui->passEdit3->text().toStdString().c_str());
106 if (newpass1.empty() || newpass2.empty()) {
110 QMessageBox::StandardButton retval = QMessageBox::question(
111 this, tr(
"Confirm wallet encryption"),
112 tr(
"Warning: If you encrypt your wallet and lose your "
113 "passphrase, you will <b>LOSE ALL OF YOUR BITCOINS</b>!") +
115 tr(
"Are you sure you wish to encrypt your wallet?"),
116 QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
117 if (retval == QMessageBox::Yes) {
118 if (newpass1 == newpass2) {
119 QString encryption_reminder =
120 tr(
"Remember that encrypting your wallet cannot fully "
121 "protect your bitcoins from being stolen by malware "
122 "infecting your computer.");
125 QMessageBox::warning(
126 this, tr(
"Wallet to be encrypted"),
128 tr(
"Your wallet is about to be encrypted. ") +
129 encryption_reminder +
"</b></qt>");
133 QMessageBox::warning(
134 this, tr(
"Wallet encrypted"),
135 "<qt>" + tr(
"Your wallet is now encrypted. ") +
136 encryption_reminder +
"<br><br><b>" +
137 tr(
"IMPORTANT: Any previous backups you "
138 "have made of your wallet file should "
139 "be replaced with the newly generated, "
140 "encrypted wallet file. For security "
141 "reasons, previous backups of the "
142 "unencrypted wallet file will become "
143 "useless as soon as you start using the "
144 "new, encrypted wallet.") +
147 QMessageBox::critical(
148 this, tr(
"Wallet encryption failed"),
149 tr(
"Wallet encryption failed due to an "
150 "internal error. Your wallet was not "
156 QMessageBox::critical(
157 this, tr(
"Wallet encryption failed"),
158 tr(
"The supplied passphrases do not match."));
167 QMessageBox::critical(
168 this, tr(
"Wallet unlock failed"),
169 tr(
"The passphrase entered for the wallet decryption "
175 }
catch (
const std::runtime_error &e) {
176 QMessageBox::critical(
this, tr(
"Wallet unlock failed"),
181 if (newpass1 == newpass2) {
183 QMessageBox::information(
184 this, tr(
"Wallet encrypted"),
185 tr(
"Wallet passphrase was successfully changed."));
188 QMessageBox::critical(
189 this, tr(
"Wallet encryption failed"),
190 tr(
"The passphrase entered for the wallet decryption "
194 QMessageBox::critical(
195 this, tr(
"Wallet encryption failed"),
196 tr(
"The supplied passphrases do not match."));
204 bool acceptable =
false;
207 acceptable = !
ui->passEdit2->text().isEmpty() &&
208 !
ui->passEdit3->text().isEmpty();
211 acceptable = !
ui->passEdit1->text().isEmpty();
214 acceptable = !
ui->passEdit1->text().isEmpty() &&
215 !
ui->passEdit2->text().isEmpty() &&
216 !
ui->passEdit3->text().isEmpty();
219 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable);