|
|
@ -89,7 +89,7 @@ static QList<QString> savedPaymentRequests; |
|
|
|
static void ReportInvalidCertificate(const QSslCertificate& cert) |
|
|
|
static void ReportInvalidCertificate(const QSslCertificate& cert) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (fDebug) { |
|
|
|
if (fDebug) { |
|
|
|
qDebug() << "Invalid certificate: " << cert.subjectInfo(QSslCertificate::CommonName); |
|
|
|
qDebug() << "ReportInvalidCertificate : Payment server found an invalid certificate: " << cert.subjectInfo(QSslCertificate::CommonName); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -162,7 +162,7 @@ void PaymentServer::LoadRootCAs(X509_STORE* _store) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (fDebug) |
|
|
|
if (fDebug) |
|
|
|
qDebug() << "PaymentServer: loaded " << nRootCerts << " root certificates"; |
|
|
|
qDebug() << "PaymentServer::LoadRootCAs : Loaded " << nRootCerts << " root certificates"; |
|
|
|
|
|
|
|
|
|
|
|
// Project for another day:
|
|
|
|
// Project for another day:
|
|
|
|
// Fetch certificate revocation lists, and add them to certStore.
|
|
|
|
// Fetch certificate revocation lists, and add them to certStore.
|
|
|
@ -221,7 +221,7 @@ bool PaymentServer::ipcSendCommandLine(int argc, char* argv[]) |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
qDebug() << "Payment request file does not exist: " << argv[i]; |
|
|
|
qDebug() << "PaymentServer::ipcSendCommandLine : Payment request file does not exist: " << argv[i]; |
|
|
|
// Printing to debug.log is about the best we can do here, the
|
|
|
|
// Printing to debug.log is about the best we can do here, the
|
|
|
|
// GUI hasn't started yet so we can't pop up a message box.
|
|
|
|
// GUI hasn't started yet so we can't pop up a message box.
|
|
|
|
} |
|
|
|
} |
|
|
@ -271,7 +271,7 @@ PaymentServer::PaymentServer(QObject* parent, |
|
|
|
uriServer = new QLocalServer(this); |
|
|
|
uriServer = new QLocalServer(this); |
|
|
|
|
|
|
|
|
|
|
|
if (!uriServer->listen(name)) |
|
|
|
if (!uriServer->listen(name)) |
|
|
|
qDebug() << "Cannot start bitcoin: click-to-pay handler"; |
|
|
|
qDebug() << "PaymentServer::PaymentServer : Cannot start bitcoin: click-to-pay handler"; |
|
|
|
else |
|
|
|
else |
|
|
|
connect(uriServer, SIGNAL(newConnection()), this, SLOT(handleURIConnection())); |
|
|
|
connect(uriServer, SIGNAL(newConnection()), this, SLOT(handleURIConnection())); |
|
|
|
} |
|
|
|
} |
|
|
@ -366,12 +366,13 @@ void PaymentServer::handleURIOrFile(const QString& s) |
|
|
|
QString decoded = QUrl::fromPercentEncoding(temp); |
|
|
|
QString decoded = QUrl::fromPercentEncoding(temp); |
|
|
|
QUrl fetchUrl(decoded, QUrl::StrictMode); |
|
|
|
QUrl fetchUrl(decoded, QUrl::StrictMode); |
|
|
|
|
|
|
|
|
|
|
|
if (fDebug) qDebug() << "PaymentServer::fetchRequest " << fetchUrl; |
|
|
|
if (fDebug) |
|
|
|
|
|
|
|
qDebug() << "PaymentServer::handleURIOrFile : fetchRequest(" << fetchUrl << ")"; |
|
|
|
|
|
|
|
|
|
|
|
if (fetchUrl.isValid()) |
|
|
|
if (fetchUrl.isValid()) |
|
|
|
fetchRequest(fetchUrl); |
|
|
|
fetchRequest(fetchUrl); |
|
|
|
else |
|
|
|
else |
|
|
|
qDebug() << "PaymentServer: invalid url: " << fetchUrl; |
|
|
|
qDebug() << "PaymentServer::handleURIOrFile : Invalid url: " << fetchUrl; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -420,13 +421,13 @@ bool PaymentServer::readPaymentRequest(const QString& filename, PaymentRequestPl |
|
|
|
QFile f(filename); |
|
|
|
QFile f(filename); |
|
|
|
if (!f.open(QIODevice::ReadOnly)) |
|
|
|
if (!f.open(QIODevice::ReadOnly)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qDebug() << "PaymentServer::readPaymentRequest fail to open " << filename; |
|
|
|
qDebug() << "PaymentServer::readPaymentRequest : Failed to open " << filename; |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (f.size() > MAX_PAYMENT_REQUEST_SIZE) |
|
|
|
if (f.size() > MAX_PAYMENT_REQUEST_SIZE) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qDebug() << "PaymentServer::readPaymentRequest " << filename << " too large"; |
|
|
|
qDebug() << "PaymentServer::readPaymentRequest : " << filename << " too large"; |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -449,7 +450,8 @@ PaymentServer::processPaymentRequest(PaymentRequestPlus& request, |
|
|
|
if (txOut.IsDust(CTransaction::nMinRelayTxFee)) { |
|
|
|
if (txOut.IsDust(CTransaction::nMinRelayTxFee)) { |
|
|
|
QString message = QObject::tr("Requested payment amount (%1) too small") |
|
|
|
QString message = QObject::tr("Requested payment amount (%1) too small") |
|
|
|
.arg(BitcoinUnits::formatWithUnit(optionsModel->getDisplayUnit(), sendingTo.second)); |
|
|
|
.arg(BitcoinUnits::formatWithUnit(optionsModel->getDisplayUnit(), sendingTo.second)); |
|
|
|
qDebug() << message; |
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "PaymentServer::processPaymentRequest : " << message; |
|
|
|
emit reportError(tr("Payment request error"), message, CClientUIInterface::MODAL); |
|
|
|
emit reportError(tr("Payment request error"), message, CClientUIInterface::MODAL); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -462,7 +464,8 @@ PaymentServer::processPaymentRequest(PaymentRequestPlus& request, |
|
|
|
if (request.getMerchant(PaymentServer::certStore, recipients[0].authenticatedMerchant)) { |
|
|
|
if (request.getMerchant(PaymentServer::certStore, recipients[0].authenticatedMerchant)) { |
|
|
|
recipients[0].paymentRequest = request; |
|
|
|
recipients[0].paymentRequest = request; |
|
|
|
recipients[0].amount = totalAmount; |
|
|
|
recipients[0].amount = totalAmount; |
|
|
|
if (fDebug) qDebug() << "PaymentRequest from " << recipients[0].authenticatedMerchant; |
|
|
|
if (fDebug) |
|
|
|
|
|
|
|
qDebug() << "PaymentServer::processPaymentRequest : Payment request from " << recipients[0].authenticatedMerchant; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
recipients.clear(); |
|
|
|
recipients.clear(); |
|
|
@ -483,7 +486,8 @@ PaymentServer::processPaymentRequest(PaymentRequestPlus& request, |
|
|
|
if (i == 0) // Tie request to first pay-to, we don't want multiple ACKs
|
|
|
|
if (i == 0) // Tie request to first pay-to, we don't want multiple ACKs
|
|
|
|
recipients[i].paymentRequest = request; |
|
|
|
recipients[i].paymentRequest = request; |
|
|
|
recipients[i].address = QString::fromStdString(CBitcoinAddress(dest).ToString()); |
|
|
|
recipients[i].address = QString::fromStdString(CBitcoinAddress(dest).ToString()); |
|
|
|
if (fDebug) qDebug() << "PaymentRequest, insecure " << recipients[i].address; |
|
|
|
if (fDebug) |
|
|
|
|
|
|
|
qDebug() << "PaymentServer::processPaymentRequest : Payment request, insecure " << recipients[i].address; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
// Insecure payments to custom bitcoin addresses are not supported
|
|
|
|
// Insecure payments to custom bitcoin addresses are not supported
|
|
|
@ -551,7 +555,7 @@ PaymentServer::fetchPaymentACK(CWallet* wallet, SendCoinsRecipient recipient, QB |
|
|
|
else { |
|
|
|
else { |
|
|
|
// This should never happen, because sending coins should have just unlocked the wallet
|
|
|
|
// This should never happen, because sending coins should have just unlocked the wallet
|
|
|
|
// and refilled the keypool
|
|
|
|
// and refilled the keypool
|
|
|
|
qDebug() << "Error getting refund key, refund_to not set"; |
|
|
|
qDebug() << "PaymentServer::fetchPaymentACK : Error getting refund key, refund_to not set"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -563,7 +567,7 @@ PaymentServer::fetchPaymentACK(CWallet* wallet, SendCoinsRecipient recipient, QB |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
// This should never happen, either:
|
|
|
|
// This should never happen, either:
|
|
|
|
qDebug() << "Error serializing payment message"; |
|
|
|
qDebug() << "PaymentServer::fetchPaymentACK : Error serializing payment message"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -576,7 +580,7 @@ PaymentServer::netRequestFinished(QNetworkReply* reply) |
|
|
|
QString message = QObject::tr("Error communicating with %1: %2") |
|
|
|
QString message = QObject::tr("Error communicating with %1: %2") |
|
|
|
.arg(reply->request().url().toString()) |
|
|
|
.arg(reply->request().url().toString()) |
|
|
|
.arg(reply->errorString()); |
|
|
|
.arg(reply->errorString()); |
|
|
|
qDebug() << message; |
|
|
|
qDebug() << "PaymentServer::netRequestFinished : " << message; |
|
|
|
emit reportError(tr("Network request error"), message, CClientUIInterface::MODAL); |
|
|
|
emit reportError(tr("Network request error"), message, CClientUIInterface::MODAL); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -594,7 +598,7 @@ PaymentServer::netRequestFinished(QNetworkReply* reply) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
qDebug() << "PaymentServer::netRequestFinished: error processing PaymentRequest"; |
|
|
|
qDebug() << "PaymentServer::netRequestFinished : Error processing payment request"; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (requestType == "PaymentACK") |
|
|
|
else if (requestType == "PaymentACK") |
|
|
@ -604,7 +608,7 @@ PaymentServer::netRequestFinished(QNetworkReply* reply) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString message = QObject::tr("Bad response from server %1") |
|
|
|
QString message = QObject::tr("Bad response from server %1") |
|
|
|
.arg(reply->request().url().toString()); |
|
|
|
.arg(reply->request().url().toString()); |
|
|
|
qDebug() << message; |
|
|
|
qDebug() << "PaymentServer::netRequestFinished : " << message; |
|
|
|
emit reportError(tr("Network request error"), message, CClientUIInterface::MODAL); |
|
|
|
emit reportError(tr("Network request error"), message, CClientUIInterface::MODAL); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
@ -618,7 +622,7 @@ PaymentServer::reportSslErrors(QNetworkReply* reply, const QList<QSslError> &err |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString errString; |
|
|
|
QString errString; |
|
|
|
foreach (const QSslError& err, errs) { |
|
|
|
foreach (const QSslError& err, errs) { |
|
|
|
qDebug() << err; |
|
|
|
qDebug() << "PaymentServer::reportSslErrors : " << err; |
|
|
|
errString += err.errorString() + "\n"; |
|
|
|
errString += err.errorString() + "\n"; |
|
|
|
} |
|
|
|
} |
|
|
|
emit reportError(tr("Network request error"), errString, CClientUIInterface::MODAL); |
|
|
|
emit reportError(tr("Network request error"), errString, CClientUIInterface::MODAL); |
|
|
|