MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / handleURIOrFile

Method handleURIOrFile

src/qt/paymentserver.cpp:390–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388}
389
390void PaymentServer::handleURIOrFile(const QString& s)
391{
392 if (saveURIs)
393 {
394 savedPaymentRequests.append(s);
395 return;
396 }
397
398 if (s.startsWith("bitcoingold://", Qt::CaseInsensitive))
399 {
400 Q_EMIT message(tr("URI handling"), tr("'bitcoin://' is not a valid URI. Use 'bitcoin:' instead."),
401 CClientUIInterface::MSG_ERROR);
402 }
403 else if (s.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // bitcoin: URI
404 {
405 QUrlQuery uri((QUrl(s)));
406 if (uri.hasQueryItem("r")) // payment request URI
407 {
408 QByteArray temp;
409 temp.append(uri.queryItemValue("r"));
410 QString decoded = QUrl::fromPercentEncoding(temp);
411 QUrl fetchUrl(decoded, QUrl::StrictMode);
412
413 if (fetchUrl.isValid())
414 {
415 qDebug() << "PaymentServer::handleURIOrFile: fetchRequest(" << fetchUrl << ")";
416 fetchRequest(fetchUrl);
417 }
418 else
419 {
420 qWarning() << "PaymentServer::handleURIOrFile: Invalid URL: " << fetchUrl;
421 Q_EMIT message(tr("URI handling"),
422 tr("Payment request fetch URL is invalid: %1").arg(fetchUrl.toString()),
423 CClientUIInterface::ICON_WARNING);
424 }
425
426 return;
427 }
428 else // normal URI
429 {
430 SendCoinsRecipient recipient;
431 if (GUIUtil::parseBitcoinURI(s, &recipient))
432 {
433 if (!IsValidDestinationString(recipient.address.toStdString())) {
434 Q_EMIT message(tr("URI handling"), tr("Invalid payment address %1").arg(recipient.address),
435 CClientUIInterface::MSG_ERROR);
436 }
437 else
438 Q_EMIT receivedPaymentRequest(recipient);
439 }
440 else
441 Q_EMIT message(tr("URI handling"),
442 tr("URI cannot be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."),
443 CClientUIInterface::ICON_WARNING);
444
445 return;
446 }
447 }

Callers

nothing calls this directly

Calls 4

parseBitcoinURIFunction · 0.85
IsValidDestinationStringFunction · 0.85
QUrlClass · 0.70
isValidMethod · 0.45

Tested by

no test coverage detected