aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-06-16 17:30:53 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-06-16 17:41:27 +0200
commit807691ca96a1a4b0655f6ea80b721b940dd29a39 (patch)
tree66a7583a17c11ea84a6e1a2f08356907d4e5cfb1 /src
parentf73082db87b9e07ddcd4656f4fc309c4d2854285 (diff)
parentf5ae6c98260fdd3c0ca203ce67c6467d9cdaea95 (diff)
Merge pull request #4326
f5ae6c9 add NetworkIDString() to chainparams (Philip Kaufmann)
Diffstat (limited to 'src')
-rw-r--r--src/chainparams.cpp3
-rw-r--r--src/chainparams.h3
-rw-r--r--src/qt/clientmodel.cpp8
-rw-r--r--src/qt/clientmodel.h2
-rw-r--r--src/qt/paymentserver.cpp13
-rw-r--r--src/qt/paymentserver.h1
-rw-r--r--src/qt/rpcconsole.cpp2
-rw-r--r--src/rpcblockchain.cpp15
8 files changed, 14 insertions, 33 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 1749dd6ff9..47136eeeea 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -99,6 +99,7 @@ class CMainParams : public CChainParams {
public:
CMainParams() {
networkID = CChainParams::MAIN;
+ strNetworkID = "main";
// The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ASCII, not valid as UTF-8, and produce
// a large 4-byte int at any alignment.
@@ -189,6 +190,7 @@ class CTestNetParams : public CMainParams {
public:
CTestNetParams() {
networkID = CChainParams::TESTNET;
+ strNetworkID = "test";
// The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ASCII, not valid as UTF-8, and produce
// a large 4-byte int at any alignment.
@@ -240,6 +242,7 @@ class CRegTestParams : public CTestNetParams {
public:
CRegTestParams() {
networkID = CChainParams::REGTEST;
+ strNetworkID = "regtest";
pchMessageStart[0] = 0xfa;
pchMessageStart[1] = 0xbf;
pchMessageStart[2] = 0xb5;
diff --git a/src/chainparams.h b/src/chainparams.h
index 8370cc5690..6e09a2cba3 100644
--- a/src/chainparams.h
+++ b/src/chainparams.h
@@ -79,6 +79,8 @@ public:
* until nGenProcLimit blocks are generated */
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
Network NetworkID() const { return networkID; }
+ /* Return the BIP70 network string (main, test or regtest) */
+ std::string NetworkIDString() const { return strNetworkID; }
const vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
const vector<CAddress>& FixedSeeds() const { return vFixedSeeds; }
@@ -102,6 +104,7 @@ protected:
vector<CDNSSeedData> vSeeds;
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
Network networkID;
+ std::string strNetworkID;
CBlock genesis;
vector<CAddress> vFixedSeeds;
bool fRequireRPCPassword;
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index 403b03378f..9c9565be67 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -142,14 +142,6 @@ void ClientModel::updateAlert(const QString &hash, int status)
emit alertsChanged(getStatusBarWarnings());
}
-QString ClientModel::getNetworkName() const
-{
- QString netname(QString::fromStdString(Params().DataDir()));
- if(netname.isEmpty())
- netname = "main";
- return netname;
-}
-
bool ClientModel::inInitialBlockDownload() const
{
return IsInitialBlockDownload();
diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h
index 9c9a35b654..c7bd60bd41 100644
--- a/src/qt/clientmodel.h
+++ b/src/qt/clientmodel.h
@@ -56,8 +56,6 @@ public:
double getVerificationProgress() const;
QDateTime getLastBlockDate() const;
- //! Return network (main, testnet3, regtest)
- QString getNetworkName() const;
//! Return true if core is doing initial block download
bool inInitialBlockDownload() const;
//! Return true if core is importing blocks
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp
index 9241f9dc3c..eb6ab879aa 100644
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -490,17 +490,6 @@ 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)
@@ -510,7 +499,7 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoins
const payments::PaymentDetails& details = request.getDetails();
// Payment request network matches client network?
- if (details.network() != mapNetworkIdToName(Params().NetworkID()))
+ if (details.network() != Params().NetworkIDString())
{
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 d6949a47ce..d84d09c57d 100644
--- a/src/qt/paymentserver.h
+++ b/src/qt/paymentserver.h
@@ -118,7 +118,6 @@ 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);
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 199050cc57..f7491f4a42 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -316,7 +316,7 @@ void RPCConsole::setClientModel(ClientModel *model)
ui->buildDate->setText(model->formatBuildDate());
ui->startupTime->setText(model->formatClientStartupTime());
- ui->networkName->setText(model->getNetworkName());
+ ui->networkName->setText(QString::fromStdString(Params().NetworkIDString()));
}
}
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index 2a21fb462a..0fabc86872 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -451,14 +451,11 @@ Value getblockchaininfo(const Array& params, bool fHelp)
);
Object obj;
- std::string chain = Params().DataDir();
- if(chain.empty())
- chain = "main";
- obj.push_back(Pair("chain", chain));
- obj.push_back(Pair("blocks", (int)chainActive.Height()));
- obj.push_back(Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()));
- obj.push_back(Pair("difficulty", (double)GetDifficulty()));
- obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(chainActive.Tip())));
- obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex()));
+ obj.push_back(Pair("chain", Params().NetworkIDString()));
+ obj.push_back(Pair("blocks", (int)chainActive.Height()));
+ obj.push_back(Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()));
+ obj.push_back(Pair("difficulty", (double)GetDifficulty()));
+ obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(chainActive.Tip())));
+ obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex()));
return obj;
}