mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-30 18:51:15 +02:00
Merge #17031: gui: Prevent processing duplicate payment requests
3f89e1eb23
Prevent processing duplicate payment requests (João Barbosa) Pull request description: Considering the following from Qt [src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm#L267](13e0a36626/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm (L267)
) ```cpp - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames { Q_UNUSED(filenames); Q_UNUSED(sender); for (NSString *fileName in filenames) { QString qtFileName = QString::fromNSString(fileName); if (inLaunch) { // We need to be careful because Cocoa will be nice enough to take // command line arguments and send them to us as events. Given the history // of Qt Applications, this will result in behavior people don't want, as // they might be doing the opening themselves with the command line parsing. if (qApp->arguments().contains(qtFileName)) continue; } QWindowSystemInterface::handleFileOpenEvent(qtFileName); } ``` And thata2714a5c69
was merged, now Qt isn't able to filter out the above notifications, and then a [QFileOpenEvent](https://doc.qt.io/qt-5/qfileopenevent.html) event is delivered to `PaymentServer::eventFilter`, which in turn (re)adds the payment request. This change fixes #17025, but makes sense regardless of the issue. ACKs for top commit: laanwj: Nah, this seems fine, utACK3f89e1eb23
Sjors: ACK3f89e1e
on macOS 10.14.6 achow101: Code review ACK3f89e1eb23
Tree-SHA512: dd1e0c73fd84953418173ca71f6f5a67ad74a5dc7e3b1d54915ef0545f513df6a24f27242a77bb094e2833a478e2f3bf30ecd50251f3c55b65e780097cb8ab4d
This commit is contained in:
@ -82,7 +82,7 @@ static QString ipcServerName()
|
|||||||
// the main GUI window is up and ready to ask the user
|
// the main GUI window is up and ready to ask the user
|
||||||
// to send payment.
|
// to send payment.
|
||||||
|
|
||||||
static QList<QString> savedPaymentRequests;
|
static QSet<QString> savedPaymentRequests;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sending to the server is done synchronously, at startup.
|
// Sending to the server is done synchronously, at startup.
|
||||||
@ -107,7 +107,8 @@ void PaymentServer::ipcParseCommandLine(interfaces::Node& node, int argc, char*
|
|||||||
// will start a mainnet instance and throw a "wrong network" error.
|
// will start a mainnet instance and throw a "wrong network" error.
|
||||||
if (arg.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // bitcoin: URI
|
if (arg.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // bitcoin: URI
|
||||||
{
|
{
|
||||||
savedPaymentRequests.append(arg);
|
if (savedPaymentRequests.contains(arg)) continue;
|
||||||
|
savedPaymentRequests.insert(arg);
|
||||||
|
|
||||||
SendCoinsRecipient r;
|
SendCoinsRecipient r;
|
||||||
if (GUIUtil::parseBitcoinURI(arg, &r) && !r.address.isEmpty())
|
if (GUIUtil::parseBitcoinURI(arg, &r) && !r.address.isEmpty())
|
||||||
@ -127,7 +128,8 @@ void PaymentServer::ipcParseCommandLine(interfaces::Node& node, int argc, char*
|
|||||||
#ifdef ENABLE_BIP70
|
#ifdef ENABLE_BIP70
|
||||||
else if (QFile::exists(arg)) // Filename
|
else if (QFile::exists(arg)) // Filename
|
||||||
{
|
{
|
||||||
savedPaymentRequests.append(arg);
|
if (savedPaymentRequests.contains(arg)) continue;
|
||||||
|
savedPaymentRequests.insert(arg);
|
||||||
|
|
||||||
PaymentRequestPlus request;
|
PaymentRequestPlus request;
|
||||||
if (readPaymentRequestFromFile(arg, request))
|
if (readPaymentRequestFromFile(arg, request))
|
||||||
@ -280,7 +282,7 @@ void PaymentServer::handleURIOrFile(const QString& s)
|
|||||||
{
|
{
|
||||||
if (saveURIs)
|
if (saveURIs)
|
||||||
{
|
{
|
||||||
savedPaymentRequests.append(s);
|
savedPaymentRequests.insert(s);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user