From f0a83fc256023f68cc046bd096de69f16ce9d394 Mon Sep 17 00:00:00 2001 From: jtimon Date: Wed, 4 Jun 2014 15:25:58 +0200 Subject: [PATCH] Use Params().NetworkID() instead of TestNet() from the payment protocol --- src/qt/paymentserver.cpp | 14 ++++++++++++-- src/qt/paymentserver.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index 4c4558568..20551591c 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -490,6 +490,17 @@ bool PaymentServer::readPaymentRequest(const QString& filename, PaymentRequestPl return request.parse(data); } +std::string PaymentServer::mapNetworkIdToName(CChainParams::Network networkId) +{ + if (networkId == CChainParams::MAIN) + return "main"; + if (networkId == CChainParams::TESTNET) + return "test"; + if (networkId == CChainParams::REGTEST) + return "regtest"; + return ""; +} + bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient) { if (!optionsModel) @@ -499,8 +510,7 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoins const payments::PaymentDetails& details = request.getDetails(); // Payment request network matches client network? - if ((details.network() == "main" && TestNet()) || - (details.network() == "test" && !TestNet())) + if (details.network() != mapNetworkIdToName(Params().NetworkID())) { emit message(tr("Payment request rejected"), tr("Payment request network doesn't match client network."), CClientUIInterface::MSG_ERROR); diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h index d84d09c57..d6949a47c 100644 --- a/src/qt/paymentserver.h +++ b/src/qt/paymentserver.h @@ -118,6 +118,7 @@ protected: private: static bool readPaymentRequest(const QString& filename, PaymentRequestPlus& request); + std::string mapNetworkIdToName(CChainParams::Network networkId); bool processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient); void fetchRequest(const QUrl& url);