5#include <qt/forms/ui_signverifymessagedialog.h>
27 ui->addressBookButton_SM->setIcon(
29 ui->pasteButton_SM->setIcon(
31 ui->copySignatureButton_SM->setIcon(
33 ui->signMessageButton_SM->setIcon(
35 ui->clearButton_SM->setIcon(
37 ui->addressBookButton_VM->setIcon(
39 ui->verifyMessageButton_VM->setIcon(
41 ui->clearButton_VM->setIcon(
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);
69 ui->addressIn_SM->setText(address);
70 ui->messageIn_SM->setFocus();
74 ui->addressIn_VM->setText(address);
75 ui->messageIn_VM->setFocus();
79 ui->tabWidget->setCurrentIndex(0);
86 ui->tabWidget->setCurrentIndex(1);
114 ui->signatureOut_SM->clear();
119 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
120 ui->statusLabel_SM->setText(
121 tr(
"The entered address is invalid.") +
QString(
" ") +
122 tr(
"Please check the address and try again."));
125 const PKHash *
pkhash = std::get_if<PKHash>(&destination);
127 ui->addressIn_SM->setValid(
false);
128 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
129 ui->statusLabel_SM->setText(
130 tr(
"The entered address does not refer to a key.") +
QString(
" ") +
131 tr(
"Please check the address and try again."));
136 if (!
ctx.isValid()) {
137 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
138 ui->statusLabel_SM->setText(
tr(
"Wallet unlock was cancelled."));
142 const std::string &message =
143 ui->messageIn_SM->document()->toPlainText().toStdString();
144 std::string signature;
154 error =
tr(
"Private key for the entered address is not available.");
157 error =
tr(
"Message signing failed.");
163 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
169 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: green; }");
170 ui->statusLabel_SM->setText(
QString(
"<nobr>") +
tr(
"Message signed.") +
173 ui->signatureOut_SM->setText(QString::fromStdString(signature));
181 ui->addressIn_SM->clear();
182 ui->messageIn_SM->clear();
183 ui->signatureOut_SM->clear();
184 ui->statusLabel_SM->clear();
186 ui->addressIn_SM->setFocus();
201 const std::string &address =
ui->addressIn_VM->text().toStdString();
202 const std::string &signature =
ui->signatureIn_VM->text().toStdString();
203 const std::string &message =
204 ui->messageIn_VM->document()->toPlainText().toStdString();
210 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: green; }");
212 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
217 ui->statusLabel_VM->setText(
QString(
"<nobr>") +
218 tr(
"Message verified.") +
222 ui->statusLabel_VM->setText(
223 tr(
"The entered address is invalid.") +
QString(
" ") +
224 tr(
"Please check the address and try again."));
227 ui->addressIn_VM->setValid(
false);
228 ui->statusLabel_VM->setText(
229 tr(
"The entered address does not refer to a key.") +
230 QString(
" ") +
tr(
"Please check the address and try again."));
233 ui->signatureIn_VM->setValid(
false);
234 ui->statusLabel_VM->setText(
235 tr(
"The signature could not be decoded.") +
QString(
" ") +
236 tr(
"Please check the signature and try again."));
239 ui->signatureIn_VM->setValid(
false);
240 ui->statusLabel_VM->setText(
241 tr(
"The signature did not match the message digest.") +
242 QString(
" ") +
tr(
"Please check the signature and try again."));
245 ui->statusLabel_VM->setText(
QString(
"<nobr>") +
246 tr(
"Message verification failed.") +
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();
262 if (event->type() == QEvent::MouseButtonPress ||
263 event->type() == QEvent::FocusIn) {
264 if (
ui->tabWidget->currentIndex() == 0) {
266 ui->statusLabel_SM->clear();
269 if (
object ==
ui->signatureOut_SM) {
270 ui->signatureOut_SM->selectAll();
273 }
else if (
ui->tabWidget->currentIndex() == 1) {
275 ui->statusLabel_VM->clear();
278 return QDialog::eventFilter(
object, event);
Widget that shows a list of sending or receiving addresses.
@ ForSelection
Open address book to pick address.
void on_clearButton_VM_clicked()
void on_signMessageButton_SM_clicked()
void showTab_SM(bool fShow)
~SignVerifyMessageDialog()
bool eventFilter(QObject *object, QEvent *event) override
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.
const CChainParams & getChainParams() const
AddressTableModel * getAddressTableModel()
interfaces::Wallet & wallet() const
UnlockContext requestUnlock()
virtual SigningResult signMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig)=0
Sign message.
CTxDestination DecodeDestination(const std::string &addr, const CChainParams ¶ms)
bool error(const char *fmt, const Args &...args)
MessageVerificationResult MessageVerify(const CChainParams ¶ms, const std::string &address, const std::string &signature, const std::string &message)
Verify a signed message.
@ PRIVATE_KEY_NOT_AVAILABLE
@ ERR_MALFORMED_SIGNATURE
The provided signature couldn't be parsed (maybe invalid base64).
@ ERR_INVALID_ADDRESS
The provided address is invalid.
@ ERR_ADDRESS_NO_KEY
The provided address is valid but does not refer to a public key.
@ ERR_NOT_SIGNED
The message was not signed with the private key of the provided address.
@ OK
The message verification was successful.
@ ERR_PUBKEY_NOT_RECOVERED
A public key could not be recovered from the provided signature and message.
void handleCloseWindowShortcut(QWidget *w)
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
void setClipboard(const QString &str)
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.