6 #include "qt/settings/forms/ui_bittoolwidget.h"
28 this->setStyleSheet(parent->styleSheet());
32 ui->left->setContentsMargins(10,10,10,10);
40 ui->pushLeft->setChecked(
true);
55 ui->lineEditDecryptResult->setAttribute(Qt::WA_MacShowFocusRect, 0);
56 ui->lineEditDecryptResult->setReadOnly(
true);
62 ui->pushButtonImport->setVisible(
false);
64 connect(
ui->pushLeft, &QPushButton::clicked, [
this](){onEncryptSelected(true);});
65 connect(
ui->pushRight, &QPushButton::clicked, [
this](){onEncryptSelected(false);});
73 ui->addressIn_ENC->setAttribute(Qt::WA_MacShowFocusRect, 0);
80 ui->passphraseIn_ENC->setAttribute(Qt::WA_MacShowFocusRect, 0);
84 ui->encryptedKeyOut_ENC->setAttribute(Qt::WA_MacShowFocusRect, 0);
85 ui->encryptedKeyOut_ENC->setReadOnly(
true);
88 btnContact =
ui->addressIn_ENC->addAction(QIcon(
"://ic-contact-arrow-down"), QLineEdit::TrailingPosition);
93 ui->statusLabel_ENC->setStyleSheet(
"QLabel { color: transparent; }");
94 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: transparent; }");
106 ui->addressIn_ENC->setText(address);
107 ui->passphraseIn_ENC->setFocus();
112 ui->stackedWidget->setCurrentIndex(isEncr);
120 for (
int i = 0; i < strPassphrase.size(); i++) {
121 if (!
validChar.contains(strPassphrase[i], Qt::CaseSensitive)) {
122 if (QString(
"\"'").contains(strPassphrase[i]))
125 strInvalid = strPassphrase[i];
138 QString qstrPassphrase =
ui->passphraseIn_ENC->text();
141 ui->statusLabel_ENC->setStyleSheet(
"QLabel { color: red; }");
142 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);
148 ui->statusLabel_ENC->setStyleSheet(
"QLabel { color: red; }");
149 ui->statusLabel_ENC->setText(tr(
"The entered address is invalid.") + QString(
" ") + tr(
"Please check the address and try again."));
153 const CKeyID* keyID = boost::get<CKeyID>(&dest);
156 ui->statusLabel_ENC->setStyleSheet(
"QLabel { color: red; }");
157 ui->statusLabel_ENC->setText(tr(
"The entered address does not refer to a key.") + QString(
" ") + tr(
"Please check the address and try again."));
163 ui->statusLabel_ENC->setStyleSheet(
"QLabel { color: red; }");
164 ui->statusLabel_ENC->setText(tr(
"Wallet unlock was cancelled."));
170 ui->statusLabel_ENC->setStyleSheet(
"QLabel { color: red; }");
171 ui->statusLabel_ENC->setText(tr(
"Private key for the entered address is not available."));
176 ui->encryptedKeyOut_ENC->setText(QString::fromStdString(encryptedKey));
178 ui->statusLabel_ENC->setStyleSheet(
"QLabel { color: green; }");
179 ui->statusLabel_ENC->setText(QString(
"<nobr>") + tr(
"Address encrypted.") + QString(
"</nobr>"));
184 ui->addressIn_ENC->clear();
185 ui->passphraseIn_ENC->clear();
186 ui->encryptedKeyOut_ENC->clear();
187 ui->statusLabel_ENC->clear();
188 ui->addressIn_ENC->setFocus();
194 if (addressSize == 0) {
195 inform(tr(
"No addresses available, you can go to the receive screen and add some there!"));
199 int height = (addressSize <= 2) ?
ui->addressIn_ENC->height() * ( 2 * (addressSize + 1 )) :
ui->addressIn_ENC->height() * 4;
200 int width =
ui->containerAddressEnc->width();
224 QPoint pos =
ui->containerAddressEnc->rect().bottomLeft();
225 pos.setY(pos.y() +
ui->containerAddressEnc->height());
226 pos.setX(pos.x() + 10);
234 int width =
ui->containerAddress->width();
237 QPoint pos =
ui->containerAddressEnc->rect().bottomLeft();
238 pos.setY(pos.y() +
ui->containerAddressEnc->height());
239 pos.setX(pos.x() + 10);
246 ui->lineEditKey->clear();
247 ui->lineEditDecryptResult->clear();
248 ui->lineEditPassphrase->clear();
249 ui->pushButtonImport->setVisible(
false);
255 std::string strPassphrase =
ui->lineEditPassphrase->text().toStdString();
256 std::string strKey =
ui->lineEditKey->text().toStdString();
260 if (!
BIP38_Decrypt(strPassphrase, strKey, privKey, fCompressed)) {
261 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: red; }");
262 ui->statusLabel_DEC->setText(tr(
"Failed to decrypt.") + QString(
" ") + tr(
"Please check the key and passphrase and try again."));
269 ui->pushButtonImport->setVisible(
true);
277 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: red; }");
278 ui->statusLabel_DEC->setText(tr(
"Wallet is currently rescanning. Abort existing rescan or wait."));
283 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: red; }");
284 ui->statusLabel_DEC->setText(tr(
"Wallet unlock was cancelled."));
292 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: red; }");
293 ui->statusLabel_DEC->setText(tr(
"Data Not Valid.") + QString(
" ") + tr(
"Please try again."));
299 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: red; }");
300 ui->statusLabel_DEC->setText(tr(
"Please wait while key is imported"));
306 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: red; }");
307 ui->statusLabel_DEC->setText(tr(
"Cannot import address, key already held by the wallet"));
312 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: red; }");
313 ui->statusLabel_DEC->setText(tr(
"Error adding key to the wallet"));
318 ui->statusLabel_DEC->setStyleSheet(
"QLabel { color: green; }");
319 ui->statusLabel_DEC->setText(tr(
"Successfully added private key to the wallet"));
325 QWidget::resizeEvent(event);
bool BIP38_Decrypt(std::string strPassphrase, std::string strEncryptedKey, uint256 &privKey, bool &fCompressed)
std::string BIP38_Encrypt(std::string strAddress, std::string strPassphrase, uint256 privKey, bool fCompressed)
static const QString Receive
Specifies receive address.
An encapsulated private key.
bool IsValid() const
Check whether this private key is valid.
bool IsCompressed() const
Check whether the public key corresponding to this private key is (to be) compressed.
CPubKey GetPubKey() const
Compute the public key from a private key.
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
A reference to a CKey: the Hash160 of its serialized public key.
An encapsulated public key.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
bool updateAddressBookLabels(const CWDestination &address, const std::string &strName, const std::string &strPurpose)
bool haveKey(const CKeyID &keyID) const
WalletRescanReserver getRescanReserver() const
Return new wallet rescan reserver.
bool addKeys(const CKey &key, const CPubKey &pubkey, WalletRescanReserver &reserver)
AddressTableModel * getAddressTableModel()
bool getKey(const CKeyID &keyID, CKey &key) const
UnlockContext requestUnlock()
RAII object to check and reserve a wallet rescan.
const std::string RECEIVE
bool IsValidDestination(const CWDestination &address)
std::string EncodeDestination(const CWDestination &address, const CChainParams::Base58Type addrType)
CWDestination DecodeDestination(const std::string &strAddress)
void setCssTitleScreen(QLabel *label)
void initCssEditLine(QLineEdit *edit, bool isDialog)
void setShadow(QWidget *edit)
void setCssProperty(std::initializer_list< QWidget * > args, const QString &value)
void setCssSubtitleScreen(QWidget *wid)
void setCssBtnPrimary(QPushButton *btn, bool forceUpdate)
void setCssBtnSecondary(QPushButton *btn, bool forceUpdate)
boost::variant< CNoDestination, CKeyID, CScriptID, CExchangeKeyID > CTxDestination
A txout script template with a specific destination.