diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-11-06 19:12:47 +0100 |
---|---|---|
committer | James Hilliard <james.hilliard1@gmail.com> | 2018-10-09 03:36:14 -0600 |
commit | 9dcf6c0dfec51f2a49edef537f377422d6dbdceb (patch) | |
tree | 68628f5648acc166e1bdbd5f3cfbe0cec5caa8d1 /src/qt/paymentserver.cpp | |
parent | 1d1417430c829a0c21bf5a2fe4a5b2f592a9423f (diff) |
build: Add --disable-bip70 configure option
This patch adds a --disable-bip70 configure option that disables BIP70
payment request support. When disabled, this removes the dependency of
the GUI on OpenSSL and Protobuf.
Diffstat (limited to 'src/qt/paymentserver.cpp')
-rw-r--r-- | src/qt/paymentserver.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index bcafc8f859..760728f85b 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -2,6 +2,10 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#if defined(HAVE_CONFIG_H) +#include <config/bitcoin-config.h> +#endif + #include <qt/paymentserver.h> #include <qt/bitcoinunits.h> @@ -45,6 +49,7 @@ const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds const QString BITCOIN_IPC_PREFIX("bitcoin:"); +#ifdef ENABLE_BIP70 // BIP70 payment protocol messages const char* BIP70_MESSAGE_PAYMENTACK = "PaymentACK"; const char* BIP70_MESSAGE_PAYMENTREQUEST = "PaymentRequest"; @@ -67,6 +72,7 @@ namespace // Anon namespace { std::unique_ptr<X509_STORE, X509StoreDeleter> certStore; } +#endif // // Create a name that is unique for: @@ -93,6 +99,7 @@ static QString ipcServerName() static QList<QString> savedPaymentRequests; +#ifdef ENABLE_BIP70 static void ReportInvalidCertificate(const QSslCertificate& cert) { qDebug() << QString("%1: Payment server found an invalid certificate: ").arg(__func__) << cert.serialNumber() << cert.subjectInfo(QSslCertificate::CommonName) << cert.subjectInfo(QSslCertificate::DistinguishedNameQualifier) << cert.subjectInfo(QSslCertificate::OrganizationalUnitName); @@ -180,6 +187,7 @@ void PaymentServer::LoadRootCAs(X509_STORE* _store) // or use Qt's blacklist? // "certificate stapling" with server-side caching is more efficient } +#endif // // Sending to the server is done synchronously, at startup. @@ -221,6 +229,7 @@ void PaymentServer::ipcParseCommandLine(interfaces::Node& node, int argc, char* } } } +#ifdef ENABLE_BIP70 else if (QFile::exists(arg)) // Filename { savedPaymentRequests.append(arg); @@ -244,6 +253,7 @@ void PaymentServer::ipcParseCommandLine(interfaces::Node& node, int argc, char* // GUI hasn't started yet so we can't pop up a message box. qWarning() << "PaymentServer::ipcSendCommandLine: Payment request file does not exist: " << arg; } +#endif } } @@ -290,12 +300,16 @@ PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) : QObject(parent), saveURIs(true), uriServer(0), +#ifdef ENABLE_BIP70 netManager(0), +#endif optionsModel(0) { +#ifdef ENABLE_BIP70 // Verify that the version of the library that we linked against is // compatible with the version of the headers we compiled against. GOOGLE_PROTOBUF_VERIFY_VERSION; +#endif // Install global event filter to catch QFileOpenEvents // on Mac: sent when you click bitcoin: links @@ -319,14 +333,18 @@ PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) : } else { connect(uriServer, &QLocalServer::newConnection, this, &PaymentServer::handleURIConnection); +#ifdef ENABLE_BIP70 connect(this, &PaymentServer::receivedPaymentACK, this, &PaymentServer::handlePaymentACK); +#endif } } } PaymentServer::~PaymentServer() { +#ifdef ENABLE_BIP70 google::protobuf::ShutdownProtobufLibrary(); +#endif } // @@ -349,6 +367,7 @@ bool PaymentServer::eventFilter(QObject *object, QEvent *event) return QObject::eventFilter(object, event); } +#ifdef ENABLE_BIP70 void PaymentServer::initNetManager() { if (!optionsModel) @@ -372,10 +391,13 @@ void PaymentServer::initNetManager() connect(netManager, &QNetworkAccessManager::finished, this, &PaymentServer::netRequestFinished); connect(netManager, &QNetworkAccessManager::sslErrors, this, &PaymentServer::reportSslErrors); } +#endif void PaymentServer::uiReady() { +#ifdef ENABLE_BIP70 initNetManager(); +#endif saveURIs = false; for (const QString& s : savedPaymentRequests) @@ -403,6 +425,7 @@ void PaymentServer::handleURIOrFile(const QString& s) QUrlQuery uri((QUrl(s))); if (uri.hasQueryItem("r")) // payment request URI { +#ifdef ENABLE_BIP70 QByteArray temp; temp.append(uri.queryItemValue("r")); QString decoded = QUrl::fromPercentEncoding(temp); @@ -420,7 +443,11 @@ void PaymentServer::handleURIOrFile(const QString& s) tr("Payment request fetch URL is invalid: %1").arg(fetchUrl.toString()), CClientUIInterface::ICON_WARNING); } - +#else + Q_EMIT message(tr("URI handling"), + tr("Cannot process payment request because BIP70 support was not compiled in."), + CClientUIInterface::ICON_WARNING); +#endif return; } else // normal URI @@ -444,6 +471,7 @@ void PaymentServer::handleURIOrFile(const QString& s) } } +#ifdef ENABLE_BIP70 if (QFile::exists(s)) // payment request file { PaymentRequestPlus request; @@ -459,6 +487,7 @@ void PaymentServer::handleURIOrFile(const QString& s) return; } +#endif } void PaymentServer::handleURIConnection() @@ -481,6 +510,7 @@ void PaymentServer::handleURIConnection() handleURIOrFile(msg); } +#ifdef ENABLE_BIP70 // // Warning: readPaymentRequestFromFile() is used in ipcSendCommandLine() // so don't use "Q_EMIT message()", but "QMessageBox::"! @@ -730,12 +760,14 @@ void PaymentServer::reportSslErrors(QNetworkReply* reply, const QList<QSslError> } Q_EMIT message(tr("Network request error"), errString, CClientUIInterface::MSG_ERROR); } +#endif void PaymentServer::setOptionsModel(OptionsModel *_optionsModel) { this->optionsModel = _optionsModel; } +#ifdef ENABLE_BIP70 void PaymentServer::handlePaymentACK(const QString& paymentACKMsg) { // currently we don't further process or store the paymentACK message @@ -794,3 +826,4 @@ X509_STORE* PaymentServer::getCertStore() { return certStore.get(); } +#endif |