6 #include <qt/forms/ui_signverifymessagedialog.h> 14 #include <bitcoin-build-config.h> 25 platformStyle(_platformStyle)
41 ui->addressIn_SM->installEventFilter(
this);
42 ui->messageIn_SM->installEventFilter(
this);
43 ui->signatureOut_SM->installEventFilter(
this);
44 ui->addressIn_VM->installEventFilter(
this);
45 ui->messageIn_VM->installEventFilter(
this);
46 ui->signatureIn_VM->installEventFilter(
this);
66 ui->addressIn_SM->setText(address);
67 ui->messageIn_SM->setFocus();
72 ui->addressIn_VM->setText(address);
73 ui->messageIn_VM->setFocus();
78 ui->tabWidget->setCurrentIndex(0);
85 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 PKHash* pkhash = std::get_if<PKHash>(&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 legacy (P2PKH) key. Message signing for SegWit and other non-P2PKH address types is not supported in this version of %1. Please check the address and try again.").arg(CLIENT_NAME));
134 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
135 ui->statusLabel_SM->setText(tr(
"Wallet unlock was cancelled."));
139 const std::string& message =
ui->messageIn_SM->document()->toPlainText().toStdString();
140 std::string signature;
146 error = tr(
"No error");
149 error = tr(
"Private key for the entered address is not available.");
152 error = tr(
"Message signing failed.");
158 ui->statusLabel_SM->setStyleSheet(
"QLabel { color: red; }");
159 ui->statusLabel_SM->setText(QString(
"<nobr>") + error + 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(signature));
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();
199 const std::string& address =
ui->addressIn_VM->text().toStdString();
200 const std::string& signature =
ui->signatureIn_VM->text().toStdString();
201 const std::string& message =
ui->messageIn_VM->document()->toPlainText().toStdString();
206 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: green; }");
208 ui->statusLabel_VM->setStyleSheet(
"QLabel { color: red; }");
213 ui->statusLabel_VM->setText(
214 QString(
"<nobr>") + tr(
"Message verified.") + QString(
"</nobr>")
218 ui->statusLabel_VM->setText(
219 tr(
"The entered address is invalid.") + QString(
" ") +
220 tr(
"Please check the address and try again.")
224 ui->addressIn_VM->setValid(
false);
225 ui->statusLabel_VM->setText(tr(
"The entered address does not refer to a legacy (P2PKH) key. Message signing for SegWit and other non-P2PKH address types is not supported in this version of %1. Please check the address and try again.").arg(CLIENT_NAME));
228 ui->signatureIn_VM->setValid(
false);
229 ui->statusLabel_VM->setText(
230 tr(
"The signature could not be decoded.") + QString(
" ") +
231 tr(
"Please check the signature and try again.")
235 ui->signatureIn_VM->setValid(
false);
236 ui->statusLabel_VM->setText(
237 tr(
"The signature did not match the message digest.") + QString(
" ") +
238 tr(
"Please check the signature and try again.")
242 ui->statusLabel_VM->setText(
243 QString(
"<nobr>") + tr(
"Message verification failed.") + QString(
"</nobr>")
251 ui->addressIn_VM->clear();
252 ui->signatureIn_VM->clear();
253 ui->messageIn_VM->clear();
254 ui->statusLabel_VM->clear();
256 ui->addressIn_VM->setFocus();
261 if (event->type() == QEvent::MouseButtonPress ||
event->type() == QEvent::FocusIn)
263 if (
ui->tabWidget->currentIndex() == 0)
266 ui->statusLabel_SM->clear();
269 if (
object ==
ui->signatureOut_SM)
271 ui->signatureOut_SM->selectAll();
275 else if (
ui->tabWidget->currentIndex() == 1)
278 ui->statusLabel_VM->clear();
281 return QDialog::eventFilter(
object, event);
286 if (e->type() == QEvent::PaletteChange) {
297 QDialog::changeEvent(e);
void on_addressBookButton_SM_clicked()
void showTab_SM(bool fShow)
void on_copySignatureButton_SM_clicked()
interfaces::Wallet & wallet() const
Utility functions used by the Bitcoin Qt UI.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination corresponds to one with an address.
A public key could not be recovered from the provided signature and message.
The message verification was successful.
void setAddress_VM(const QString &address)
The provided address is invalid.
void setModel(AddressTableModel *model)
UnlockContext requestUnlock()
The provided signature couldn't be parsed (maybe invalid base64).
void on_addressBookButton_VM_clicked()
void on_pasteButton_SM_clicked()
QFont fixedPitchFont(bool use_embedded_font)
~SignVerifyMessageDialog()
MessageVerificationResult MessageVerify(const std::string &address, const std::string &signature, const std::string &message)
Verify a signed message.
Open address book to pick address.
virtual SigningResult signMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig)=0
Sign message.
void changeEvent(QEvent *e) override
Ui::SignVerifyMessageDialog * ui
constexpr auto dialog_flags
void on_signMessageButton_SM_clicked()
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
void setClipboard(const QString &str)
void handleCloseWindowShortcut(QWidget *w)
void on_verifyMessageButton_VM_clicked()
void on_clearButton_VM_clicked()
void refresh(bool pk_hash_only=false)
Widget that shows a list of sending or receiving addresses.
SignVerifyMessageDialog(const PlatformStyle *platformStyle, QWidget *parent)
void on_clearButton_SM_clicked()
Interface to Bitcoin wallet from Qt view code.
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
bool eventFilter(QObject *object, QEvent *event) override
The message was not signed with the private key of the provided address.
The provided address is valid but does not refer to a public key.
AddressTableModel * getAddressTableModel() const
const PlatformStyle * platformStyle
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
void setModel(WalletModel *model)
void showTab_VM(bool fShow)
const QString & getReturnValue() const
void setAddress_SM(const QString &address)