gui: fix misleading signmessage error with segwit

As described in #10542 (and numerous other places), message signing in
Bitcoin Core only supports message signing using P2PKH addresses, at
least until a new message-signing standard is agreed upon.

Therefore update the possibly-misleading error message presented to the
user in the GUI to detail more specifically the reason their message
cannot be signed, in the case that a non P2PKH address is entered.

Github-Pull: gui#819
Rebased-From: fb9f150759
This commit is contained in:
willcl-ark 2024-04-29 13:50:08 +01:00 committed by Luke Dashjr
parent a840dab2a5
commit 1cc2de7e27
2 changed files with 4 additions and 6 deletions

View File

@ -30,7 +30,7 @@
<item> <item>
<widget class="QLabel" name="infoLabel_SM"> <widget class="QLabel" name="infoLabel_SM">
<property name="text"> <property name="text">
<string>You can sign messages/agreements with your addresses to prove you can receive bitcoins sent to them. Be careful not to sign anything vague or random, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to.</string> <string>You can sign messages/agreements with your legacy (P2PKH) addresses to prove you can receive bitcoins sent to them. Be careful not to sign anything vague or random, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to.</string>
</property> </property>
<property name="textFormat"> <property name="textFormat">
<enum>Qt::PlainText</enum> <enum>Qt::PlainText</enum>

View File

@ -10,6 +10,7 @@
#include <qt/platformstyle.h> #include <qt/platformstyle.h>
#include <qt/walletmodel.h> #include <qt/walletmodel.h>
#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <key_io.h> #include <key_io.h>
#include <util/message.h> // For MessageSign(), MessageVerify() #include <util/message.h> // For MessageSign(), MessageVerify()
#include <wallet/wallet.h> #include <wallet/wallet.h>
@ -121,7 +122,7 @@ void SignVerifyMessageDialog::on_signMessageButton_SM_clicked()
if (!pkhash) { if (!pkhash) {
ui->addressIn_SM->setValid(false); ui->addressIn_SM->setValid(false);
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_SM->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again.")); 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(PACKAGE_NAME));
return; return;
} }
@ -219,10 +220,7 @@ void SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked()
return; return;
case MessageVerificationResult::ERR_ADDRESS_NO_KEY: case MessageVerificationResult::ERR_ADDRESS_NO_KEY:
ui->addressIn_VM->setValid(false); ui->addressIn_VM->setValid(false);
ui->statusLabel_VM->setText( 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(PACKAGE_NAME));
tr("The entered address does not refer to a key.") + QString(" ") +
tr("Please check the address and try again.")
);
return; return;
case MessageVerificationResult::ERR_MALFORMED_SIGNATURE: case MessageVerificationResult::ERR_MALFORMED_SIGNATURE:
ui->signatureIn_VM->setValid(false); ui->signatureIn_VM->setValid(false);