6 #include "ui_signverifymessagedialog.h"
15 #include "validation.h"
27 platformStyle(_platformStyle)
40 #if QT_VERSION >= 0x040700
41 ui->signatureOut_SM->setPlaceholderText(tr(
"Click \"Sign Message\" to generate signature"));
47 ui->addressIn_SM->installEventFilter(
this);
48 ui->messageIn_SM->installEventFilter(
this);
49 ui->signatureOut_SM->installEventFilter(
this);
50 ui->addressIn_VM->installEventFilter(
this);
51 ui->messageIn_VM->installEventFilter(
this);
52 ui->signatureIn_VM->installEventFilter(
this);
70 ui->addressIn_SM->setText(address);
71 ui->messageIn_SM->setFocus();
76 ui->addressIn_VM->setText(address);
77 ui->messageIn_VM->setFocus();
82 ui->tabWidget->setCurrentIndex(0);
89 ui->tabWidget->setCurrentIndex(1);
118 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."));
130 ui->addressIn_SM->setValid(
false);
131 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
132 ui->statusLabel_SM->setText(tr(
"The entered address does not refer to a key.") + QString(
" ") + tr(
"Please check the address and try again."));
139 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
140 ui->statusLabel_SM->setText(tr(
"Wallet unlock was cancelled."));
147 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
148 ui->statusLabel_SM->setText(tr(
"Private key for the entered address is not available."));
154 ss <<
ui->messageIn_SM->document()->toPlainText().toStdString();
156 std::vector<unsigned char> vchSig;
159 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
160 ui->statusLabel_SM->setText(QString(
"<nobr>") + tr(
"Message signing failed.") + QString(
"</nobr>"));
164 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: green; }");
165 ui->statusLabel_SM->setText(QString(
"<nobr>") + tr(
"Message signed.") + QString(
"</nobr>"));
167 ui->signatureOut_SM->setText(QString::fromStdString(
EncodeBase64(&vchSig[0], vchSig.size())));
177 ui->addressIn_SM->clear();
178 ui->messageIn_SM->clear();
179 ui->signatureOut_SM->clear();
180 ui->statusLabel_SM->clear();
182 ui->addressIn_SM->setFocus();
203 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
204 ui->statusLabel_VM->setText(tr(
"The entered address is invalid.") + QString(
" ") + tr(
"Please check the address and try again."));
210 ui->addressIn_VM->setValid(
false);
211 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
212 ui->statusLabel_VM->setText(tr(
"The entered address does not refer to a key.") + QString(
" ") + tr(
"Please check the address and try again."));
216 bool fInvalid =
false;
217 std::vector<unsigned char> vchSig =
DecodeBase64(
ui->signatureIn_VM->text().toStdString().c_str(), &fInvalid);
221 ui->signatureIn_VM->setValid(
false);
222 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
223 ui->statusLabel_VM->setText(tr(
"The signature could not be decoded.") + QString(
" ") + tr(
"Please check the signature and try again."));
229 ss <<
ui->messageIn_VM->document()->toPlainText().toStdString();
234 ui->signatureIn_VM->setValid(
false);
235 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
236 ui->statusLabel_VM->setText(tr(
"The signature did not match the message digest.") + QString(
" ") + tr(
"Please check the signature and try again."));
242 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
243 ui->statusLabel_VM->setText(QString(
"<nobr>") + tr(
"Message verification failed.") + QString(
"</nobr>"));
247 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: green; }");
248 ui->statusLabel_VM->setText(QString(
"<nobr>") + tr(
"Message verified.") + QString(
"</nobr>"));
253 ui->addressIn_VM->clear();
254 ui->signatureIn_VM->clear();
255 ui->messageIn_VM->clear();
256 ui->statusLabel_VM->clear();
258 ui->addressIn_VM->setFocus();
263 if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::FocusIn)
265 if (
ui->tabWidget->currentIndex() == 0)
268 ui->statusLabel_SM->clear();
271 if (
object ==
ui->signatureOut_SM)
273 ui->signatureOut_SM->selectAll();
277 else if (
ui->tabWidget->currentIndex() == 1)
280 ui->statusLabel_VM->clear();
283 return QDialog::eventFilter(
object, event);
Widget that shows a list of sending or receiving addresses.
@ ForSelection
Open address book to pick address.
void setModel(AddressTableModel *model)
const QString & getReturnValue() const
base58-encoded Bitcoin addresses.
bool GetKeyID(CKeyID &keyID) const
A writer stream (for serialization) that computes a 256-bit hash.
An encapsulated private key.
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
Create a compact signature (65 bytes), which allows reconstructing the used public key.
A reference to a CKey: the Hash160 of its serialized public key.
An encapsulated public key.
bool RecoverCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig)
Recover a public key from a compact signature.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
bool eventFilter(QObject *object, QEvent *event)
void on_clearButton_VM_clicked()
void on_signMessageButton_SM_clicked()
void showTab_SM(bool fShow)
~SignVerifyMessageDialog()
void on_pasteButton_SM_clicked()
void on_copySignatureButton_SM_clicked()
void setAddress_SM(const QString &address)
void showTab_VM(bool fShow)
void on_addressBookButton_SM_clicked()
SignVerifyMessageDialog(const PlatformStyle *platformStyle, QWidget *parent)
void on_addressBookButton_VM_clicked()
const PlatformStyle * platformStyle
void setModel(WalletModel *model)
Ui::SignVerifyMessageDialog * ui
void on_clearButton_SM_clicked()
void on_verifyMessageButton_VM_clicked()
void setAddress_VM(const QString &address)
Interface to Bitcoin wallet from Qt view code.
bool getPrivKey(const CKeyID &address, CKey &vchPrivKeyOut) const
AddressTableModel * getAddressTableModel()
UnlockContext requestUnlock()
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
void setClipboard(const QString &str)
vector< unsigned char > DecodeBase64(const char *p, bool *pfInvalid)
string EncodeBase64(const unsigned char *pch, size_t len)
const std::string strMessageMagic