aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.qt.include2
-rw-r--r--src/chainparams.cpp75
-rw-r--r--src/chainparams.h6
-rw-r--r--src/checkpoints.cpp81
-rw-r--r--src/checkpoints.h12
-rw-r--r--src/qt/bitcoin.cpp25
-rw-r--r--src/qt/bitcoingui.cpp57
-rw-r--r--src/qt/bitcoingui.h7
-rw-r--r--src/qt/networkstyle.cpp47
-rw-r--r--src/qt/networkstyle.h33
-rw-r--r--src/qt/splashscreen.cpp25
-rw-r--r--src/qt/splashscreen.h4
-rw-r--r--src/rpcmining.cpp2
-rw-r--r--src/rpcmisc.cpp2
14 files changed, 222 insertions, 156 deletions
diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include
index 1ea039adb3..872a0cf1c5 100644
--- a/src/Makefile.qt.include
+++ b/src/Makefile.qt.include
@@ -178,6 +178,7 @@ BITCOIN_QT_H = \
qt/macdockiconhandler.h \
qt/macnotificationhandler.h \
qt/monitoreddatamapper.h \
+ qt/networkstyle.h \
qt/notificator.h \
qt/openuridialog.h \
qt/optionsdialog.h \
@@ -269,6 +270,7 @@ BITCOIN_QT_CPP = \
qt/guiutil.cpp \
qt/intro.cpp \
qt/monitoreddatamapper.cpp \
+ qt/networkstyle.cpp \
qt/notificator.cpp \
qt/optionsdialog.cpp \
qt/optionsmodel.cpp \
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 31c67715c8..f2a14b8293 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -44,6 +44,57 @@ static void convertSeed6(std::vector<CAddress> &vSeedsOut, const SeedSpec6 *data
}
}
+ // What makes a good checkpoint block?
+ // + Is surrounded by blocks with reasonable timestamps
+ // (no blocks before with a timestamp after, none after with
+ // timestamp before)
+ // + Contains no strange transactions
+static Checkpoints::MapCheckpoints mapCheckpoints =
+ boost::assign::map_list_of
+ ( 11111, uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"))
+ ( 33333, uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6"))
+ ( 74000, uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20"))
+ (105000, uint256("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97"))
+ (134444, uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe"))
+ (168000, uint256("0x000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763"))
+ (193000, uint256("0x000000000000059f452a5f7340de6682a977387c17010ff6e6c3bd83ca8b1317"))
+ (210000, uint256("0x000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e"))
+ (216116, uint256("0x00000000000001b4f4b433e81ee46494af945cf96014816a4e2370f11b23df4e"))
+ (225430, uint256("0x00000000000001c108384350f74090433e7fcf79a606b8e797f065b130575932"))
+ (250000, uint256("0x000000000000003887df1f29024b06fc2200b55f8af8f35453d7be294df2d214"))
+ (279000, uint256("0x0000000000000001ae8c72a0b0c301f67e3afca10e819efa9041e458e9bd7e40"))
+ (295000, uint256("0x00000000000000004d9b4ef50f0f9d686fd69db2e03af35a100370c64632a983"))
+ ;
+static const Checkpoints::CCheckpointData data = {
+ &mapCheckpoints,
+ 1397080064, // * UNIX timestamp of last checkpoint block
+ 36544669, // * total number of transactions between genesis and last checkpoint
+ // (the tx=... number in the SetBestChain debug.log lines)
+ 60000.0 // * estimated number of transactions per day after checkpoint
+ };
+
+static Checkpoints::MapCheckpoints mapCheckpointsTestnet =
+ boost::assign::map_list_of
+ ( 546, uint256("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70"))
+ ;
+static const Checkpoints::CCheckpointData dataTestnet = {
+ &mapCheckpointsTestnet,
+ 1337966069,
+ 1488,
+ 300
+ };
+
+static Checkpoints::MapCheckpoints mapCheckpointsRegtest =
+ boost::assign::map_list_of
+ ( 0, uint256("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"))
+ ;
+static const Checkpoints::CCheckpointData dataRegtest = {
+ &mapCheckpointsRegtest,
+ 0,
+ 0,
+ 0
+ };
+
class CMainParams : public CChainParams {
public:
CMainParams() {
@@ -116,6 +167,12 @@ public:
fRequireStandard = true;
fMineBlocksOnDemand = false;
fSkipProofOfWorkCheck = false;
+ fTestnetToBeDeprecatedFieldRPC = false;
+ }
+
+ const Checkpoints::CCheckpointData& Checkpoints() const
+ {
+ return data;
}
};
static CMainParams mainParams;
@@ -172,6 +229,11 @@ public:
fAllowMinDifficultyBlocks = true;
fRequireStandard = false;
fMineBlocksOnDemand = false;
+ fTestnetToBeDeprecatedFieldRPC = true;
+ }
+ const Checkpoints::CCheckpointData& Checkpoints() const
+ {
+ return dataTestnet;
}
};
static CTestNetParams testNetParams;
@@ -211,6 +273,11 @@ public:
fAllowMinDifficultyBlocks = true;
fRequireStandard = false;
fMineBlocksOnDemand = true;
+ fTestnetToBeDeprecatedFieldRPC = false;
+ }
+ const Checkpoints::CCheckpointData& Checkpoints() const
+ {
+ return dataRegtest;
}
};
static CRegTestParams regTestParams;
@@ -233,7 +300,13 @@ public:
fAllowMinDifficultyBlocks = false;
fMineBlocksOnDemand = true;
}
-public:
+
+ const Checkpoints::CCheckpointData& Checkpoints() const
+ {
+ // UnitTest share the same checkpoints as MAIN
+ return data;
+ }
+
// Published setters to allow changing values in unit test cases
virtual void setSubsidyHalvingInterval(int anSubsidyHalvingInterval) { nSubsidyHalvingInterval=anSubsidyHalvingInterval; }
virtual void setEnforceBlockUpgradeMajority(int anEnforceBlockUpgradeMajority) { nEnforceBlockUpgradeMajority=anEnforceBlockUpgradeMajority; }
diff --git a/src/chainparams.h b/src/chainparams.h
index 50441a89f3..f157419bb2 100644
--- a/src/chainparams.h
+++ b/src/chainparams.h
@@ -8,6 +8,7 @@
#include "core.h"
#include "chainparamsbase.h"
+#include "checkpoints.h"
#include "protocol.h"
#include "uint256.h"
@@ -71,12 +72,14 @@ public:
/* Make miner stop after a block is found. In RPC, don't return
* until nGenProcLimit blocks are generated */
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
- CBaseChainParams::Network NetworkID() const { return networkID; }
+ /* In the future use NetworkIDString() for RPC fields */
+ bool TestnetToBeDeprecatedFieldRPC() const { return fTestnetToBeDeprecatedFieldRPC; }
/* Return the BIP70 network string (main, test or regtest) */
std::string NetworkIDString() const { return strNetworkID; }
const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
const std::vector<CAddress>& FixedSeeds() const { return vFixedSeeds; }
+ virtual const Checkpoints::CCheckpointData& Checkpoints() const = 0;
protected:
CChainParams() {}
@@ -106,6 +109,7 @@ protected:
bool fRequireStandard;
bool fMineBlocksOnDemand;
bool fSkipProofOfWorkCheck;
+ bool fTestnetToBeDeprecatedFieldRPC;
};
/** Modifiable parameters interface is used by test cases to adapt the parameters in order
diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp
index 9a6bc05e63..fbde47339d 100644
--- a/src/checkpoints.cpp
+++ b/src/checkpoints.cpp
@@ -4,18 +4,16 @@
#include "checkpoints.h"
+#include "chainparams.h"
#include "main.h"
#include "uint256.h"
#include <stdint.h>
-#include <boost/assign/list_of.hpp> // for 'map_list_of()'
#include <boost/foreach.hpp>
namespace Checkpoints {
- typedef std::map<int, uint256> MapCheckpoints;
-
// How many times we expect transactions after the last checkpoint to
// be slower. This number is a compromise, as it can't be accurate for
// every system. When reindexing from a fast disk with a slow CPU, it
@@ -23,83 +21,14 @@ namespace Checkpoints {
// fast multicore CPU, it won't be much higher than 1.
static const double SIGCHECK_VERIFICATION_FACTOR = 5.0;
- struct CCheckpointData {
- const MapCheckpoints *mapCheckpoints;
- int64_t nTimeLastCheckpoint;
- int64_t nTransactionsLastCheckpoint;
- double fTransactionsPerDay;
- };
-
bool fEnabled = true;
- // What makes a good checkpoint block?
- // + Is surrounded by blocks with reasonable timestamps
- // (no blocks before with a timestamp after, none after with
- // timestamp before)
- // + Contains no strange transactions
- static MapCheckpoints mapCheckpoints =
- boost::assign::map_list_of
- ( 11111, uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"))
- ( 33333, uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6"))
- ( 74000, uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20"))
- (105000, uint256("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97"))
- (134444, uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe"))
- (168000, uint256("0x000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763"))
- (193000, uint256("0x000000000000059f452a5f7340de6682a977387c17010ff6e6c3bd83ca8b1317"))
- (210000, uint256("0x000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e"))
- (216116, uint256("0x00000000000001b4f4b433e81ee46494af945cf96014816a4e2370f11b23df4e"))
- (225430, uint256("0x00000000000001c108384350f74090433e7fcf79a606b8e797f065b130575932"))
- (250000, uint256("0x000000000000003887df1f29024b06fc2200b55f8af8f35453d7be294df2d214"))
- (279000, uint256("0x0000000000000001ae8c72a0b0c301f67e3afca10e819efa9041e458e9bd7e40"))
- (295000, uint256("0x00000000000000004d9b4ef50f0f9d686fd69db2e03af35a100370c64632a983"))
- ;
- static const CCheckpointData data = {
- &mapCheckpoints,
- 1397080064, // * UNIX timestamp of last checkpoint block
- 36544669, // * total number of transactions between genesis and last checkpoint
- // (the tx=... number in the SetBestChain debug.log lines)
- 60000.0 // * estimated number of transactions per day after checkpoint
- };
-
- static MapCheckpoints mapCheckpointsTestnet =
- boost::assign::map_list_of
- ( 546, uint256("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70"))
- ;
- static const CCheckpointData dataTestnet = {
- &mapCheckpointsTestnet,
- 1337966069,
- 1488,
- 300
- };
-
- static MapCheckpoints mapCheckpointsRegtest =
- boost::assign::map_list_of
- ( 0, uint256("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"))
- ;
- static const CCheckpointData dataRegtest = {
- &mapCheckpointsRegtest,
- 0,
- 0,
- 0
- };
-
- const CCheckpointData &Checkpoints() {
- if (Params().NetworkID() == CBaseChainParams::TESTNET)
- return dataTestnet;
- else if (Params().NetworkID() == CBaseChainParams::MAIN)
- return data;
- else if (Params().NetworkID() == CBaseChainParams::UNITTEST) // UnitTest share the same checkpoints as MAIN
- return data;
- else
- return dataRegtest;
- }
-
bool CheckBlock(int nHeight, const uint256& hash)
{
if (!fEnabled)
return true;
- const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints;
+ const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
MapCheckpoints::const_iterator i = checkpoints.find(nHeight);
if (i == checkpoints.end()) return true;
@@ -119,7 +48,7 @@ namespace Checkpoints {
// Work is defined as: 1.0 per transaction before the last checkpoint, and
// fSigcheckVerificationFactor per transaction after.
- const CCheckpointData &data = Checkpoints();
+ const CCheckpointData &data = Params().Checkpoints();
if (pindex->nChainTx <= data.nTransactionsLastCheckpoint) {
double nCheapBefore = pindex->nChainTx;
@@ -143,7 +72,7 @@ namespace Checkpoints {
if (!fEnabled)
return 0;
- const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints;
+ const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
return checkpoints.rbegin()->first;
}
@@ -153,7 +82,7 @@ namespace Checkpoints {
if (!fEnabled)
return NULL;
- const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints;
+ const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints)
{
diff --git a/src/checkpoints.h b/src/checkpoints.h
index fca046559a..b5b620fa6b 100644
--- a/src/checkpoints.h
+++ b/src/checkpoints.h
@@ -5,16 +5,26 @@
#ifndef BITCOIN_CHECKPOINT_H
#define BITCOIN_CHECKPOINT_H
+#include "uint256.h"
+
#include <map>
class CBlockIndex;
-class uint256;
/** Block-chain checkpoints are compiled-in sanity checks.
* They are updated every release or three.
*/
namespace Checkpoints
{
+typedef std::map<int, uint256> MapCheckpoints;
+
+struct CCheckpointData {
+ const MapCheckpoints *mapCheckpoints;
+ int64_t nTimeLastCheckpoint;
+ int64_t nTransactionsLastCheckpoint;
+ double fTransactionsPerDay;
+};
+
// Returns true if block passes checkpoint checks
bool CheckBlock(int nHeight, const uint256& hash);
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 5e2fdc6c30..9872ebc1f6 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -12,6 +12,7 @@
#include "guiconstants.h"
#include "guiutil.h"
#include "intro.h"
+#include "networkstyle.h"
#include "optionsmodel.h"
#include "splashscreen.h"
#include "utilitydialog.h"
@@ -190,9 +191,9 @@ public:
/// Create options model
void createOptionsModel();
/// Create main window
- void createWindow(bool isaTestNet);
+ void createWindow(const NetworkStyle *networkStyle);
/// Create splash screen
- void createSplashScreen(bool isaTestNet);
+ void createSplashScreen(const NetworkStyle *networkStyle);
/// Request core initialization
void requestInitialize();
@@ -331,18 +332,18 @@ void BitcoinApplication::createOptionsModel()
optionsModel = new OptionsModel();
}
-void BitcoinApplication::createWindow(bool isaTestNet)
+void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
{
- window = new BitcoinGUI(isaTestNet, 0);
+ window = new BitcoinGUI(networkStyle, 0);
pollShutdownTimer = new QTimer(window);
connect(pollShutdownTimer, SIGNAL(timeout()), window, SLOT(detectShutdown()));
pollShutdownTimer->start(200);
}
-void BitcoinApplication::createSplashScreen(bool isaTestNet)
+void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
{
- SplashScreen *splash = new SplashScreen(0, isaTestNet);
+ SplashScreen *splash = new SplashScreen(0, networkStyle);
// We don't hold a direct pointer to the splash screen after creation, so use
// Qt::WA_DeleteOnClose to make sure that the window will be deleted eventually.
splash->setAttribute(Qt::WA_DeleteOnClose);
@@ -572,12 +573,10 @@ int main(int argc, char *argv[])
if (!PaymentServer::ipcParseCommandLine(argc, argv))
exit(0);
#endif
- bool isaTestNet = Params().NetworkID() != CBaseChainParams::MAIN;
+ QScopedPointer<const NetworkStyle> networkStyle(NetworkStyle::instantiate(QString::fromStdString(Params().NetworkIDString())));
+ assert(!networkStyle.isNull());
// Allow for separate UI settings for testnets
- if (isaTestNet)
- QApplication::setApplicationName(QAPP_APP_NAME_TESTNET);
- else
- QApplication::setApplicationName(QAPP_APP_NAME_DEFAULT);
+ QApplication::setApplicationName(networkStyle->getAppName());
// Re-initialize translations after changing application name (language in network-specific settings can be different)
initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
@@ -617,11 +616,11 @@ int main(int argc, char *argv[])
uiInterface.InitMessage.connect(InitMessage);
if (GetBoolArg("-splash", true) && !GetBoolArg("-min", false))
- app.createSplashScreen(isaTestNet);
+ app.createSplashScreen(networkStyle.data());
try
{
- app.createWindow(isaTestNet);
+ app.createWindow(networkStyle.data());
app.requestInitialize();
#if defined(Q_OS_WIN) && QT_VERSION >= 0x050000
WinShutdownMonitor::registerShutdownBlockReason(QObject::tr("Bitcoin Core didn't yet exit safely..."), (HWND)app.getMainWinId());
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 7380fbd240..8a945606dc 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -8,6 +8,7 @@
#include "clientmodel.h"
#include "guiconstants.h"
#include "guiutil.h"
+#include "networkstyle.h"
#include "notificator.h"
#include "openuridialog.h"
#include "optionsdialog.h"
@@ -59,7 +60,7 @@
const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
-BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
+BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) :
QMainWindow(parent),
clientModel(0),
walletFrame(0),
@@ -112,26 +113,13 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
} else {
windowTitle += tr("Node");
}
-
- if (!fIsTestnet)
- {
+ windowTitle += " " + networkStyle->getTitleAddText();
#ifndef Q_OS_MAC
- QApplication::setWindowIcon(QIcon(":icons/bitcoin"));
- setWindowIcon(QIcon(":icons/bitcoin"));
+ QApplication::setWindowIcon(networkStyle->getAppIcon());
+ setWindowIcon(networkStyle->getAppIcon());
#else
- MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin"));
+ MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon());
#endif
- }
- else
- {
- windowTitle += " " + tr("[testnet]");
-#ifndef Q_OS_MAC
- QApplication::setWindowIcon(QIcon(":icons/bitcoin_testnet"));
- setWindowIcon(QIcon(":icons/bitcoin_testnet"));
-#else
- MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet"));
-#endif
- }
setWindowTitle(windowTitle);
#if defined(Q_OS_MAC) && QT_VERSION < 0x050000
@@ -161,7 +149,7 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
// Create actions for the toolbar, menu bar and tray/dock icon
// Needs walletFrame to be initialized
- createActions(fIsTestnet);
+ createActions(networkStyle);
// Create application menu bar
createMenuBar();
@@ -170,7 +158,7 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
createToolBars();
// Create system tray icon and notification
- createTrayIcon(fIsTestnet);
+ createTrayIcon(networkStyle);
// Create status bar
statusBar();
@@ -248,7 +236,7 @@ BitcoinGUI::~BitcoinGUI()
#endif
}
-void BitcoinGUI::createActions(bool fIsTestnet)
+void BitcoinGUI::createActions(const NetworkStyle *networkStyle)
{
QActionGroup *tabGroup = new QActionGroup(this);
@@ -295,10 +283,7 @@ void BitcoinGUI::createActions(bool fIsTestnet)
quitAction->setStatusTip(tr("Quit application"));
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
quitAction->setMenuRole(QAction::QuitRole);
- if (!fIsTestnet)
- aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About Bitcoin Core"), this);
- else
- aboutAction = new QAction(QIcon(":/icons/bitcoin_testnet"), tr("&About Bitcoin Core"), this);
+ aboutAction = new QAction(networkStyle->getAppIcon(), tr("&About Bitcoin Core"), this);
aboutAction->setStatusTip(tr("Show information about Bitcoin Core"));
aboutAction->setMenuRole(QAction::AboutRole);
#if QT_VERSION < 0x050000
@@ -311,10 +296,7 @@ void BitcoinGUI::createActions(bool fIsTestnet)
optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
optionsAction->setStatusTip(tr("Modify configuration options for Bitcoin"));
optionsAction->setMenuRole(QAction::PreferencesRole);
- if (!fIsTestnet)
- toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this);
- else
- toggleHideAction = new QAction(QIcon(":/icons/bitcoin_testnet"), tr("&Show / Hide"), this);
+ toggleHideAction = new QAction(networkStyle->getAppIcon(), tr("&Show / Hide"), this);
toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
@@ -505,22 +487,13 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
openAction->setEnabled(enabled);
}
-void BitcoinGUI::createTrayIcon(bool fIsTestnet)
+void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
{
#ifndef Q_OS_MAC
trayIcon = new QSystemTrayIcon(this);
-
- if (!fIsTestnet)
- {
- trayIcon->setToolTip(tr("Bitcoin Core client"));
- trayIcon->setIcon(QIcon(":/icons/bitcoin"));
- }
- else
- {
- trayIcon->setToolTip(tr("Bitcoin Core client") + " " + tr("[testnet]"));
- trayIcon->setIcon(QIcon(":/icons/bitcoin_testnet"));
- }
-
+ QString toolTip = tr("Bitcoin Core client") + " " + networkStyle->getTitleAddText();
+ trayIcon->setToolTip(toolTip);
+ trayIcon->setIcon(networkStyle->getAppIcon());
trayIcon->show();
#endif
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index 8af6eda867..f65f0e9137 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -19,6 +19,7 @@
#include <QSystemTrayIcon>
class ClientModel;
+class NetworkStyle;
class Notificator;
class OptionsModel;
class RPCConsole;
@@ -46,7 +47,7 @@ class BitcoinGUI : public QMainWindow
public:
static const QString DEFAULT_WALLET;
- explicit BitcoinGUI(bool fIsTestnet = false, QWidget *parent = 0);
+ explicit BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent = 0);
~BitcoinGUI();
/** Set the client model.
@@ -114,13 +115,13 @@ private:
int spinnerFrame;
/** Create the main UI actions. */
- void createActions(bool fIsTestnet);
+ void createActions(const NetworkStyle *networkStyle);
/** Create the menu bar and sub-menus. */
void createMenuBar();
/** Create the toolbars */
void createToolBars();
/** Create system tray icon and notification */
- void createTrayIcon(bool fIsTestnet);
+ void createTrayIcon(const NetworkStyle *networkStyle);
/** Create system tray menu (or setup the dock menu) */
void createTrayIconMenu();
diff --git a/src/qt/networkstyle.cpp b/src/qt/networkstyle.cpp
new file mode 100644
index 0000000000..62c44703f4
--- /dev/null
+++ b/src/qt/networkstyle.cpp
@@ -0,0 +1,47 @@
+// Copyright (c) 2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include "networkstyle.h"
+
+#include "guiconstants.h"
+
+#include <QApplication>
+
+static const struct {
+ const char *networkId;
+ const char *appName;
+ const char *appIcon;
+ const char *titleAddText;
+ const char *splashImage;
+} network_styles[] = {
+ {"main", QAPP_APP_NAME_DEFAULT, ":/icons/bitcoin", "", ":/images/splash"},
+ {"test", QAPP_APP_NAME_TESTNET, ":/icons/bitcoin_testnet", QT_TRANSLATE_NOOP("SplashScreen", "[testnet]"), ":/images/splash_testnet"},
+ {"regtest", QAPP_APP_NAME_TESTNET, ":/icons/bitcoin_testnet", "[regtest]", ":/images/splash_testnet"}
+};
+static const unsigned network_styles_count = sizeof(network_styles)/sizeof(*network_styles);
+
+// titleAddText needs to be const char* for tr()
+NetworkStyle::NetworkStyle(const QString &appName, const QString &appIcon, const char *titleAddText, const QString &splashImage):
+ appName(appName),
+ appIcon(appIcon),
+ titleAddText(qApp->translate("SplashScreen", titleAddText)),
+ splashImage(splashImage)
+{
+}
+
+const NetworkStyle *NetworkStyle::instantiate(const QString &networkId)
+{
+ for (unsigned x=0; x<network_styles_count; ++x)
+ {
+ if (networkId == network_styles[x].networkId)
+ {
+ return new NetworkStyle(
+ network_styles[x].appName,
+ network_styles[x].appIcon,
+ network_styles[x].titleAddText,
+ network_styles[x].splashImage);
+ }
+ }
+ return 0;
+}
diff --git a/src/qt/networkstyle.h b/src/qt/networkstyle.h
new file mode 100644
index 0000000000..99304d61a3
--- /dev/null
+++ b/src/qt/networkstyle.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef H_NETWORKSTYLE
+#define H_NETWORKSTYLE
+
+#include <QIcon>
+#include <QPixmap>
+#include <QString>
+
+/* Coin network-specific GUI style information */
+class NetworkStyle
+{
+public:
+ /** Get style associated with provided BIP70 network id, or 0 if not known */
+ static const NetworkStyle *instantiate(const QString &networkId);
+
+ const QString &getAppName() const { return appName; }
+ const QIcon &getAppIcon() const { return appIcon; }
+ const QString &getTitleAddText() const { return titleAddText; }
+ const QPixmap &getSplashImage() const { return splashImage; }
+
+private:
+ NetworkStyle(const QString &appName, const QString &appIcon, const char *titleAddText, const QString &splashImage);
+
+ QString appName;
+ QIcon appIcon;
+ QString titleAddText;
+ QPixmap splashImage;
+};
+
+#endif // H_NETWORKSTYLE
diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp
index 74512e62aa..b4b81440ca 100644
--- a/src/qt/splashscreen.cpp
+++ b/src/qt/splashscreen.cpp
@@ -6,6 +6,7 @@
#include "clientversion.h"
#include "init.h"
+#include "networkstyle.h"
#include "ui_interface.h"
#include "util.h"
#include "version.h"
@@ -19,7 +20,7 @@
#include <QDesktopWidget>
#include <QPainter>
-SplashScreen::SplashScreen(Qt::WindowFlags f, bool isTestNet) :
+SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) :
QWidget(0, f), curAlignment(0)
{
// set reference point, paddings
@@ -34,17 +35,12 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, bool isTestNet) :
QString titleText = tr("Bitcoin Core");
QString versionText = QString("Version %1").arg(QString::fromStdString(FormatFullVersion()));
QString copyrightText = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers"));
- QString testnetAddText = QString(tr("[testnet]")); // define text to place as single text object
+ QString titleAddText = networkStyle->getTitleAddText();
QString font = "Arial";
// load the bitmap for writing some text over it
- if(isTestNet) {
- pixmap = QPixmap(":/images/splash_testnet");
- }
- else {
- pixmap = QPixmap(":/images/splash");
- }
+ pixmap = networkStyle->getSplashImage();
QPainter pixPaint(&pixmap);
pixPaint.setPen(QColor(100,100,100));
@@ -78,23 +74,20 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, bool isTestNet) :
pixPaint.setFont(QFont(font, 10*fontFactor));
pixPaint.drawText(pixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText);
- // draw testnet string if testnet is on
- if(isTestNet) {
+ // draw additional text if special network
+ if(!titleAddText.isEmpty()) {
QFont boldFont = QFont(font, 10*fontFactor);
boldFont.setWeight(QFont::Bold);
pixPaint.setFont(boldFont);
fm = pixPaint.fontMetrics();
- int testnetAddTextWidth = fm.width(testnetAddText);
- pixPaint.drawText(pixmap.width()-testnetAddTextWidth-10,15,testnetAddText);
+ int titleAddTextWidth = fm.width(titleAddText);
+ pixPaint.drawText(pixmap.width()-titleAddTextWidth-10,15,titleAddText);
}
pixPaint.end();
// Set window title
- if(isTestNet)
- setWindowTitle(titleText + " " + testnetAddText);
- else
- setWindowTitle(titleText);
+ setWindowTitle(titleText + " " + titleAddText);
// Resize window and move to center of desktop, disallow resizing
QRect r(QPoint(), pixmap.size());
diff --git a/src/qt/splashscreen.h b/src/qt/splashscreen.h
index 89c21e6457..128edadbee 100644
--- a/src/qt/splashscreen.h
+++ b/src/qt/splashscreen.h
@@ -7,6 +7,8 @@
#include <QSplashScreen>
+class NetworkStyle;
+
/** Class for the splashscreen with information of the running client.
*
* @note this is intentionally not a QSplashScreen. Bitcoin Core initialization
@@ -18,7 +20,7 @@ class SplashScreen : public QWidget
Q_OBJECT
public:
- explicit SplashScreen(Qt::WindowFlags f, bool isTestNet);
+ explicit SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle);
~SplashScreen();
protected:
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index e794bf69e0..c767835a27 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -239,7 +239,7 @@ Value getmininginfo(const Array& params, bool fHelp)
obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1)));
obj.push_back(Pair("networkhashps", getnetworkhashps(params, false)));
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
- obj.push_back(Pair("testnet", Params().NetworkID() == CBaseChainParams::TESTNET));
+ obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
obj.push_back(Pair("chain", Params().NetworkIDString()));
#ifdef ENABLE_WALLET
obj.push_back(Pair("generate", getgenerate(params, false)));
diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp
index dd45eefd58..8be14b567c 100644
--- a/src/rpcmisc.cpp
+++ b/src/rpcmisc.cpp
@@ -87,7 +87,7 @@ Value getinfo(const Array& params, bool fHelp)
obj.push_back(Pair("connections", (int)vNodes.size()));
obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.ToStringIPPort() : string())));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
- obj.push_back(Pair("testnet", Params().NetworkID() == CBaseChainParams::TESTNET));
+ obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
#ifdef ENABLE_WALLET
if (pwalletMain) {
obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime()));