diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index 2278c695a..e6c19d1bb 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -298,13 +298,7 @@ bool PaymentServer::ipcSendCommandLine() return fResult; } -PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) : - QObject(parent), - saveURIs(true), - uriServer(0), - netManager(0), - optionsModel(0) -{ +void PaymentServer::initializeServer(QObject* parent, QString ipcServerName, bool startLocalServer) { // 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; @@ -315,13 +309,11 @@ PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) : if (parent) parent->installEventFilter(this); - QString name = ipcServerName(); - if (startLocalServer) { uriServer = new QLocalServer(this); - if (!uriServer->listen(name)) { + if (!uriServer->listen(ipcServerName)) { // constructor is called early in init, so don't use "Q_EMIT message()" here QMessageBox::critical(0, tr("Payment request error"), tr("Cannot start dogecoin: click-to-pay handler")); @@ -333,6 +325,27 @@ PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) : } } +PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) : + QObject(parent), + saveURIs(true), + uriServer(0), + netManager(0), + optionsModel(0) +{ + this->initializeServer(parent, ipcServerName(), startLocalServer); +} + + +PaymentServer::PaymentServer(QObject* parent, QString ipcServerName, bool startLocalServer) : + QObject(parent), + saveURIs(true), + uriServer(0), + netManager(0), + optionsModel(0) +{ + this->initializeServer(parent, ipcServerName, startLocalServer); +} + PaymentServer::~PaymentServer() { google::protobuf::ShutdownProtobufLibrary(); diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h index 7c6d4507f..b230bea81 100644 --- a/src/qt/paymentserver.h +++ b/src/qt/paymentserver.h @@ -73,6 +73,7 @@ public: // parent should be QApplication object PaymentServer(QObject* parent, bool startLocalServer = true); + PaymentServer(QObject* parent, QString ipcServerName, bool startLocalServer = true); ~PaymentServer(); // Load root certificate authorities. Pass NULL (default) @@ -138,6 +139,8 @@ private: void initNetManager(); bool saveURIs; // true during startup + + void initializeServer(QObject* parent, QString ipcServerName, bool startLocalServer); QLocalServer* uriServer; QNetworkAccessManager* netManager; // Used to fetch payment requests diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp index 484fd571e..7d2e64619 100644 --- a/src/qt/test/paymentservertests.cpp +++ b/src/qt/test/paymentservertests.cpp @@ -67,7 +67,7 @@ void PaymentServerTests::paymentServerTests() { SelectParams(CBaseChainParams::MAIN); OptionsModel optionsModel; - PaymentServer* server = new PaymentServer(NULL, false); + PaymentServer* server = new PaymentServer(NULL, QString("testIPCServer"), false); X509_STORE* caStore = X509_STORE_new(); X509_STORE_add_cert(caStore, parse_b64der_cert(caCert1_BASE64)); PaymentServer::LoadRootCAs(caStore);