6 #include <qt/forms/ui_signverifymessagedialog.h>
24 platformStyle(_platformStyle)
40 ui->addressIn_SM->installEventFilter(
this);
41 ui->messageIn_SM->installEventFilter(
this);
42 ui->signatureOut_SM->installEventFilter(
this);
43 ui->addressIn_VM->installEventFilter(
this);
44 ui->messageIn_VM->installEventFilter(
this);
45 ui->signatureIn_VM->installEventFilter(
this);
65 ui->addressIn_SM->setText(address);
66 ui->messageIn_SM->setFocus();
71 ui->addressIn_VM->setText(address);
72 ui->messageIn_VM->setFocus();
77 ui->tabWidget->setCurrentIndex(0);
84 ui->tabWidget->setCurrentIndex(1);
114 ui->signatureOut_SM->clear();
118 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
119 ui->statusLabel_SM->setText(tr(
"The entered address is invalid.") + QString(
" ") + tr(
"Please check the address and try again."));
122 const PKHash* pkhash = std::get_if<PKHash>(&destination);
124 ui->addressIn_SM->setValid(
false);
125 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
126 ui->statusLabel_SM->setText(tr(
"The entered address does not refer to a key.") + QString(
" ") + tr(
"Please check the address and try again."));
133 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
134 ui->statusLabel_SM->setText(tr(
"Wallet unlock was cancelled."));
138 const std::string& message =
ui->messageIn_SM->document()->toPlainText().toStdString();
139 std::string signature;
145 error = tr(
"No error");
148 error = tr(
"Private key for the entered address is not available.");
151 error = tr(
"Message signing failed.");
157 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
158 ui->statusLabel_SM->setText(QString(
"<nobr>") + error + QString(
"</nobr>"));
162 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: green; }");
163 ui->statusLabel_SM->setText(QString(
"<nobr>") + tr(
"Message signed.") + QString(
"</nobr>"));
165 ui->signatureOut_SM->setText(QString::fromStdString(signature));
175 ui->addressIn_SM->clear();
176 ui->messageIn_SM->clear();
177 ui->signatureOut_SM->clear();
178 ui->statusLabel_SM->clear();
180 ui->addressIn_SM->setFocus();
198 const std::string& address =
ui->addressIn_VM->text().toStdString();
199 const std::string& signature =
ui->signatureIn_VM->text().toStdString();
200 const std::string& message =
ui->messageIn_VM->document()->toPlainText().toStdString();
202 const auto result =
MessageVerify(address, signature, message);
205 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: green; }");
207 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
212 ui->statusLabel_VM->setText(
213 QString(
"<nobr>") + tr(
"Message verified.") + QString(
"</nobr>")
217 ui->statusLabel_VM->setText(
218 tr(
"The entered address is invalid.") + QString(
" ") +
219 tr(
"Please check the address and try again.")
223 ui->addressIn_VM->setValid(
false);
224 ui->statusLabel_VM->setText(
225 tr(
"The entered address does not refer to a key.") + QString(
" ") +
226 tr(
"Please check the address and try again.")
230 ui->signatureIn_VM->setValid(
false);
231 ui->statusLabel_VM->setText(
232 tr(
"The signature could not be decoded.") + QString(
" ") +
233 tr(
"Please check the signature and try again.")
237 ui->signatureIn_VM->setValid(
false);
238 ui->statusLabel_VM->setText(
239 tr(
"The signature did not match the message digest.") + QString(
" ") +
240 tr(
"Please check the signature and try again.")
244 ui->statusLabel_VM->setText(
245 QString(
"<nobr>") + tr(
"Message verification failed.") + 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);
288 if (e->type() == QEvent::PaletteChange) {
299 QDialog::changeEvent(e);
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination corresponds to one with an address.
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
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
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()
void changeEvent(QEvent *e) override
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.
void refresh(bool pk_hash_only=false)
AddressTableModel * getAddressTableModel() const
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 &str, std::string &error_msg, std::vector< int > *error_locations)
@ 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.
Utility functions used by the Bitcoin Qt UI.
QFont fixedPitchFont(bool use_embedded_font)
void handleCloseWindowShortcut(QWidget *w)
constexpr auto dialog_flags
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
void setClipboard(const QString &str)
MessageVerificationResult MessageVerify(const std::string &address, const std::string &signature, const std::string &message)
Verify a signed message.