| 401 | } |
| 402 | |
| 403 | void 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 | } |
nothing calls this directly
no test coverage detected