6 #include <qt/forms/ui_signverifymessagedialog.h> 14 #include <validation.h> 26 platformStyle(_platformStyle)
39 ui->signatureOut_SM->setPlaceholderText(tr(
"Click \"Sign Message\" to generate signature"));
44 ui->addressIn_SM->installEventFilter(
this);
45 ui->messageIn_SM->installEventFilter(
this);
46 ui->signatureOut_SM->installEventFilter(
this);
47 ui->addressIn_VM->installEventFilter(
this);
48 ui->messageIn_VM->installEventFilter(
this);
49 ui->signatureIn_VM->installEventFilter(
this);
67 ui->addressIn_SM->setText(address);
68 ui->messageIn_SM->setFocus();
73 ui->addressIn_VM->setText(address);
74 ui->messageIn_VM->setFocus();
79 ui->tabWidget->setCurrentIndex(0);
86 ui->tabWidget->setCurrentIndex(1);
115 ui->signatureOut_SM->clear();
119 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
120 ui->statusLabel_SM->setText(tr(
"The entered address is invalid.") + QString(
" ") + tr(
"Please check the address and try again."));
123 const CKeyID* keyID = boost::get<CKeyID>(&destination);
125 ui->addressIn_SM->setValid(
false);
126 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
127 ui->statusLabel_SM->setText(tr(
"The entered address does not refer to a key.") + QString(
" ") + tr(
"Please check the address and try again."));
134 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
135 ui->statusLabel_SM->setText(tr(
"Wallet unlock was cancelled."));
142 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
143 ui->statusLabel_SM->setText(tr(
"Private key for the entered address is not available."));
149 ss <<
ui->messageIn_SM->document()->toPlainText().toStdString();
151 std::vector<unsigned char> vchSig;
154 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
155 ui->statusLabel_SM->setText(QString(
"<nobr>") + tr(
"Message signing failed.") + QString(
"</nobr>"));
159 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: green; }");
160 ui->statusLabel_SM->setText(QString(
"<nobr>") + tr(
"Message signed.") + QString(
"</nobr>"));
162 ui->signatureOut_SM->setText(QString::fromStdString(
EncodeBase64(vchSig.data(), vchSig.size())));
172 ui->addressIn_SM->clear();
173 ui->messageIn_SM->clear();
174 ui->signatureOut_SM->clear();
175 ui->statusLabel_SM->clear();
177 ui->addressIn_SM->setFocus();
197 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
198 ui->statusLabel_VM->setText(tr(
"The entered address is invalid.") + QString(
" ") + tr(
"Please check the address and try again."));
201 if (!boost::get<CKeyID>(&destination)) {
202 ui->addressIn_VM->setValid(
false);
203 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
204 ui->statusLabel_VM->setText(tr(
"The entered address does not refer to a key.") + QString(
" ") + tr(
"Please check the address and try again."));
208 bool fInvalid =
false;
209 std::vector<unsigned char> vchSig =
DecodeBase64(
ui->signatureIn_VM->text().toStdString().c_str(), &fInvalid);
213 ui->signatureIn_VM->setValid(
false);
214 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
215 ui->statusLabel_VM->setText(tr(
"The signature could not be decoded.") + QString(
" ") + tr(
"Please check the signature and try again."));
221 ss <<
ui->messageIn_VM->document()->toPlainText().toStdString();
226 ui->signatureIn_VM->setValid(
false);
227 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
228 ui->statusLabel_VM->setText(tr(
"The signature did not match the message digest.") + QString(
" ") + tr(
"Please check the signature and try again."));
233 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
234 ui->statusLabel_VM->setText(QString(
"<nobr>") + tr(
"Message verification failed.") + QString(
"</nobr>"));
238 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: green; }");
239 ui->statusLabel_VM->setText(QString(
"<nobr>") + tr(
"Message verified.") + QString(
"</nobr>"));
244 ui->addressIn_VM->clear();
245 ui->signatureIn_VM->clear();
246 ui->messageIn_VM->clear();
247 ui->statusLabel_VM->clear();
249 ui->addressIn_VM->setFocus();
254 if (event->type() == QEvent::MouseButtonPress ||
event->type() == QEvent::FocusIn)
256 if (
ui->tabWidget->currentIndex() == 0)
259 ui->statusLabel_SM->clear();
262 if (
object ==
ui->signatureOut_SM)
264 ui->signatureOut_SM->selectAll();
268 else if (
ui->tabWidget->currentIndex() == 1)
271 ui->statusLabel_VM->clear();
274 return QDialog::eventFilter(
object, event);
void on_addressBookButton_SM_clicked()
void showTab_SM(bool fShow)
void on_copySignatureButton_SM_clicked()
bool eventFilter(QObject *object, QEvent *event)
interfaces::Wallet & wallet() const
std::vector< unsigned char > DecodeBase64(const char *p, bool *pfInvalid)
void setAddress_VM(const QString &address)
void setModel(AddressTableModel *model)
UnlockContext requestUnlock()
void on_addressBookButton_VM_clicked()
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
void on_pasteButton_SM_clicked()
~SignVerifyMessageDialog()
Open address book to pick address.
AddressTableModel * getAddressTableModel()
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
const std::string strMessageMagic
Ui::SignVerifyMessageDialog * ui
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
Create a compact signature (65 bytes), which allows reconstructing the used public key...
void on_signMessageButton_SM_clicked()
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
void setClipboard(const QString &str)
boost::variant< CNoDestination, CKeyID, CScriptID, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
bool RecoverCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig)
Recover a public key from a compact signature.
void on_verifyMessageButton_VM_clicked()
An encapsulated public key.
void on_clearButton_VM_clicked()
Widget that shows a list of sending or receiving addresses.
SignVerifyMessageDialog(const PlatformStyle *platformStyle, QWidget *parent)
void on_clearButton_SM_clicked()
CTxDestination DecodeDestination(const std::string &str)
Interface to Bitcoin wallet from Qt view code.
A reference to a CKey: the Hash360 of its serialized public key.
A writer stream (for serialization) that computes a 256-bit SHA-3-256 hash.
An encapsulated private key.
const PlatformStyle * platformStyle
void setModel(WalletModel *model)
virtual bool getPrivKey(const CKeyID &address, CKey &key)=0
Get private key.
void showTab_VM(bool fShow)
std::string EncodeBase64(const unsigned char *pch, size_t len)
const QString & getReturnValue() const
void setAddress_SM(const QString &address)