9 #include "ui_bip38tooldialog.h"
32 ui->decryptedKeyOut_DEC->setPlaceholderText(tr(
"Click \"Decrypt Key\" to compute key"));
35 ui->addressIn_ENC->installEventFilter(
this);
36 ui->passphraseIn_ENC->installEventFilter(
this);
37 ui->encryptedKeyOut_ENC->installEventFilter(
this);
38 ui->encryptedKeyIn_DEC->installEventFilter(
this);
39 ui->passphraseIn_DEC->installEventFilter(
this);
40 ui->decryptedKeyOut_DEC->installEventFilter(
this);
55 ui->addressIn_ENC->setText(address);
56 ui->passphraseIn_ENC->setFocus();
61 ui->encryptedKeyIn_DEC->setText(address);
62 ui->passphraseIn_DEC->setFocus();
67 ui->tabWidget->setCurrentIndex(0);
74 ui->tabWidget->setCurrentIndex(1);
99 for (
int i = 0; i < strPassphrase.size(); i++) {
100 if (!
validChar.contains(strPassphrase[i], Qt::CaseSensitive)) {
101 if (QString(
"\"'").contains(strPassphrase[i]))
104 strInvalid = strPassphrase[i];
117 QString qstrPassphrase =
ui->passphraseIn_ENC->text();
120 ui->statusLabel_ENC->setStyleSheet(
"QLabel { color: red; }");
121 ui->statusLabel_ENC->setText(tr(
"The entered passphrase is invalid. ") + strInvalid + QString(
" is not valid") + QString(
" ") + tr(
"Allowed: 0-9,a-z,A-Z,") +
specialChar);
127 ui->statusLabel_ENC->setStyleSheet(
"QLabel { color: red; }");
128 ui->statusLabel_ENC->setText(tr(
"The entered address is invalid.") + QString(
" ") + tr(
"Please check the address and try again."));
134 ui->addressIn_ENC->setValid(
false);
135 ui->statusLabel_ENC->setStyleSheet(
"QLabel { color: red; }");
136 ui->statusLabel_ENC->setText(tr(
"The entered address does not refer to a key.") + QString(
" ") + tr(
"Please check the address and try again."));
142 ui->statusLabel_ENC->setStyleSheet(
"QLabel { color: red; }");
143 ui->statusLabel_ENC->setText(tr(
"Wallet unlock was cancelled."));
149 ui->statusLabel_ENC->setStyleSheet(
"QLabel { color: red; }");
150 ui->statusLabel_ENC->setText(tr(
"Private key for the entered address is not available."));
155 ui->encryptedKeyOut_ENC->setText(QString::fromStdString(encryptedKey));
165 ui->addressIn_ENC->clear();
166 ui->passphraseIn_ENC->clear();
167 ui->encryptedKeyOut_ENC->clear();
168 ui->statusLabel_ENC->clear();
170 ui->addressIn_ENC->setFocus();
177 ui->encryptedKeyIn_DEC->setText(QApplication::clipboard()->text());
182 std::string strPassphrase =
ui->passphraseIn_DEC->text().toStdString();
183 std::string strKey =
ui->encryptedKeyIn_DEC->text().toStdString();
187 if (!
BIP38_Decrypt(strPassphrase, strKey, privKey, fCompressed)) {
188 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: red; }");
189 ui->statusLabel_DEC->setText(tr(
"Failed to decrypt.") + QString(
" ") + tr(
"Please check the key and passphrase and try again."));
198 ui->addressOut_DEC->setText(QString::fromStdString(address.
ToString()));
205 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: red; }");
206 ui->statusLabel_DEC->setText(tr(
"Wallet unlock was cancelled."));
214 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: red; }");
215 ui->statusLabel_DEC->setText(tr(
"Data Not Valid.") + QString(
" ") + tr(
"Please try again."));
221 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: red; }");
222 ui->statusLabel_DEC->setText(tr(
"Please wait while key is imported"));
229 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: red; }");
230 ui->statusLabel_DEC->setText(tr(
"Key Already Held By Wallet"));
237 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: red; }");
238 ui->statusLabel_DEC->setText(tr(
"Error Adding Key To Wallet"));
247 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: green; }");
248 ui->statusLabel_DEC->setText(tr(
"Successfully Added Private Key To Wallet"));
253 ui->encryptedKeyIn_DEC->clear();
254 ui->decryptedKeyOut_DEC->clear();
255 ui->passphraseIn_DEC->clear();
256 ui->statusLabel_DEC->clear();
258 ui->encryptedKeyIn_DEC->setFocus();
263 if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::FocusIn) {
264 if (
ui->tabWidget->currentIndex() == 0) {
266 ui->statusLabel_ENC->clear();
269 if (
object ==
ui->encryptedKeyOut_ENC) {
270 ui->encryptedKeyOut_ENC->selectAll();
273 }
else if (
ui->tabWidget->currentIndex() == 1) {
275 ui->statusLabel_DEC->clear();
278 return QDialog::eventFilter(
object, event);