|
|
@ -44,8 +44,6 @@ |
|
|
|
#include "wallet.h" |
|
|
|
#include "wallet.h" |
|
|
|
#include "walletmodel.h" |
|
|
|
#include "walletmodel.h" |
|
|
|
|
|
|
|
|
|
|
|
using namespace boost; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds
|
|
|
|
const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds
|
|
|
|
const QString BITCOIN_IPC_PREFIX("bitcoin:"); |
|
|
|
const QString BITCOIN_IPC_PREFIX("bitcoin:"); |
|
|
|
const char* BITCOIN_REQUEST_MIMETYPE = "application/bitcoin-paymentrequest"; |
|
|
|
const char* BITCOIN_REQUEST_MIMETYPE = "application/bitcoin-paymentrequest"; |
|
|
@ -73,14 +71,14 @@ static QString ipcServerName() |
|
|
|
// Append a simple hash of the datadir
|
|
|
|
// Append a simple hash of the datadir
|
|
|
|
// Note that GetDataDir(true) returns a different path
|
|
|
|
// Note that GetDataDir(true) returns a different path
|
|
|
|
// for -testnet versus main net
|
|
|
|
// for -testnet versus main net
|
|
|
|
QString ddir(GetDataDir(true).string().c_str()); |
|
|
|
QString ddir(QString::fromStdString(GetDataDir(true).string())); |
|
|
|
name.append(QString::number(qHash(ddir))); |
|
|
|
name.append(QString::number(qHash(ddir))); |
|
|
|
|
|
|
|
|
|
|
|
return name; |
|
|
|
return name; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// We store payment URLs and requests received before
|
|
|
|
// We store payment URIs and requests received before
|
|
|
|
// the main GUI window is up and ready to ask the user
|
|
|
|
// the main GUI window is up and ready to ask the user
|
|
|
|
// to send payment.
|
|
|
|
// to send payment.
|
|
|
|
|
|
|
|
|
|
|
@ -250,8 +248,7 @@ bool PaymentServer::ipcSendCommandLine(int argc, char* argv[]) |
|
|
|
return fResult; |
|
|
|
return fResult; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PaymentServer::PaymentServer(QObject* parent, |
|
|
|
PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) : QObject(parent), saveURIs(true) |
|
|
|
bool startLocalServer) : QObject(parent), saveURIs(true) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// Verify that the version of the library that we linked against is
|
|
|
|
// Verify that the version of the library that we linked against is
|
|
|
|
// compatible with the version of the headers we compiled against.
|
|
|
|
// compatible with the version of the headers we compiled against.
|
|
|
@ -286,12 +283,12 @@ PaymentServer::~PaymentServer() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// OSX-specific way of handling bitcoin uris and
|
|
|
|
// OSX-specific way of handling bitcoin: URIs and
|
|
|
|
// PaymentRequest mime types
|
|
|
|
// PaymentRequest mime types
|
|
|
|
//
|
|
|
|
//
|
|
|
|
bool PaymentServer::eventFilter(QObject *, QEvent *event) |
|
|
|
bool PaymentServer::eventFilter(QObject *, QEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// clicking on bitcoin: URLs creates FileOpen events on the Mac:
|
|
|
|
// clicking on bitcoin: URIs creates FileOpen events on the Mac:
|
|
|
|
if (event->type() == QEvent::FileOpen) |
|
|
|
if (event->type() == QEvent::FileOpen) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event); |
|
|
|
QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event); |
|
|
@ -356,13 +353,13 @@ void PaymentServer::handleURIOrFile(const QString& s) |
|
|
|
if (s.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // bitcoin:
|
|
|
|
if (s.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // bitcoin:
|
|
|
|
{ |
|
|
|
{ |
|
|
|
#if QT_VERSION >= 0x050000 |
|
|
|
#if QT_VERSION >= 0x050000 |
|
|
|
QUrlQuery url((QUrl(s))); |
|
|
|
QUrlQuery uri((QUrl(s))); |
|
|
|
#else |
|
|
|
#else |
|
|
|
QUrl url(s); |
|
|
|
QUrl uri(s); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
if (url.hasQueryItem("request")) |
|
|
|
if (uri.hasQueryItem("request")) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QByteArray temp; temp.append(url.queryItemValue("request")); |
|
|
|
QByteArray temp; temp.append(uri.queryItemValue("request")); |
|
|
|
QString decoded = QUrl::fromPercentEncoding(temp); |
|
|
|
QString decoded = QUrl::fromPercentEncoding(temp); |
|
|
|
QUrl fetchUrl(decoded, QUrl::StrictMode); |
|
|
|
QUrl fetchUrl(decoded, QUrl::StrictMode); |
|
|
|
|
|
|
|
|
|
|
@ -436,9 +433,7 @@ bool PaymentServer::readPaymentRequest(const QString& filename, PaymentRequestPl |
|
|
|
return request.parse(data); |
|
|
|
return request.parse(data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool |
|
|
|
bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList<SendCoinsRecipient>& recipients) |
|
|
|
PaymentServer::processPaymentRequest(PaymentRequestPlus& request, |
|
|
|
|
|
|
|
QList<SendCoinsRecipient>& recipients) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!optionsModel) |
|
|
|
if (!optionsModel) |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -493,7 +488,7 @@ PaymentServer::processPaymentRequest(PaymentRequestPlus& request, |
|
|
|
// Insecure payments to custom bitcoin addresses are not supported
|
|
|
|
// Insecure payments to custom bitcoin addresses are not supported
|
|
|
|
// (there is no good way to tell the user where they are paying in a way
|
|
|
|
// (there is no good way to tell the user where they are paying in a way
|
|
|
|
// they'd have a chance of understanding).
|
|
|
|
// they'd have a chance of understanding).
|
|
|
|
emit reportError(tr("Payment request error"), |
|
|
|
emit reportError(tr("Payment request error"), |
|
|
|
tr("Insecure requests to custom payment scripts unsupported"), |
|
|
|
tr("Insecure requests to custom payment scripts unsupported"), |
|
|
|
CClientUIInterface::MODAL); |
|
|
|
CClientUIInterface::MODAL); |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -504,8 +499,7 @@ PaymentServer::processPaymentRequest(PaymentRequestPlus& request, |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void PaymentServer::fetchRequest(const QUrl& url) |
|
|
|
PaymentServer::fetchRequest(const QUrl& url) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
QNetworkRequest netRequest; |
|
|
|
QNetworkRequest netRequest; |
|
|
|
netRequest.setAttribute(QNetworkRequest::User, "PaymentRequest"); |
|
|
|
netRequest.setAttribute(QNetworkRequest::User, "PaymentRequest"); |
|
|
@ -515,8 +509,7 @@ PaymentServer::fetchRequest(const QUrl& url) |
|
|
|
netManager->get(netRequest); |
|
|
|
netManager->get(netRequest); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void PaymentServer::fetchPaymentACK(CWallet* wallet, SendCoinsRecipient recipient, QByteArray transaction) |
|
|
|
PaymentServer::fetchPaymentACK(CWallet* wallet, SendCoinsRecipient recipient, QByteArray transaction) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
const payments::PaymentDetails& details = recipient.paymentRequest.getDetails(); |
|
|
|
const payments::PaymentDetails& details = recipient.paymentRequest.getDetails(); |
|
|
|
if (!details.has_payment_url()) |
|
|
|
if (!details.has_payment_url()) |
|
|
@ -571,8 +564,7 @@ PaymentServer::fetchPaymentACK(CWallet* wallet, SendCoinsRecipient recipient, QB |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void PaymentServer::netRequestFinished(QNetworkReply* reply) |
|
|
|
PaymentServer::netRequestFinished(QNetworkReply* reply) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
reply->deleteLater(); |
|
|
|
reply->deleteLater(); |
|
|
|
if (reply->error() != QNetworkReply::NoError) |
|
|
|
if (reply->error() != QNetworkReply::NoError) |
|
|
@ -617,9 +609,10 @@ PaymentServer::netRequestFinished(QNetworkReply* reply) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void PaymentServer::reportSslErrors(QNetworkReply* reply, const QList<QSslError> &errs) |
|
|
|
PaymentServer::reportSslErrors(QNetworkReply* reply, const QList<QSslError> &errs) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
Q_UNUSED(reply); |
|
|
|
|
|
|
|
|
|
|
|
QString errString; |
|
|
|
QString errString; |
|
|
|
foreach (const QSslError& err, errs) { |
|
|
|
foreach (const QSslError& err, errs) { |
|
|
|
qDebug() << "PaymentServer::reportSslErrors : " << err; |
|
|
|
qDebug() << "PaymentServer::reportSslErrors : " << err; |
|
|
|