6 #include "qt/settings/forms/ui_signmessagewidgets.h"
26 this->setStyleSheet(parent->styleSheet());
29 ui->left->setProperty(
"cssClass",
"container");
30 ui->left->setContentsMargins(10,10,10,10);
33 ui->labelTitle->setProperty(
"cssClass",
"text-title-screen");
34 ui->labelSubtitle1->setProperty(
"cssClass",
"text-subtitle");
37 ui->labelSubtitleAddress->setProperty(
"cssClass",
"text-title");
38 ui->addressIn_SM->setProperty(
"cssClass",
"edit-primary-multi-book");
39 ui->addressIn_SM->setAttribute(Qt::WA_MacShowFocusRect, 0);
45 ui->labelSubtitleSwitch->setText(tr(
"Select mode"));
47 ui->pushSign->setChecked(
true);
51 ui->labelSubtitleMessage->setProperty(
"cssClass",
"text-title");
52 ui->messageIn_SM->setProperty(
"cssClass",
"edit-primary");
54 ui->messageIn_SM->setAttribute(Qt::WA_MacShowFocusRect, 0);
57 ui->labelSubtitleSignature->setProperty(
"cssClass",
"text-title");
58 ui->signatureOut_SM->setAttribute(Qt::WA_MacShowFocusRect, 0);
64 btnContact =
ui->addressIn_SM->addAction(QIcon(
"://ic-contact-arrow-down"), QLineEdit::TrailingPosition);
69 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: transparent; }");
74 connect(
ui->pushSign, &QPushButton::clicked, [
this](){onModeSelected(true);});
75 connect(
ui->pushVerify, &QPushButton::clicked, [
this](){onModeSelected(false);});
85 if (
ui->addressIn_SM)
ui->addressIn_SM->setFocus();
108 subtitle = tr(
"You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to.");
110 ui->signatureOut_SM->setReadOnly(
true);
111 ui->signatureOut_SM->clear();
113 subtitle = tr(
"Enter the signing address, message (ensure you copy line breaks, spaces, tabs, etc. exactly) and signature below to verify the message. Be careful not to read more into the signature than what is in the signed message itself, to avoid being tricked by a man-in-the-middle attack.");
115 ui->signatureOut_SM->setReadOnly(
false);
117 ui->labelSubtitle1->setText(subtitle);
118 ui->pushButtonSave->setText(go);
123 ui->addressIn_SM->setText(address);
124 ui->messageIn_SM->setFocus();
129 ui->addressIn_SM->clear();
130 ui->signatureOut_SM->clear();
131 ui->messageIn_SM->clear();
132 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: transparent; }");
141 ui->signatureOut_SM->clear();
145 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
146 ui->statusLabel_SM->setText(tr(
"The entered address is invalid.") + QString(
" ") + tr(
"Please check the address and try again."));
149 const CKeyID* keyID = boost::get<CKeyID>(&addr);
153 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
154 ui->statusLabel_SM->setText(tr(
"The entered address does not refer to a key.") + QString(
" ") + tr(
"Please check the address and try again."));
160 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
161 ui->statusLabel_SM->setText(tr(
"Wallet unlock was cancelled."));
167 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
168 ui->statusLabel_SM->setText(tr(
"Private key for the entered address is not available."));
172 const std::string&
message =
ui->messageIn_SM->document()->toPlainText().toStdString();
174 std::vector<unsigned char> vchSig;
176 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
177 ui->statusLabel_SM->setText(QString(
"<nobr>") + tr(
"Message signing failed.") + QString(
"</nobr>"));
181 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: green; }");
182 ui->statusLabel_SM->setText(QString(
"<nobr>") + tr(
"Message signed.") + QString(
"</nobr>"));
183 ui->signatureOut_SM->setText(QString::fromStdString(
EncodeBase64(vchSig)));
197 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
198 ui->statusLabel_SM->setText(tr(
"The entered address is invalid.") + QString(
" ") + tr(
"Please check the address and try again."));
201 const CKeyID* keyID = boost::get<CKeyID>(&addr);
204 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
205 ui->statusLabel_SM->setText(tr(
"The entered address does not refer to a key.") + QString(
" ") + tr(
"Please check the address and try again."));
209 bool fInvalid =
false;
210 std::vector<unsigned char> vchSig =
DecodeBase64(
ui->signatureOut_SM->text().toStdString().c_str(), &fInvalid);
214 ui->signatureOut_SM->setStyleSheet(
"QLabel { color: red; }");
215 ui->signatureOut_SM->setText(tr(
"The signature could not be decoded.") + QString(
" ") + tr(
"Please check the signature and try again."));
219 const std::string&
message =
ui->messageIn_SM->document()->toPlainText().toStdString();
223 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
224 ui->statusLabel_SM->setText(QString(
"<nobr>") + tr(
"Message verification failed.") + QString(
"</nobr>"));
228 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: green; }");
229 ui->statusLabel_SM->setText(QString(
"<nobr>") + tr(
"Message verified.") + QString(
"</nobr>"));
235 if (addressSize == 0) {
236 inform(tr(
"No addresses available, you can go to the receive screen and add some there!"));
240 int height = (addressSize <= 2) ?
ui->addressIn_SM->height() * ( 2 * (addressSize + 1 )) :
ui->addressIn_SM->height() * 4;
241 int width =
ui->containerAddress->width();
265 QPoint pos =
ui->container_sign->mapToParent(
ui->containerAddress->rect().bottomLeft());
266 pos.setY(pos.y() + (
ui->containerAddress->height() * 1.4) - 10);
274 int width =
ui->containerAddress->width();
277 QPoint pos =
ui->container_sign->mapToParent(
ui->containerAddress->rect().bottomLeft());
278 pos.setY(pos.y() + (
ui->containerAddress->height() * 1.4) - 10);
286 QWidget::resizeEvent(event);
static const QString Receive
Specifies receive address.
An encapsulated private key.
A reference to a CKey: the Hash160 of its serialized public key.
static bool SignMessage(const std::string &strMessage, std::vector< unsigned char > &vchSigRet, const CKey &key)
Sign the message, returns true if successful.
static bool VerifyMessage(const CPubKey &pubkey, const std::vector< unsigned char > &vchSig, const std::string &strMessage, std::string &strErrorRet)
Verify the message signature, returns true if successful.
AddressTableModel * getAddressTableModel()
bool getKey(const CKeyID &keyID, CKey &key) const
UnlockContext requestUnlock()
bool IsValidDestination(const CWDestination &address)
CWDestination DecodeDestination(const std::string &strAddress)
void initCssEditLine(QLineEdit *edit, bool isDialog)
void setShadow(QWidget *edit)
void setCssProperty(std::initializer_list< QWidget * > args, const QString &value)
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.
std::string EncodeBase64(Span< const unsigned char > input)
std::vector< unsigned char > DecodeBase64(const char *p, bool *pfInvalid)