aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--contrib/bitrpc/bitrpc.py12
-rw-r--r--src/Makefile.am5
-rw-r--r--src/base58.cpp9
-rw-r--r--src/bitcoin-cli.cpp1
-rw-r--r--src/chainparams.cpp7
-rw-r--r--src/chainparams.h28
-rw-r--r--src/compat/glibc_sanity.cpp61
-rw-r--r--src/compat/glibcxx_sanity.cpp61
-rw-r--r--src/compat/sanity.h7
-rw-r--r--src/init.cpp18
-rw-r--r--src/miner.cpp2
-rw-r--r--src/qt/clientmodel.cpp8
-rw-r--r--src/qt/clientmodel.h2
-rw-r--r--src/qt/paymentrequestplus.cpp1
-rw-r--r--src/qt/paymentrequestplus.h2
-rw-r--r--src/qt/paymentserver.cpp14
-rw-r--r--src/qt/paymentserver.h1
-rw-r--r--src/qt/rpcconsole.cpp2
-rw-r--r--src/qt/transactiondesc.cpp2
-rw-r--r--src/qt/walletmodel.cpp2
-rw-r--r--src/rpcblockchain.cpp17
-rw-r--r--src/rpcmining.cpp4
-rw-r--r--src/rpcmisc.cpp2
24 files changed, 203 insertions, 67 deletions
diff --git a/configure.ac b/configure.ac
index d8521ad3ad..81a32f9fb7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -368,7 +368,7 @@ if test x$TARGET_OS = xdarwin; then
AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"])
fi
-AC_CHECK_HEADERS([stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h])
+AC_CHECK_HEADERS([stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h])
dnl Check for MSG_NOSIGNAL
AC_MSG_CHECKING(for MSG_NOSIGNAL)
diff --git a/contrib/bitrpc/bitrpc.py b/contrib/bitrpc/bitrpc.py
index a84d7e34dd..02577b1b6a 100644
--- a/contrib/bitrpc/bitrpc.py
+++ b/contrib/bitrpc/bitrpc.py
@@ -22,6 +22,18 @@ if cmd == "backupwallet":
print access.backupwallet(path)
except:
print "\n---An error occurred---\n"
+
+elif cmd == "encryptwallet":
+ try:
+ pwd = getpass.getpass(prompt="Enter passphrase: ")
+ pwd2 = getpass.getpass(prompt="Repeat passphrase: ")
+ if pwd == pwd2:
+ access.encryptwallet(pwd)
+ print "\n---Wallet encrypted. Server stopping, restart to run with encrypted wallet---\n"
+ else:
+ print "\n---Passphrases do not match---\n"
+ except:
+ print "\n---An error occurred---\n"
elif cmd == "getaccount":
try:
diff --git a/src/Makefile.am b/src/Makefile.am
index 0a76829197..e1542203f8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -85,7 +85,8 @@ BITCOIN_CORE_H = \
util.h \
version.h \
walletdb.h \
- wallet.h
+ wallet.h \
+ compat/sanity.h
JSON_H = \
json/json_spirit.h \
@@ -154,6 +155,8 @@ libbitcoin_common_a_SOURCES = \
sync.cpp \
util.cpp \
version.cpp \
+ compat/glibc_sanity.cpp \
+ compat/glibcxx_sanity.cpp \
$(BITCOIN_CORE_H)
if GLIBC_BACK_COMPAT
diff --git a/src/base58.cpp b/src/base58.cpp
index 5975703887..1bd64684e5 100644
--- a/src/base58.cpp
+++ b/src/base58.cpp
@@ -114,9 +114,8 @@ std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn) {
}
bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet) {
- if (!DecodeBase58(psz, vchRet))
- return false;
- if (vchRet.size() < 4)
+ if (!DecodeBase58(psz, vchRet) ||
+ (vchRet.size() < 4))
{
vchRet.clear();
return false;
@@ -154,8 +153,8 @@ void CBase58Data::SetData(const std::vector<unsigned char> &vchVersionIn, const
bool CBase58Data::SetString(const char* psz, unsigned int nVersionBytes) {
std::vector<unsigned char> vchTemp;
- DecodeBase58Check(psz, vchTemp);
- if (vchTemp.size() < nVersionBytes) {
+ bool rc58 = DecodeBase58Check(psz, vchTemp);
+ if ((!rc58) || (vchTemp.size() < nVersionBytes)) {
vchData.clear();
vchVersion.clear();
return false;
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index c7327fd7c9..40b45415c4 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -12,6 +12,7 @@
#include <boost/filesystem/operations.hpp>
+using namespace std;
using namespace boost;
using namespace boost::asio;
using namespace json_spirit;
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 1749dd6ff9..31eac62d48 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -10,6 +10,7 @@
#include <boost/assign/list_of.hpp>
+using namespace std;
using namespace boost::assign;
//
@@ -99,6 +100,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.
@@ -176,7 +178,6 @@ public:
fDefaultCheckMemPool = false;
fAllowMinDifficultyBlocks = false;
fRequireStandard = true;
- fRPCisTestNet = false;
fMineBlocksOnDemand = false;
}
};
@@ -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.
@@ -227,7 +229,6 @@ public:
fDefaultCheckMemPool = false;
fAllowMinDifficultyBlocks = true;
fRequireStandard = false;
- fRPCisTestNet = true;
fMineBlocksOnDemand = false;
}
};
@@ -240,6 +241,7 @@ class CRegTestParams : public CTestNetParams {
public:
CRegTestParams() {
networkID = CChainParams::REGTEST;
+ strNetworkID = "regtest";
pchMessageStart[0] = 0xfa;
pchMessageStart[1] = 0xbf;
pchMessageStart[2] = 0xb5;
@@ -265,7 +267,6 @@ public:
fDefaultCheckMemPool = true;
fAllowMinDifficultyBlocks = true;
fRequireStandard = false;
- fRPCisTestNet = true;
fMineBlocksOnDemand = true;
}
};
diff --git a/src/chainparams.h b/src/chainparams.h
index 8370cc5690..c0a6ebda6b 100644
--- a/src/chainparams.h
+++ b/src/chainparams.h
@@ -12,13 +12,11 @@
#include <vector>
-using namespace std;
-
typedef unsigned char MessageStartChars[MESSAGE_START_SIZE];
struct CDNSSeedData {
- string name, host;
- CDNSSeedData(const string &strName, const string &strHost) : name(strName), host(strHost) {}
+ std::string name, host;
+ CDNSSeedData(const std::string &strName, const std::string &strHost) : name(strName), host(strHost) {}
};
/**
@@ -51,7 +49,7 @@ public:
const uint256& HashGenesisBlock() const { return hashGenesisBlock; }
const MessageStartChars& MessageStart() const { return pchMessageStart; }
- const vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
+ const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
int GetDefaultPort() const { return nDefaultPort; }
const uint256& ProofOfWorkLimit() const { return bnProofOfWorkLimit; }
int SubsidyHalvingInterval() const { return nSubsidyHalvingInterval; }
@@ -72,16 +70,16 @@ public:
bool AllowMinDifficultyBlocks() const { return fAllowMinDifficultyBlocks; }
/* Make standard checks */
bool RequireStandard() const { return fRequireStandard; }
- /* Make standard checks */
- bool RPCisTestNet() const { return fRPCisTestNet; }
- const string& DataDir() const { return strDataDir; }
+ const std::string& DataDir() const { return strDataDir; }
/* Make miner stop after a block is found. In RPC, don't return
* until nGenProcLimit blocks are generated */
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
Network NetworkID() const { return networkID; }
- const vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
+ /* 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 vector<CAddress>& FixedSeeds() const { return vFixedSeeds; }
+ const std::vector<CAddress>& FixedSeeds() const { return vFixedSeeds; }
int RPCPort() const { return nRPCPort; }
protected:
CChainParams() {}
@@ -89,7 +87,7 @@ protected:
uint256 hashGenesisBlock;
MessageStartChars pchMessageStart;
// Raw pub key bytes for the broadcast alert signing key.
- vector<unsigned char> vAlertPubKey;
+ std::vector<unsigned char> vAlertPubKey;
int nDefaultPort;
int nRPCPort;
uint256 bnProofOfWorkLimit;
@@ -97,19 +95,19 @@ protected:
int nEnforceBlockUpgradeMajority;
int nRejectBlockOutdatedMajority;
int nToCheckBlockUpgradeMajority;
- string strDataDir;
+ std::string strDataDir;
int nMinerThreads;
- vector<CDNSSeedData> vSeeds;
+ std::vector<CDNSSeedData> vSeeds;
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
Network networkID;
+ std::string strNetworkID;
CBlock genesis;
- vector<CAddress> vFixedSeeds;
+ std::vector<CAddress> vFixedSeeds;
bool fRequireRPCPassword;
bool fMiningRequiresPeers;
bool fDefaultCheckMemPool;
bool fAllowMinDifficultyBlocks;
bool fRequireStandard;
- bool fRPCisTestNet;
bool fMineBlocksOnDemand;
};
diff --git a/src/compat/glibc_sanity.cpp b/src/compat/glibc_sanity.cpp
new file mode 100644
index 0000000000..1f64df9e33
--- /dev/null
+++ b/src/compat/glibc_sanity.cpp
@@ -0,0 +1,61 @@
+#include "bitcoin-config.h"
+
+#include <cstddef>
+#if defined(HAVE_SYS_SELECT_H)
+#include <sys/select.h>
+#endif
+
+extern "C" void* memcpy(void* a, const void* b, size_t c);
+void* memcpy_int(void* a, const void* b, size_t c)
+{
+ return memcpy(a,b,c);
+}
+
+namespace {
+// trigger: Use the memcpy_int wrapper which calls our internal memcpy.
+// A direct call to memcpy may be optimized away by the compiler.
+// test: Fill an array with a sequence of integers. memcpy to a new empty array.
+// Verify that the arrays are equal. Use an odd size to decrease the odds of
+// the call being optimized away.
+template <unsigned int T>
+bool sanity_test_memcpy()
+{
+ unsigned int memcpy_test[T];
+ unsigned int memcpy_verify[T] = {};
+ for (unsigned int i = 0; i != T; ++i)
+ memcpy_test[i] = i;
+
+ memcpy_int(memcpy_verify,memcpy_test,sizeof(memcpy_test));
+
+ for (unsigned int i = 0; i != T; ++i)
+ {
+ if(memcpy_verify[i] != i)
+ return false;
+ }
+ return true;
+}
+
+#if defined(HAVE_SYS_SELECT_H)
+// trigger: Call FD_SET to trigger __fdelt_chk. FORTIFY_SOURCE must be defined
+// as >0 and optimizations must be set to at least -O2.
+// test: Add a file descriptor to an empty fd_set. Verify that it has been
+// correctly added.
+bool sanity_test_fdelt()
+{
+ fd_set fds;
+ FD_ZERO(&fds);
+ FD_SET(0, &fds);
+ return FD_ISSET(0,&fds);
+}
+#endif
+
+} // anon namespace
+
+bool glibc_sanity_test()
+{
+#if defined(HAVE_SYS_SELECT_H)
+ if (!sanity_test_fdelt())
+ return false;
+#endif
+ return sanity_test_memcpy<1025>();
+}
diff --git a/src/compat/glibcxx_sanity.cpp b/src/compat/glibcxx_sanity.cpp
new file mode 100644
index 0000000000..2ff70948fd
--- /dev/null
+++ b/src/compat/glibcxx_sanity.cpp
@@ -0,0 +1,61 @@
+#include <locale>
+#include <list>
+#include <stdexcept>
+
+namespace{
+
+// trigger: use ctype<char>::widen to trigger ctype<char>::_M_widen_init().
+// test: convert a char from narrow to wide and back. Verify that the result
+// matches the original.
+bool sanity_test_widen(char testchar)
+{
+ const std::ctype<char>& test(std::use_facet< std::ctype<char> >(std::locale()));
+ return test.narrow(test.widen(testchar),'b') == testchar;
+}
+
+// trigger: use list::push_back and list::pop_back to trigger _M_hook and
+// _M_unhook.
+// test: Push a sequence of integers into a list. Pop them off and verify that
+// they match the original sequence.
+bool sanity_test_list(unsigned int size)
+{
+ std::list<unsigned int> test;
+ for (unsigned int i = 0; i != size; ++i)
+ test.push_back(i+1);
+
+ if (test.size() != size)
+ return false;
+
+ while (!test.empty())
+ {
+ if(test.back() != test.size())
+ return false;
+ test.pop_back();
+ }
+ return true;
+}
+
+} // anon namespace
+
+// trigger: string::at(x) on an empty string to trigger __throw_out_of_range_fmt.
+// test: force std::string to throw an out_of_range exception. Verify that
+// it's caught correctly.
+bool sanity_test_range_fmt()
+{
+ std::string test;
+ try
+ {
+ test.at(1);
+ }
+ catch (const std::out_of_range&)
+ {
+ return true;
+ }
+ catch (...){}
+ return false;
+}
+
+bool glibcxx_sanity_test()
+{
+ return sanity_test_widen('a') && sanity_test_list(100) && sanity_test_range_fmt();
+}
diff --git a/src/compat/sanity.h b/src/compat/sanity.h
new file mode 100644
index 0000000000..a221f69dfc
--- /dev/null
+++ b/src/compat/sanity.h
@@ -0,0 +1,7 @@
+#ifndef BITCON_COMPAT_SANITY_H
+#define BITCON_COMPAT_SANITY_H
+
+bool glibc_sanity_test();
+bool glibcxx_sanity_test();
+
+#endif
diff --git a/src/init.cpp b/src/init.cpp
index 39453da9c8..6eab273526 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -31,6 +31,7 @@
#ifndef WIN32
#include <signal.h>
#endif
+#include "compat/sanity.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>
@@ -195,8 +196,9 @@ bool static Bind(const CService &addr, unsigned int flags) {
return true;
}
-std::string HelpMessage(HelpMessageMode hmm)
+std::string HelpMessage(HelpMessageMode mode)
{
+ // When adding new options to the categories, please keep and ensure alphabetical ordering.
string strUsage = _("Options:") + "\n";
strUsage += " -? " + _("This help message") + "\n";
strUsage += " -alertnotify=<cmd> " + _("Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)") + "\n";
@@ -204,7 +206,7 @@ std::string HelpMessage(HelpMessageMode hmm)
strUsage += " -checkblocks=<n> " + _("How many blocks to check at startup (default: 288, 0 = all)") + "\n";
strUsage += " -checklevel=<n> " + _("How thorough the block verification of -checkblocks is (0-4, default: 3)") + "\n";
strUsage += " -conf=<file> " + _("Specify configuration file (default: bitcoin.conf)") + "\n";
- if (hmm == HMM_BITCOIND)
+ if (mode == HMM_BITCOIND)
{
#if !defined(WIN32)
strUsage += " -daemon " + _("Run in the background as a daemon and accept commands") + "\n";
@@ -273,12 +275,13 @@ std::string HelpMessage(HelpMessageMode hmm)
strUsage += " -dropmessagestest=<n> " + _("Randomly drop 1 of every <n> network messages") + "\n";
strUsage += " -fuzzmessagestest=<n> " + _("Randomly fuzz 1 of every <n> network messages") + "\n";
strUsage += " -flushwallet " + _("Run a thread to flush wallet periodically (default: 1)") + "\n";
+ strUsage += " -stopafterblockimport " + _("Stop running after importing blocks from disk (default: 0)") + "\n";
}
strUsage += " -debug=<category> " + _("Output debugging information (default: 0, supplying <category> is optional)") + "\n";
strUsage += " " + _("If <category> is not supplied, output all debugging information.") + "\n";
strUsage += " " + _("<category> can be:");
strUsage += " addrman, alert, coindb, db, lock, rand, rpc, selectcoins, mempool, net"; // Don't translate these and qt below
- if (hmm == HMM_BITCOIN_QT)
+ if (mode == HMM_BITCOIN_QT)
strUsage += ", qt";
strUsage += ".\n";
strUsage += " -gen " + _("Generate coins (default: 0)") + "\n";
@@ -404,6 +407,11 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
LogPrintf("Warning: Could not open blocks file %s\n", path.string());
}
}
+
+ if (GetBoolArg("-stopafterblockimport", false)) {
+ LogPrintf("Stopping after block import\n");
+ StartShutdown();
+ }
}
/** Sanity checks
@@ -417,8 +425,8 @@ bool InitSanityCheck(void)
"information, visit https://en.bitcoin.it/wiki/OpenSSL_and_EC_Libraries");
return false;
}
-
- // TODO: remaining sanity checks, see #4081
+ if (!glibc_sanity_test() || !glibcxx_sanity_test())
+ return false;
return true;
}
diff --git a/src/miner.cpp b/src/miner.cpp
index a0a728fb81..87779efbbd 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -11,6 +11,8 @@
#ifdef ENABLE_WALLET
#include "wallet.h"
#endif
+
+using namespace std;
//////////////////////////////////////////////////////////////////////////////
//
// BitcoinMiner
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/paymentrequestplus.cpp b/src/qt/paymentrequestplus.cpp
index e369734a98..464f995eb6 100644
--- a/src/qt/paymentrequestplus.cpp
+++ b/src/qt/paymentrequestplus.cpp
@@ -17,6 +17,7 @@
#include <QDebug>
#include <QSslCertificate>
+using namespace std;
class SSLVerifyError : public std::runtime_error
{
diff --git a/src/qt/paymentrequestplus.h b/src/qt/paymentrequestplus.h
index 8c126b1fad..3c4861a4d4 100644
--- a/src/qt/paymentrequestplus.h
+++ b/src/qt/paymentrequestplus.h
@@ -24,7 +24,7 @@ public:
PaymentRequestPlus() { }
bool parse(const QByteArray& data);
- bool SerializeToString(string* output) const;
+ bool SerializeToString(std::string* output) const;
bool IsInitialized() const;
QString getPKIType() const;
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp
index 9241f9dc3c..49923a1afc 100644
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -44,6 +44,7 @@
#include <QUrlQuery>
#endif
+using namespace std;
using namespace boost;
const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds
@@ -490,17 +491,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 +500,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/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 0cfcb048c8..61da3373fd 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -18,6 +18,8 @@
#include <stdint.h>
#include <string>
+using namespace std;
+
QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx)
{
AssertLockHeld(cs_main);
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 87ff3db584..2f633a26c8 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -24,6 +24,8 @@
#include <QSet>
#include <QTimer>
+using namespace std;
+
WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent) :
QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0),
transactionTableModel(0),
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index 2a21fb462a..580c6bd5ba 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -438,7 +438,7 @@ Value getblockchaininfo(const Array& params, bool fHelp)
"Returns an object containing various state info regarding block chain processing.\n"
"\nResult:\n"
"{\n"
- " \"chain\": \"xxxx\", (string) current chain (main, testnet3, regtest)\n"
+ " \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n"
" \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
" \"bestblockhash\": \"...\", (string) the hash of the currently best block\n"
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
@@ -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;
}
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index 3caf7d89fe..57a51c0fde 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -253,6 +253,7 @@ Value getmininginfo(const Array& params, bool fHelp)
" \"hashespersec\": n (numeric) The hashes per second of the generation, or 0 if no generation.\n"
" \"pooledtx\": n (numeric) The size of the mem pool\n"
" \"testnet\": true|false (boolean) If using testnet or not\n"
+ " \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getmininginfo", "")
@@ -268,7 +269,8 @@ 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().RPCisTestNet()));
+ obj.push_back(Pair("testnet", Params().NetworkID() == CChainParams::TESTNET));
+ obj.push_back(Pair("chain", Params().NetworkIDString()));
#ifdef ENABLE_WALLET
obj.push_back(Pair("generate", getgenerate(params, false)));
obj.push_back(Pair("hashespersec", gethashespersec(params, false)));
diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp
index 77e0e09ec3..5181aa23d8 100644
--- a/src/rpcmisc.cpp
+++ b/src/rpcmisc.cpp
@@ -73,7 +73,7 @@ Value getinfo(const Array& params, bool fHelp)
obj.push_back(Pair("connections", (int)vNodes.size()));
obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string())));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
- obj.push_back(Pair("testnet", Params().RPCisTestNet()));
+ obj.push_back(Pair("testnet", Params().NetworkID() == CChainParams::TESTNET));
#ifdef ENABLE_WALLET
if (pwalletMain) {
obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime()));