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

Method handleURIOrFile

src/qt/paymentserver.cpp:403–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

401}
402
403void PaymentServer::handleURIOrFile(const QString& s)
404{
405 if (saveURIs)
406 {
407 savedPaymentRequests.append(s);
408 return;
409 }
410
411 if (s.startsWith(GUIUtil::uriPrefix(), Qt::CaseInsensitive)) // bitcoin: URI
412 {
413#if QT_VERSION < 0x050000
414 QUrl uri(s);
415#else
416 QUrlQuery uri((QUrl(s)));
417#endif
418 if (uri.hasQueryItem("r")) // payment request URI
419 {
420 QByteArray temp;
421 temp.append(uri.queryItemValue("r"));
422 QString decoded = QUrl::fromPercentEncoding(temp);
423 QUrl fetchUrl(decoded, QUrl::StrictMode);
424
425 if (fetchUrl.isValid())
426 {
427 qDebug() << "PaymentServer::handleURIOrFile: fetchRequest(" << fetchUrl << ")";
428 fetchRequest(fetchUrl);
429 }
430 else
431 {
432 qWarning() << "PaymentServer::handleURIOrFile: Invalid URL: " << fetchUrl;
433 Q_EMIT message(tr("URI handling"),
434 tr("Payment request fetch URL is invalid: %1").arg(fetchUrl.toString()),
435 CClientUIInterface::ICON_WARNING);
436 }
437
438 return;
439 }
440 else // normal URI
441 {
442 SendCoinsRecipient recipient;
443 if (GUIUtil::parseBitcoinURI(s, &recipient))
444 {
445 CBitcoinAddress address(recipient.address.toStdString());
446 if (!address.IsValid()) {
447 Q_EMIT message(tr("URI handling"), tr("Invalid payment address %1").arg(recipient.address),
448 CClientUIInterface::MSG_ERROR);
449 }
450 else
451 Q_EMIT receivedPaymentRequest(recipient);
452 }
453 else
454 Q_EMIT message(tr("URI handling"),
455 tr("URI cannot be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."),
456 CClientUIInterface::ICON_WARNING);
457
458 return;
459 }
460 }

Callers

nothing calls this directly

Calls 5

uriPrefixFunction · 0.85
parseBitcoinURIFunction · 0.85
isValidMethod · 0.80
QUrlClass · 0.70
IsValidMethod · 0.45

Tested by

no test coverage detected