MCPcopy Create free account
hub / github.com/LUX-Core/lux / handleURIOrFile

Method handleURIOrFile

src/qt/paymentserver.cpp:394–458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

parseBitcoinURIFunction · 0.85
DecodeDestinationFunction · 0.85
IsValidDestinationFunction · 0.85
QUrlClass · 0.70
appendMethod · 0.45
isValidMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected