Remove user input from URI error message

+ Detailed error messages for invalid address
+ Used `IsValidDestination` instead of `IsValidDestinationString`
+ Referred to https://github.com/bitcoin/bitcoin/pull/20832 for solution
This commit is contained in:
unknown 2021-04-14 01:21:49 +05:30
parent a1f0b8b62e
commit 3bad0b3fad

View file

@ -232,7 +232,10 @@ void PaymentServer::handleURIOrFile(const QString& s)
SendCoinsRecipient recipient;
if (GUIUtil::parseBitcoinURI(s, &recipient))
{
if (!IsValidDestinationString(recipient.address.toStdString())) {
std::string error_msg;
const CTxDestination dest = DecodeDestination(recipient.address.toStdString(), error_msg);
if (!IsValidDestination(dest)) {
if (uri.hasQueryItem("r")) { // payment request
Q_EMIT message(tr("URI handling"),
tr("Cannot process payment request because BIP70 is not supported.\n"
@ -240,7 +243,7 @@ void PaymentServer::handleURIOrFile(const QString& s)
"If you are receiving this error you should request the merchant provide a BIP21 compatible URI."),
CClientUIInterface::ICON_WARNING);
}
Q_EMIT message(tr("URI handling"), tr("Invalid payment address %1").arg(recipient.address),
Q_EMIT message(tr("URI handling"), QString::fromStdString(error_msg),
CClientUIInterface::MSG_ERROR);
}
else