7 #include "ui_signverifymessagedialog.h" 16 #include "validation.h" 28 platformStyle(_platformStyle)
41 #if QT_VERSION >= 0x040700 42 ui->signatureOut_SM->setPlaceholderText(tr(
"Click \"Sign Message\" to generate signature"));
48 ui->addressIn_SM->installEventFilter(
this);
49 ui->messageIn_SM->installEventFilter(
this);
50 ui->signatureOut_SM->installEventFilter(
this);
51 ui->addressIn_VM->installEventFilter(
this);
52 ui->messageIn_VM->installEventFilter(
this);
53 ui->signatureIn_VM->installEventFilter(
this);
71 ui->addressIn_SM->setText(address);
72 ui->messageIn_SM->setFocus();
77 ui->addressIn_VM->setText(address);
78 ui->messageIn_VM->setFocus();
83 ui->tabWidget->setCurrentIndex(0);
90 ui->tabWidget->setCurrentIndex(1);
119 ui->signatureOut_SM->clear();
123 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
124 ui->statusLabel_SM->setText(tr(
"The entered address is invalid.") + QString(
" ") + tr(
"Please check the address and try again."));
127 const CKeyID* keyID = boost::get<CKeyID>(&destination);
129 ui->addressIn_SM->setValid(
false);
130 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
131 ui->statusLabel_SM->setText(tr(
"The entered address does not refer to a key.") + QString(
" ") + tr(
"Please check the address and try again."));
138 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
139 ui->statusLabel_SM->setText(tr(
"Wallet unlock was cancelled."));
146 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
147 ui->statusLabel_SM->setText(tr(
"Private key for the entered address is not available."));
153 ss <<
ui->messageIn_SM->document()->toPlainText().toStdString();
155 std::vector<unsigned char> vchSig;
158 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
159 ui->statusLabel_SM->setText(QString(
"<nobr>") + tr(
"Message signing failed.") + QString(
"</nobr>"));
163 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: green; }");
164 ui->statusLabel_SM->setText(QString(
"<nobr>") + tr(
"Message signed.") + QString(
"</nobr>"));
166 ui->signatureOut_SM->setText(QString::fromStdString(
EncodeBase64(vchSig.data(), vchSig.size())));
176 ui->addressIn_SM->clear();
177 ui->messageIn_SM->clear();
178 ui->signatureOut_SM->clear();
179 ui->statusLabel_SM->clear();
181 ui->addressIn_SM->setFocus();
201 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
202 ui->statusLabel_VM->setText(tr(
"The entered address is invalid.") + QString(
" ") + tr(
"Please check the address and try again."));
205 if (!boost::get<CKeyID>(&destination)) {
206 ui->addressIn_VM->setValid(
false);
207 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
208 ui->statusLabel_VM->setText(tr(
"The entered address does not refer to a key.") + QString(
" ") + tr(
"Please check the address and try again."));
212 bool fInvalid =
false;
213 std::vector<unsigned char> vchSig =
DecodeBase64(
ui->signatureIn_VM->text().toStdString().c_str(), &fInvalid);
217 ui->signatureIn_VM->setValid(
false);
218 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
219 ui->statusLabel_VM->setText(tr(
"The signature could not be decoded.") + QString(
" ") + tr(
"Please check the signature and try again."));
225 ss <<
ui->messageIn_VM->document()->toPlainText().toStdString();
230 ui->signatureIn_VM->setValid(
false);
231 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
232 ui->statusLabel_VM->setText(tr(
"The signature did not match the message digest.") + QString(
" ") + tr(
"Please check the signature and try again."));
237 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
238 ui->statusLabel_VM->setText(QString(
"<nobr>") + tr(
"Message verification failed.") + QString(
"</nobr>"));
242 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: green; }");
243 ui->statusLabel_VM->setText(QString(
"<nobr>") + tr(
"Message verified.") + QString(
"</nobr>"));
248 ui->addressIn_VM->clear();
249 ui->signatureIn_VM->clear();
250 ui->messageIn_VM->clear();
251 ui->statusLabel_VM->clear();
253 ui->addressIn_VM->setFocus();
258 if (event->type() == QEvent::MouseButtonPress ||
event->type() == QEvent::FocusIn)
260 if (
ui->tabWidget->currentIndex() == 0)
263 ui->statusLabel_SM->clear();
266 if (
object ==
ui->signatureOut_SM)
268 ui->signatureOut_SM->selectAll();
272 else if (
ui->tabWidget->currentIndex() == 1)
275 ui->statusLabel_VM->clear();
278 return QDialog::eventFilter(
object, event);
void on_addressBookButton_SM_clicked()
void showTab_SM(bool fShow)
void on_copySignatureButton_SM_clicked()
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
bool eventFilter(QObject *object, QEvent *event)
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.
CTxDestination DecodeDestination(const std::string &str)
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)
bool getPrivKey(const CKeyID &address, CKey &vchPrivKeyOut) const
void setClipboard(const QString &str)
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()
Interface to Raven wallet from Qt view code.
A reference to a CKey: the Hash160 of its serialized public key.
A writer stream (for serialization) that computes a 256-bit hash.
An encapsulated private key.
const PlatformStyle * platformStyle
void setModel(WalletModel *model)
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)