aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--bitcoin-qt.pro23
-rw-r--r--contrib/gitian-descriptors/gitian-win32.yml4
-rw-r--r--contrib/homebrew/makefile.osx.patch47
-rw-r--r--doc/build-osx.md173
-rw-r--r--doc/build-osx.txt54
-rw-r--r--doc/readme-qt.rst19
-rw-r--r--src/bitcoinrpc.cpp2
-rw-r--r--src/checkqueue.h4
-rw-r--r--src/init.cpp80
-rw-r--r--src/main.cpp12
-rw-r--r--src/main.h2
-rw-r--r--src/makefile.linux-mingw15
-rw-r--r--src/makefile.mingw15
-rw-r--r--src/makefile.osx7
-rw-r--r--src/makefile.unix6
-rw-r--r--src/noui.cpp4
-rw-r--r--src/qt/bitcoin.cpp8
-rw-r--r--src/qt/bitcoingui.cpp6
-rw-r--r--src/qt/bitcoingui.h3
-rw-r--r--src/qt/bitcoinstrings.cpp1
-rw-r--r--src/qt/locale/bitcoin_en.ts55
-rw-r--r--src/rpcwallet.cpp1
-rw-r--r--src/test/util_tests.cpp62
-rw-r--r--src/ui_interface.h2
-rw-r--r--src/util.cpp33
-rw-r--r--src/util.h27
-rw-r--r--src/wallet.cpp21
28 files changed, 517 insertions, 171 deletions
diff --git a/README.md b/README.md
index 58dc2969a6..ce9bfae872 100644
--- a/README.md
+++ b/README.md
@@ -66,7 +66,7 @@ Unit tests for the GUI code are in `src/qt/test/`. To compile and run them:
qmake BITCOIN_QT_TEST=1 -o Makefile.test bitcoin-qt.pro
make -f Makefile.test
- ./Bitcoin-Qt
+ ./bitcoin-qt_test
Every pull request is built for both Windows and Linux on a dedicated server,
and unit and sanity tests are automatically run. The binaries produced may be
diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro
index 7bab4a4975..30e90a3fbc 100644
--- a/bitcoin-qt.pro
+++ b/bitcoin-qt.pro
@@ -1,5 +1,6 @@
TEMPLATE = app
TARGET = bitcoin-qt
+macx:TARGET = "Bitcoin-Qt"
VERSION = 0.8.0
INCLUDEPATH += src src/json src/qt
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
@@ -29,19 +30,19 @@ contains(RELEASE, 1) {
!win32:!macx {
# Linux: static link
- LIBS += -Wl,-Bstatic
+ LIBS += -Wl,-Bstatic -Wl,-z,relro -Wl,-z,now
+ # for extra security (see: https://wiki.debian.org/Hardening)
+ QMAKE_CXXFLAGS *= -D_FORTIFY_SOURCE=2
}
}
!win32 {
-# for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection
-QMAKE_CXXFLAGS *= -fstack-protector-all
-QMAKE_LFLAGS *= -fstack-protector-all
-# We need to exclude this for Windows cross compile with MinGW 4.2.x, as it will result in a non-working executable!
-# This can be enabled for Windows, when we switch to MinGW >= 4.4.x.
+ # for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection
+ QMAKE_CXXFLAGS *= -fstack-protector-all
+ QMAKE_LFLAGS *= -fstack-protector-all
+ # Exclude on Windows cross compile with MinGW 4.2.x, as it will result in a non-working executable!
+ # This can be enabled for Windows, when we switch to MinGW >= 4.4.x.
}
-# for extra security (see: https://wiki.debian.org/Hardening)
-QMAKE_CXXFLAGS *= -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now
# for extra security on Windows: enable ASLR and DEP via GCC linker flags
win32:QMAKE_LFLAGS *= -Wl,--dynamicbase -Wl,--nxcompat
# on Windows: enable GCC large address aware linker flag
@@ -99,14 +100,14 @@ contains(BITCOIN_NEED_QT_PLUGINS, 1) {
INCLUDEPATH += src/leveldb/include src/leveldb/helpers
LIBS += $$PWD/src/leveldb/libleveldb.a $$PWD/src/leveldb/libmemenv.a
!win32 {
- genleveldb.commands = cd $$PWD/src/leveldb && $(MAKE) libleveldb.a libmemenv.a
+ genleveldb.commands = cd $$PWD/src/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX $(MAKE) OPT=\"$$QMAKE_CXXFLAGS\" libleveldb.a libmemenv.a
} else {
# make an educated guess about what the ranlib command is called
isEmpty(QMAKE_RANLIB) {
QMAKE_RANLIB = $$replace(QMAKE_STRIP, strip, ranlib)
}
LIBS += -lshlwapi
- genleveldb.commands = cd $$PWD/src/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) libleveldb.a libmemenv.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libleveldb.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libmemenv.a
+ genleveldb.commands = cd $$PWD/src/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) OPT=\"$$QMAKE_CXXFLAGS\" libleveldb.a libmemenv.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libleveldb.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libmemenv.a
}
genleveldb.target = $$PWD/src/leveldb/libleveldb.a
genleveldb.depends = FORCE
@@ -300,6 +301,7 @@ DEPENDPATH += src/qt/test
QT += testlib
TARGET = bitcoin-qt_test
DEFINES += BITCOIN_QT_TEST
+ macx: CONFIG -= app_bundle
}
CODECFORTR = UTF-8
@@ -381,7 +383,6 @@ macx:OBJECTIVE_SOURCES += src/qt/macdockiconhandler.mm
macx:LIBS += -framework Foundation -framework ApplicationServices -framework AppKit
macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0
macx:ICON = src/qt/res/icons/bitcoin.icns
-macx:TARGET = "Bitcoin-Qt"
macx:QMAKE_CFLAGS_THREAD += -pthread
macx:QMAKE_LFLAGS_THREAD += -pthread
macx:QMAKE_CXXFLAGS_THREAD += -pthread
diff --git a/contrib/gitian-descriptors/gitian-win32.yml b/contrib/gitian-descriptors/gitian-win32.yml
index 9df42a0bec..fd3b55325a 100644
--- a/contrib/gitian-descriptors/gitian-win32.yml
+++ b/contrib/gitian-descriptors/gitian-win32.yml
@@ -24,7 +24,7 @@ script: |
cd $HOME/qt
unzip ../build/qt-win32-4.8.3-gitian-r1.zip
cd $HOME/build/
- export PATH=$PATH:$HOME/qt/bin/
+ export PATH=$HOME/qt/bin/:$PATH
#
mkdir boost_1_50_0
cd boost_1_50_0
@@ -51,7 +51,7 @@ script: |
export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
export FAKETIME=$REFERENCE_DATETIME
export TZ=UTC
- $HOME/qt/src/bin/qmake -spec unsupported/win32-g++-cross MINIUPNPC_LIB_PATH=$HOME/build/miniupnpc MINIUPNPC_INCLUDE_PATH=$HOME/build/ BDB_LIB_PATH=$HOME/build/db-4.8.30.NC/build_unix BDB_INCLUDE_PATH=$HOME/build/db-4.8.30.NC/build_unix BOOST_LIB_PATH=$HOME/build/boost_1_50_0/stage/lib BOOST_INCLUDE_PATH=$HOME/build/boost_1_50_0 BOOST_LIB_SUFFIX=-mt-s BOOST_THREAD_LIB_SUFFIX=_win32-mt-s OPENSSL_LIB_PATH=$HOME/build/openssl-1.0.1c OPENSSL_INCLUDE_PATH=$HOME/build/openssl-1.0.1c/include QRENCODE_LIB_PATH=$HOME/build/qrencode-3.2.0/.libs QRENCODE_INCLUDE_PATH=$HOME/build/qrencode-3.2.0 USE_QRCODE=1 INCLUDEPATH=$HOME/build DEFINES=BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 QMAKE_LRELEASE=lrelease QMAKE_CXXFLAGS=-frandom-seed=bitcoin QMAKE_LFLAGS=-frandom-seed=bitcoin USE_BUILD_INFO=1
+ $HOME/qt/src/bin/qmake -spec unsupported/win32-g++-cross MINIUPNPC_LIB_PATH=$HOME/build/miniupnpc MINIUPNPC_INCLUDE_PATH=$HOME/build/ BDB_LIB_PATH=$HOME/build/db-4.8.30.NC/build_unix BDB_INCLUDE_PATH=$HOME/build/db-4.8.30.NC/build_unix BOOST_LIB_PATH=$HOME/build/boost_1_50_0/stage/lib BOOST_INCLUDE_PATH=$HOME/build/boost_1_50_0 BOOST_LIB_SUFFIX=-mt-s BOOST_THREAD_LIB_SUFFIX=_win32-mt-s OPENSSL_LIB_PATH=$HOME/build/openssl-1.0.1c OPENSSL_INCLUDE_PATH=$HOME/build/openssl-1.0.1c/include QRENCODE_LIB_PATH=$HOME/build/qrencode-3.2.0/.libs QRENCODE_INCLUDE_PATH=$HOME/build/qrencode-3.2.0 USE_QRCODE=1 INCLUDEPATH=$HOME/build DEFINES=BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 QMAKE_LRELEASE=lrelease QMAKE_CXXFLAGS=-frandom-seed=bitcoin USE_BUILD_INFO=1
make $MAKEOPTS
cp release/bitcoin-qt.exe $OUTDIR/
#
diff --git a/contrib/homebrew/makefile.osx.patch b/contrib/homebrew/makefile.osx.patch
new file mode 100644
index 0000000000..340de0efdf
--- /dev/null
+++ b/contrib/homebrew/makefile.osx.patch
@@ -0,0 +1,47 @@
+diff --git a/src/makefile.osx b/src/makefile.osx
+index 8b7c559..8a0560c 100644
+--- a/src/makefile.osx
++++ b/src/makefile.osx
+@@ -7,17 +7,21 @@
+ # Originally by Laszlo Hanyecz (solar@heliacal.net)
+
+ CXX=llvm-g++
+-DEPSDIR=/opt/local
++DEPSDIR=/usr/local
++DB4DIR=/usr/local/opt/berkeley-db4
++OPENSSLDIR=/usr/local/opt/openssl
+
+ INCLUDEPATHS= \
+ -I"$(CURDIR)" \
+- -I"$(CURDIR)"/obj \
++ -I"$(CURDIR)/obj" \
+ -I"$(DEPSDIR)/include" \
+- -I"$(DEPSDIR)/include/db48"
++ -I"$(DB4DIR)/include" \
++ -I"$(OPENSSLDIR)/include"
+
+ LIBPATHS= \
+ -L"$(DEPSDIR)/lib" \
+- -L"$(DEPSDIR)/lib/db48"
++ -L"$(DB4DIR)/lib" \
++ -L"$(OPENSSLDIR)/lib"
+
+ USE_UPNP:=1
+ USE_IPV6:=1
+@@ -31,13 +35,13 @@ ifdef STATIC
+ TESTLIBS += \
+ $(DEPSDIR)/lib/libboost_unit_test_framework-mt.a
+ LIBS += \
+- $(DEPSDIR)/lib/db48/libdb_cxx-4.8.a \
++ $(DB4DIR)/lib/libdb_cxx-4.8.a \
+ $(DEPSDIR)/lib/libboost_system-mt.a \
+ $(DEPSDIR)/lib/libboost_filesystem-mt.a \
+ $(DEPSDIR)/lib/libboost_program_options-mt.a \
+ $(DEPSDIR)/lib/libboost_thread-mt.a \
+- $(DEPSDIR)/lib/libssl.a \
+- $(DEPSDIR)/lib/libcrypto.a \
++ $(OPENSSLDIR)/lib/libssl.a \
++ $(OPENSSLDIR)/lib/libcrypto.a \
+ -lz
+ else
+ TESTLIBS += \
diff --git a/doc/build-osx.md b/doc/build-osx.md
new file mode 100644
index 0000000000..1ed593d5eb
--- /dev/null
+++ b/doc/build-osx.md
@@ -0,0 +1,173 @@
+Mac OS X bitcoind build instructions
+====================================
+
+Authors
+-------
+
+* Laszlo Hanyecz <solar@heliacal.net>
+* Douglas Huff <dhuff@jrbobdobbs.org>
+* Colin Dean <cad@cad.cx>
+* Gavin Andresen <gavinandresen@gmail.com>
+
+License
+-------
+
+Copyright (c) 2009-2012 Bitcoin Developers
+
+Distributed under the MIT/X11 software license, see the accompanying
+file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+This product includes software developed by the OpenSSL Project for use in
+the OpenSSL Toolkit (http://www.openssl.org/).
+
+This product includes cryptographic software written by
+Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard.
+
+Notes
+-----
+
+See `doc/readme-qt.rst` for instructions on building Bitcoin-Qt, the
+graphical user interface.
+
+Tested on OS X 10.5 through 10.8 on Intel processors only. PPC is not
+supported because it is big-endian.
+
+All of the commands should be executed in a Terminal application. The
+built-in one is located in `/Applications/Utilities`.
+
+Preparation
+-----------
+
+You need to install XCode with all the options checked so that the compiler
+and everything is available in /usr not just /Developer. XCode should be
+available on your OS X installation media, but if not, you can get the
+current version from https://developer.apple.com/xcode/. If you install
+Xcode 4.3 or later, you'll need to install its command line tools. This can
+be done in `Xcode > Preferences > Downloads > Components` and generally must
+be re-done or updated every time Xcode is updated.
+
+There's an assumption that you already have `git` installed, as well. If
+not, it's the path of least resistance to install Github for Mac
+(OS X 10.7+) or
+[Git for OS X](https://code.google.com/p/git-osx-installer/). It is also
+available via Homebrew or MacPorts.
+
+You will also need to install [Homebrew](http://mxcl.github.com/homebrew/)
+or [MacPorts](http://www.macports.org/) in order to install library
+dependencies. It's largely a religious decision which to choose, but, as of
+December 2012, MacPorts is a little easier because you can just install the
+dependencies immediately - no other work required. If you're unsure, read
+the instructions through first in order to assess what you want to do.
+Homebrew is a little more popular among those newer to OS X.
+
+The installation of the actual dependencies is covered in the Instructions
+sections below.
+
+Instructions: MacPorts
+----------------------
+
+### Install dependencies
+
+Installing the dependencies using MacPorts is very straightforward.
+
+ sudo port install boost db48@+no_java openssl miniupnpc
+
+### Building `bitcoind`
+
+1. Clone the github tree to get the source code and go into the directory.
+
+ git clone git@github.com:bitcoin/bitcoin.git bitcoin
+ cd bitcoin
+
+2. Build bitcoind:
+
+ cd src
+ make -f makefile.osx
+
+3. It is a good idea to build and run the unit tests, too:
+
+ make -f makefile.osx test
+
+Instructions: HomeBrew
+----------------------
+
+#### Install dependencies using Homebrew
+
+ brew install boost miniupnpc openssl berkeley-db4
+
+### Building `bitcoind`
+
+1. Clone the github tree to get the source code and go into the directory.
+
+ git clone git@github.com:bitcoin/bitcoin.git bitcoin
+ cd bitcoin
+
+2. Modify source in order to pick up the `openssl` library.
+
+ Edit `makefile.osx` to account for library location differences. There's a
+ diff in `contrib/homebrew/makefile.osx.patch` that shows what you need to
+ change, or you can just patch by doing
+
+ patch -p1 < contrib/homebrew/makefile.osx.patch
+
+3. Build bitcoind:
+
+ cd src
+ make -f makefile.osx
+
+4. It is a good idea to build and run the unit tests, too:
+
+ make -f makefile.osx test
+
+Creating a release build
+------------------------
+
+A bitcoind binary is not included in the Bitcoin-Qt.app bundle. You can ignore
+this section if you are building `bitcoind` for your own use.
+
+If you are building `bitcoind` for others, your build machine should be set up
+as follows for maximum compatibility:
+
+All dependencies should be compiled with these flags:
+
+ -mmacosx-version-min=10.5 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk
+
+For MacPorts, that means editing your macports.conf and setting
+`macosx_deployment_target` and `build_arch`:
+
+ macosx_deployment_target=10.5
+ build_arch=i386
+
+... and then uninstalling and re-installing, or simply rebuilding, all ports.
+
+As of December 2012, the `boost` port does not obey `macosx_deployment_target`.
+Download `http://gavinandresen-bitcoin.s3.amazonaws.com/boost_macports_fix.zip`
+for a fix. Some ports also seem to obey either `build_arch` or
+`macosx_deployment_target`, but not both at the same time. For example, building
+on an OS X 10.6 64-bit machine fails. Official release builds of Bitcoin-Qt are
+compiled on an OS X 10.6 32-bit machine to workaround that problem.
+
+Once dependencies are compiled, creating `Bitcoin-Qt.app` is easy:
+
+ make -f Makefile.osx RELEASE=1
+
+Running
+-------
+
+It's now available at `./bitcoind`, provided that you are still in the `src`
+directory. We have to first create the RPC configuration file, though.
+
+Run `./bitcoind` to get the filename where it should be put, or just try these
+commands:
+
+ echo -e "rpcuser=bitcoinrpc\nrpcpassword=$(xxd -l 16 -p /dev/urandom)" > "/Users/${USER}/Library/Application Support/Bitcoin/bitcoin.conf"
+ chmod 600 "/Users/${USER}/Library/Application Support/Bitcoin/bitcoin.conf"
+
+When next you run it, it will start downloading the blockchain, but it won't
+output anything while it's doing this. This process may take several hours.
+
+Other commands:
+
+ ./bitcoind --help # for a list of command-line options.
+ ./bitcoind -daemon # to start the bitcoin daemon.
+ ./bitcoind help # When the daemon is running, to get a list of RPC commands
diff --git a/doc/build-osx.txt b/doc/build-osx.txt
deleted file mode 100644
index fd878043c0..0000000000
--- a/doc/build-osx.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-Copyright (c) 2009-2012 Bitcoin Developers
-Distributed under the MIT/X11 software license, see the accompanying
-file COPYING or http://www.opensource.org/licenses/mit-license.php.
-This product includes software developed by the OpenSSL Project for use in
-the OpenSSL Toolkit (http://www.openssl.org/). This product includes
-cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP
-software written by Thomas Bernard.
-
-
-Mac OS X bitcoind build instructions
-Laszlo Hanyecz <solar@heliacal.net>
-Douglas Huff <dhuff@jrbobdobbs.org>
-
-
-See readme-qt.rst for instructions on building Bitcoin-Qt, the
-graphical user interface.
-
-Tested on 10.5, 10.6 and 10.7 intel. PPC is not supported because it's big-endian.
-
-All of the commands should be executed in Terminal.app.. it's in
-/Applications/Utilities
-
-You need to install XCode with all the options checked so that the compiler and
-everything is available in /usr not just /Developer. XCode should be available on your OS X
-install DVD, but if not, you can get the current version from https://developer.apple.com/xcode/
-
-
-1. Clone the github tree to get the source code:
-
-git clone git@github.com:bitcoin/bitcoin.git bitcoin
-
-2. Download and install MacPorts from http://www.macports.org/
-
-2a. (for 10.7 Lion)
- Edit /opt/local/etc/macports/macports.conf and uncomment "build_arch i386"
-
-3. Install dependencies from MacPorts
-
-sudo port install boost db48 openssl miniupnpc
-
-Optionally install qrencode (and set USE_QRCODE=1):
-sudo port install qrencode
-
-4. Now you should be able to build bitcoind:
-
-cd bitcoin/src
-make -f makefile.osx
-
-Run:
- ./bitcoind --help # for a list of command-line options.
-Run
- ./bitcoind -daemon # to start the bitcoin daemon.
-Run
- ./bitcoind help # When the daemon is running, to get a list of RPC commands
diff --git a/doc/readme-qt.rst b/doc/readme-qt.rst
index b0fdd4d810..7283dc780b 100644
--- a/doc/readme-qt.rst
+++ b/doc/readme-qt.rst
@@ -41,25 +41,6 @@ An executable named `bitcoin-qt` will be built.
.. _`Qt Creator`: http://qt-project.org/downloads/
-Windows
---------
-
-Windows build instructions:
-
-- Download the `Qt Windows SDK`_ and install it. You don't need the Symbian stuff, just the desktop Qt.
-
-- Download and extract the `dependencies archive`_ [#]_, or compile openssl, boost and dbcxx yourself.
-
-- Copy the contents of the folder "deps" to "X:\\QtSDK\\mingw", replace X:\\ with the location where you installed the Qt SDK. Make sure that the contents of "deps\\include" end up in the current "include" directory.
-
-- Open the bitcoin-qt.pro file in Qt Creator and build as normal (ctrl-B)
-
-.. _`Qt Windows SDK`: http://qt-project.org/downloads/
-.. _`dependencies archive`: https://download.visucore.com/bitcoin/qtgui_deps_1.zip
-.. [#] PGP signature: https://download.visucore.com/bitcoin/qtgui_deps_1.zip.sig (signed with RSA key ID `610945D0`_)
-.. _`610945D0`: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x610945D0
-
-
Mac OS X
--------
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 7751e4c8b6..230a248422 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -246,7 +246,7 @@ static const CRPCCommand vRPCCommands[] =
{ "getblocktemplate", &getblocktemplate, true, false },
{ "submitblock", &submitblock, false, false },
{ "listsinceblock", &listsinceblock, false, false },
- { "dumpprivkey", &dumpprivkey, false, false },
+ { "dumpprivkey", &dumpprivkey, true, false },
{ "importprivkey", &importprivkey, false, false },
{ "listunspent", &listunspent, false, false },
{ "getrawtransaction", &getrawtransaction, false, false },
diff --git a/src/checkqueue.h b/src/checkqueue.h
index 36141dd74b..12dde36fe7 100644
--- a/src/checkqueue.h
+++ b/src/checkqueue.h
@@ -163,6 +163,10 @@ public:
condQuit.wait(lock);
}
+ ~CCheckQueue() {
+ Quit();
+ }
+
friend class CCheckQueueControl<T>;
};
diff --git a/src/init.cpp b/src/init.cpp
index 15a46946fa..64f91a349f 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -82,6 +82,7 @@ void Shutdown(void* parg)
if (fFirstThread)
{
fShutdown = true;
+ fRequestShutdown = true;
nTransactionsUpdated++;
bitdb.Flush(false);
{
@@ -299,6 +300,7 @@ std::string HelpMessage()
" -rpcallowip=<ip> " + _("Allow JSON-RPC connections from specified IP address") + "\n" +
" -rpcconnect=<ip> " + _("Send commands to node running on <ip> (default: 127.0.0.1)") + "\n" +
" -blocknotify=<cmd> " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n" +
+ " -walletnotify=<cmd> " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n" +
" -upgradewallet " + _("Upgrade wallet to latest format") + "\n" +
" -keypool=<n> " + _("Set key pool size to <n> (default: 100)") + "\n" +
" -rescan " + _("Rescan the block chain for missing wallet transactions") + "\n" +
@@ -791,27 +793,69 @@ bool AppInit2()
nTotalCache -= nCoinDBCache;
nCoinCacheSize = nTotalCache / 300; // coins in memory require around 300 bytes
- uiInterface.InitMessage(_("Loading block index..."));
+ bool fLoaded = false;
+ while (!fLoaded) {
+ bool fReset = fReindex;
+ std::string strLoadError;
- nStart = GetTimeMillis();
- pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex);
- pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex);
- pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
-
- if (fReindex)
- pblocktree->WriteReindexing(true);
-
- if (!LoadBlockIndex())
- return InitError(_("Error loading block database"));
+ uiInterface.InitMessage(_("Loading block index..."));
- // Initialize the block index (no-op if non-empty database was already loaded)
- if (!InitBlockIndex())
- return InitError(_("Error initializing block database"));
-
- uiInterface.InitMessage(_("Verifying block database integrity..."));
+ nStart = GetTimeMillis();
+ do {
+ try {
+ UnloadBlockIndex();
+ delete pcoinsTip;
+ delete pcoinsdbview;
+ delete pblocktree;
+
+ pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex);
+ pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex);
+ pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
+
+ if (fReindex)
+ pblocktree->WriteReindexing(true);
+
+ if (!LoadBlockIndex()) {
+ strLoadError = _("Error loading block database");
+ break;
+ }
+
+ // Initialize the block index (no-op if non-empty database was already loaded)
+ if (!InitBlockIndex()) {
+ strLoadError = _("Error initializing block database");
+ break;
+ }
+
+ uiInterface.InitMessage(_("Verifying database..."));
+ if (!VerifyDB()) {
+ strLoadError = _("Corrupted block database detected");
+ break;
+ }
+ } catch(std::exception &e) {
+ strLoadError = _("Error opening block database");
+ break;
+ }
- if (!VerifyDB())
- return InitError(_("Corrupted block database detected. Please restart the client with -reindex."));
+ fLoaded = true;
+ } while(false);
+
+ if (!fLoaded) {
+ // first suggest a reindex
+ if (!fReset) {
+ bool fRet = uiInterface.ThreadSafeMessageBox(
+ strLoadError + ".\n" + _("Do you want to rebuild the block database now?"),
+ "", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT);
+ if (fRet) {
+ fReindex = true;
+ fRequestShutdown = false;
+ } else {
+ return false;
+ }
+ } else {
+ return InitError(strLoadError);
+ }
+ }
+ }
if (mapArgs.count("-txindex") && fTxIndex != GetBoolArg("-txindex", false))
return InitError(_("You need to rebuild the databases using -reindex to change -txindex"));
diff --git a/src/main.cpp b/src/main.cpp
index 8c115c26f9..3151a806dc 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2653,6 +2653,18 @@ bool VerifyDB() {
return true;
}
+void UnloadBlockIndex()
+{
+ mapBlockIndex.clear();
+ setBlockIndexValid.clear();
+ pindexGenesisBlock = NULL;
+ nBestHeight = 0;
+ bnBestChainWork = 0;
+ bnBestInvalidWork = 0;
+ hashBestChain = 0;
+ pindexBest = NULL;
+}
+
bool LoadBlockIndex()
{
if (fTestNet)
diff --git a/src/main.h b/src/main.h
index d69aef94ea..4a217d1746 100644
--- a/src/main.h
+++ b/src/main.h
@@ -139,6 +139,8 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp = NULL);
bool InitBlockIndex();
/** Load the block tree and coins database from disk */
bool LoadBlockIndex();
+/** Unload database information */
+void UnloadBlockIndex();
/** Verify consistency of the block and coin databases */
bool VerifyDB();
/** Print the loaded block tree */
diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw
index c3cbe90bcd..7509e2798e 100644
--- a/src/makefile.linux-mingw
+++ b/src/makefile.linux-mingw
@@ -4,6 +4,9 @@
DEPSDIR:=/usr/i586-mingw32msvc
+CC := i586-mingw32msvc-gcc
+CXX := i586-mingw32msvc-g++
+
USE_UPNP:=0
USE_IPV6:=1
@@ -58,6 +61,7 @@ LIBS += -l mingwthrd -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l w
HEADERS = $(wildcard *.h)
OBJS= \
+ leveldb/libleveldb.a \
obj/alert.o \
obj/version.o \
obj/checkpoints.o \
@@ -95,8 +99,7 @@ all: bitcoind.exe
DEFS += -I"$(CURDIR)/leveldb/include"
DEFS += -I"$(CURDIR)/leveldb/helpers"
leveldb/libleveldb.a:
- @echo "Building LevelDB ..." && cd leveldb && CC=i586-mingw32msvc-gcc CXX=i586-mingw32msvc-g++ TARGET_OS=OS_WINDOWS_CROSSCOMPILE CXXFLAGS="$(INCLUDEPATHS)" LDFLAGS="$(LIBPATHS)" $(MAKE) libleveldb.a libmemenv.a && i586-mingw32msvc-ranlib libleveldb.a && i586-mingw32msvc-ranlib libmemenv.a && cd ..
-obj/leveldb.o: leveldb/libleveldb.a
+ @echo "Building LevelDB ..." && cd leveldb && TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) CC=$(CC) CXX=$(CXX) OPT="$(CFLAGS)" libleveldb.a libmemenv.a && i586-mingw32msvc-ranlib libleveldb.a && i586-mingw32msvc-ranlib libmemenv.a && cd ..
obj/build.h: FORCE
/bin/sh ../share/genbuild.sh obj/build.h
@@ -104,18 +107,18 @@ version.cpp: obj/build.h
DEFS += -DHAVE_BUILD_INFO
obj/%.o: %.cpp $(HEADERS)
- i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $<
+ $(CXX) -c $(CFLAGS) -o $@ $<
bitcoind.exe: $(OBJS:obj/%=obj/%)
- i586-mingw32msvc-g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
+ $(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
obj-test/%.o: test/%.cpp $(HEADERS)
- i586-mingw32msvc-g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $<
+ $(CXX) -c $(TESTDEFS) $(CFLAGS) -o $@ $<
test_bitcoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
- i586-mingw32msvc-g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework-mt-s $(LIBS)
+ $(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework-mt-s $(LIBS)
clean:
diff --git a/src/makefile.mingw b/src/makefile.mingw
index 366d32bd86..2e092ff686 100644
--- a/src/makefile.mingw
+++ b/src/makefile.mingw
@@ -15,6 +15,8 @@
# 'make clean' assumes it is running inside a MSYS shell, and uses 'rm'
# to remove files.
+CXX ?= g++
+
USE_UPNP:=-
USE_IPV6:=1
@@ -67,6 +69,7 @@ LIBS += -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell
HEADERS = $(wildcard *.h)
OBJS= \
+ leveldb/libleveldb.a \
obj/alert.o \
obj/version.o \
obj/checkpoints.o \
@@ -112,23 +115,21 @@ DEFS += $(addprefix -I,$(CURDIR)/leveldb/include)
DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
leveldb/libleveldb.a:
- cd leveldb && $(MAKE) OPT="$(DEBUGFLAGS)" TARGET_OS=NATIVE_WINDOWS libleveldb.a libmemenv.a && cd ..
-
-obj/leveldb.o: leveldb/libleveldb.a
+ cd leveldb && $(MAKE) CC=$(CC) CXX=$(CXX) OPT="$(CFLAGS)" TARGET_OS=NATIVE_WINDOWS libleveldb.a libmemenv.a && cd ..
obj/%.o: %.cpp $(HEADERS)
- g++ -c $(CFLAGS) -o $@ $<
+ $(CXX) -c $(CFLAGS) -o $@ $<
bitcoind.exe: $(OBJS:obj/%=obj/%)
- g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
+ $(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
obj-test/%.o: test/%.cpp $(HEADERS)
- g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $<
+ $(CXX) -c $(TESTDEFS) $(CFLAGS) -o $@ $<
test_bitcoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
- g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework$(BOOST_SUFFIX) $(LIBS)
+ $(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework$(BOOST_SUFFIX) $(LIBS)
clean:
rm -f bitcoind.exe test_bitcoin.exe
diff --git a/src/makefile.osx b/src/makefile.osx
index 8b7c559fa1..cdee781257 100644
--- a/src/makefile.osx
+++ b/src/makefile.osx
@@ -62,7 +62,7 @@ ifdef RELEASE
# the same way.
CFLAGS = -mmacosx-version-min=10.5 -arch i386 -O3
else
-CFLAGS = -g
+DEBUGFLAGS = -g
endif
# ppc doesn't work because we don't support big-endian
@@ -70,6 +70,7 @@ CFLAGS += -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \
$(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
OBJS= \
+ leveldb/libleveldb.a \
obj/alert.o \
obj/version.o \
obj/checkpoints.o \
@@ -130,8 +131,7 @@ LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
DEFS += $(addprefix -I,$(CURDIR)/leveldb/include)
DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
leveldb/libleveldb.a:
- @echo "Building LevelDB ..." && cd leveldb && $(MAKE) libleveldb.a libmemenv.a && cd ..
-obj/leveldb.o: leveldb/libleveldb.a
+ @echo "Building LevelDB ..." && cd leveldb && $(MAKE) CC=$(CC) CXX=$(CXX) OPT="$(CFLAGS)" libleveldb.a libmemenv.a && cd ..
# auto-generated dependencies:
-include obj/*.P
@@ -171,5 +171,6 @@ clean:
-rm -f obj/*.P
-rm -f obj-test/*.P
-rm -f obj/build.h
+ -cd leveldb && $(MAKE) clean || true
FORCE:
diff --git a/src/makefile.unix b/src/makefile.unix
index b52a0f8aea..ece2f59cf5 100644
--- a/src/makefile.unix
+++ b/src/makefile.unix
@@ -101,6 +101,7 @@ xCXXFLAGS=-O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-para
xLDFLAGS=$(LDHARDENING) $(LDFLAGS)
OBJS= \
+ leveldb/libleveldb.a \
obj/alert.o \
obj/version.o \
obj/checkpoints.o \
@@ -142,12 +143,12 @@ test check: test_bitcoin FORCE
#
# LevelDB support
#
+MAKEOVERRIDES =
LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
DEFS += $(addprefix -I,$(CURDIR)/leveldb/include)
DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
leveldb/libleveldb.a:
- @echo "Building LevelDB ..." && cd leveldb && $(MAKE) libleveldb.a libmemenv.a && cd ..
-obj/leveldb.o: leveldb/libleveldb.a
+ @echo "Building LevelDB ..." && cd leveldb && $(MAKE) CC=$(CC) CXX=$(CXX) OPT="$(xCXXFLAGS)" libleveldb.a libmemenv.a && cd ..
# auto-generated dependencies:
-include obj/*.P
@@ -187,5 +188,6 @@ clean:
-rm -f obj/*.P
-rm -f obj-test/*.P
-rm -f obj/build.h
+ -cd leveldb && $(MAKE) clean || true
FORCE:
diff --git a/src/noui.cpp b/src/noui.cpp
index 302d059291..c0e00c4715 100644
--- a/src/noui.cpp
+++ b/src/noui.cpp
@@ -9,7 +9,7 @@
#include <string>
-static int noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
+static bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
{
std::string strCaption;
// Check for usage of predefined caption
@@ -29,7 +29,7 @@ static int noui_ThreadSafeMessageBox(const std::string& message, const std::stri
printf("%s: %s\n", strCaption.c_str(), message.c_str());
fprintf(stderr, "%s: %s\n", strCaption.c_str(), message.c_str());
- return 4;
+ return false;
}
static bool noui_ThreadSafeAskFee(int64 /*nFeeRequired*/)
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index e5526a6c09..afd8d71a0e 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -34,23 +34,27 @@ Q_IMPORT_PLUGIN(qtaccessiblewidgets)
static BitcoinGUI *guiref;
static QSplashScreen *splashref;
-static void ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
+static bool ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
{
// Message from network thread
if(guiref)
{
bool modal = (style & CClientUIInterface::MODAL);
+ bool ret = false;
// In case of modal message, use blocking connection to wait for user to click a button
QMetaObject::invokeMethod(guiref, "message",
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(caption)),
Q_ARG(QString, QString::fromStdString(message)),
- Q_ARG(unsigned int, style));
+ Q_ARG(unsigned int, style),
+ Q_ARG(bool*, &ret));
+ return ret;
}
else
{
printf("%s: %s\n", caption.c_str(), message.c_str());
fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
+ return false;
}
}
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 16bc0a47de..f1bf5f5880 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -598,7 +598,7 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
progressBar->setToolTip(tooltip);
}
-void BitcoinGUI::message(const QString &title, const QString &message, unsigned int style)
+void BitcoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
{
QString strTitle = tr("Bitcoin") + " - ";
// Default to information icon
@@ -638,7 +638,9 @@ void BitcoinGUI::message(const QString &title, const QString &message, unsigned
buttons = QMessageBox::Ok;
QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons);
- mBox.exec();
+ int r = mBox.exec();
+ if (ret != NULL)
+ *ret = r == QMessageBox::Ok;
}
else
notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message);
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index 0726db7f9c..8ce0335bcd 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -128,8 +128,9 @@ public slots:
@param[in] message the displayed text
@param[in] style modality and style definitions (icon and used buttons - buttons only for message boxes)
@see CClientUIInterface::MessageBoxFlags
+ @param[in] ret pointer to a bool that will be modified to whether Ok was clicked (modal only)
*/
- void message(const QString &title, const QString &message, unsigned int style);
+ void message(const QString &title, const QString &message, unsigned int style, bool *ret = NULL);
/** Asks the user whether to pay the transaction fee or to cancel the transaction.
It is currently not possible to pass a return value to another thread through
BlockingQueuedConnection, so an indirected pointer is used.
diff --git a/src/qt/bitcoinstrings.cpp b/src/qt/bitcoinstrings.cpp
index 5bd1517091..2c3d859c82 100644
--- a/src/qt/bitcoinstrings.cpp
+++ b/src/qt/bitcoinstrings.cpp
@@ -100,6 +100,7 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Connect to a node to retrieve peer addresses,
QT_TRANSLATE_NOOP("bitcoin-core", "Discover own IP address (default: 1 when listening and no -externalip)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Don't generate coins"),
QT_TRANSLATE_NOOP("bitcoin-core", "Done loading"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Error initializing block database"),
QT_TRANSLATE_NOOP("bitcoin-core", "Error loading block database"),
QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat"),
QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat: Wallet corrupted"),
diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts
index 18249b1669..39062d0a2c 100644
--- a/src/qt/locale/bitcoin_en.ts
+++ b/src/qt/locale/bitcoin_en.ts
@@ -2179,7 +2179,7 @@ Address: %4
<translation>Bitcoin version</translation>
</message>
<message>
- <location line="+95"/>
+ <location line="+96"/>
<source>Usage:</source>
<translation>Usage:</translation>
</message>
@@ -2219,12 +2219,12 @@ Address: %4
<translation>Generate coins</translation>
</message>
<message>
- <location line="-26"/>
+ <location line="-27"/>
<source>Don&apos;t generate coins</source>
<translation>Don&apos;t generate coins</translation>
</message>
<message>
- <location line="+73"/>
+ <location line="+74"/>
<source>Specify data directory</source>
<translation>Specify data directory</translation>
</message>
@@ -2244,12 +2244,12 @@ Address: %4
<translation>Maintain at most &lt;n&gt; connections to peers (default: 125)</translation>
</message>
<message>
- <location line="-46"/>
+ <location line="-47"/>
<source>Connect to a node to retrieve peer addresses, and disconnect</source>
<translation>Connect to a node to retrieve peer addresses, and disconnect</translation>
</message>
<message>
- <location line="+77"/>
+ <location line="+78"/>
<source>Specify your own public address</source>
<translation>Specify your own public address</translation>
</message>
@@ -2259,7 +2259,7 @@ Address: %4
<translation>Threshold for disconnecting misbehaving peers (default: 100)</translation>
</message>
<message>
- <location line="-129"/>
+ <location line="-130"/>
<source>Number of seconds to keep misbehaving peers from reconnecting (default: 86400)</source>
<translation>Number of seconds to keep misbehaving peers from reconnecting (default: 86400)</translation>
</message>
@@ -2279,7 +2279,7 @@ Address: %4
<translation>Accept command line and JSON-RPC commands</translation>
</message>
<message>
- <location line="+74"/>
+ <location line="+75"/>
<source>Run in the background as a daemon and accept commands</source>
<translation>Run in the background as a daemon and accept commands</translation>
</message>
@@ -2289,7 +2289,7 @@ Address: %4
<translation>Use the test network</translation>
</message>
<message>
- <location line="-105"/>
+ <location line="-106"/>
<source>Accept connections from outside (default: 1 if no -proxy or -connect)</source>
<translation>Accept connections from outside (default: 1 if no -proxy or -connect)</translation>
</message>
@@ -2410,6 +2410,11 @@ If the file does not exist, create it with owner-readable-only file permissions.
</message>
<message>
<location line="+3"/>
+ <source>Error initializing block database</source>
+ <translation>Error initializing block database</translation>
+ </message>
+ <message>
+ <location line="+1"/>
<source>Error loading block database</source>
<translation>Error loading block database</translation>
</message>
@@ -2659,22 +2664,22 @@ If the file does not exist, create it with owner-readable-only file permissions.
<translation>Password for JSON-RPC connections</translation>
</message>
<message>
- <location line="-65"/>
+ <location line="-66"/>
<source>Allow JSON-RPC connections from specified IP address</source>
<translation>Allow JSON-RPC connections from specified IP address</translation>
</message>
<message>
- <location line="+74"/>
+ <location line="+75"/>
<source>Send commands to node running on &lt;ip&gt; (default: 127.0.0.1)</source>
<translation>Send commands to node running on &lt;ip&gt; (default: 127.0.0.1)</translation>
</message>
<message>
- <location line="-117"/>
+ <location line="-118"/>
<source>Execute command when the best block changes (%s in cmd is replaced by block hash)</source>
<translation>Execute command when the best block changes (%s in cmd is replaced by block hash)</translation>
</message>
<message>
- <location line="+139"/>
+ <location line="+140"/>
<source>Upgrade wallet to latest format</source>
<translation>Upgrade wallet to latest format</translation>
</message>
@@ -2704,12 +2709,12 @@ If the file does not exist, create it with owner-readable-only file permissions.
<translation>Server private key (default: server.pem)</translation>
</message>
<message>
- <location line="-147"/>
+ <location line="-148"/>
<source>Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)</source>
<translation>Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)</translation>
</message>
<message>
- <location line="+159"/>
+ <location line="+160"/>
<source>This help message</source>
<translation>This help message</translation>
</message>
@@ -2719,7 +2724,7 @@ If the file does not exist, create it with owner-readable-only file permissions.
<translation>Unable to bind to %s on this computer (bind returned error %d, %s)</translation>
</message>
<message>
- <location line="-83"/>
+ <location line="-84"/>
<source>Connect through socks proxy</source>
<translation>Connect through socks proxy</translation>
</message>
@@ -2729,7 +2734,7 @@ If the file does not exist, create it with owner-readable-only file permissions.
<translation>Allow DNS lookups for -addnode, -seednode and -connect</translation>
</message>
<message>
- <location line="+54"/>
+ <location line="+55"/>
<source>Loading addresses...</source>
<translation>Loading addresses...</translation>
</message>
@@ -2779,7 +2784,7 @@ If the file does not exist, create it with owner-readable-only file permissions.
<translation>Unknown -socks proxy version requested: %i</translation>
</message>
<message>
- <location line="-88"/>
+ <location line="-89"/>
<source>Cannot resolve -bind address: &apos;%s&apos;</source>
<translation>Cannot resolve -bind address: &apos;%s&apos;</translation>
</message>
@@ -2789,7 +2794,7 @@ If the file does not exist, create it with owner-readable-only file permissions.
<translation>Cannot resolve -externalip address: &apos;%s&apos;</translation>
</message>
<message>
- <location line="+42"/>
+ <location line="+43"/>
<source>Invalid amount for -paytxfee=&lt;amount&gt;: &apos;%s&apos;</source>
<translation>Invalid amount for -paytxfee=&lt;amount&gt;: &apos;%s&apos;</translation>
</message>
@@ -2814,7 +2819,7 @@ If the file does not exist, create it with owner-readable-only file permissions.
<translation>Loading block index...</translation>
</message>
<message>
- <location line="-56"/>
+ <location line="-57"/>
<source>Add a node to connect to and attempt to keep the connection open</source>
<translation>Add a node to connect to and attempt to keep the connection open</translation>
</message>
@@ -2824,7 +2829,7 @@ If the file does not exist, create it with owner-readable-only file permissions.
<translation>Unable to bind to %s on this computer. Bitcoin is probably already running.</translation>
</message>
<message>
- <location line="+65"/>
+ <location line="+66"/>
<source>Find peers using internet relay chat (default: 0)</source>
<translation>Find peers using internet relay chat (default: 0)</translation>
</message>
@@ -2839,7 +2844,7 @@ If the file does not exist, create it with owner-readable-only file permissions.
<translation>Loading wallet...</translation>
</message>
<message>
- <location line="-51"/>
+ <location line="-52"/>
<source>Cannot downgrade wallet</source>
<translation>Cannot downgrade wallet</translation>
</message>
@@ -2854,17 +2859,17 @@ If the file does not exist, create it with owner-readable-only file permissions.
<translation>Cannot write default address</translation>
</message>
<message>
- <location line="+61"/>
+ <location line="+62"/>
<source>Rescanning...</source>
<translation>Rescanning...</translation>
</message>
<message>
- <location line="-55"/>
+ <location line="-56"/>
<source>Done loading</source>
<translation>Done loading</translation>
</message>
<message>
- <location line="+78"/>
+ <location line="+79"/>
<source>To use the %s option</source>
<translation>To use the %s option</translation>
</message>
@@ -2874,7 +2879,7 @@ If the file does not exist, create it with owner-readable-only file permissions.
<translation>Error</translation>
</message>
<message>
- <location line="-28"/>
+ <location line="-29"/>
<source>You must set rpcpassword=&lt;password&gt; in the configuration file:
%s
If the file does not exist, create it with owner-readable-only file permissions.</source>
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index 90a68f560a..21eb2fd1aa 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -75,6 +75,7 @@ Value getinfo(const Array& params, bool fHelp)
obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance())));
obj.push_back(Pair("blocks", (int)nBestHeight));
+ obj.push_back(Pair("timeoffset", (boost::int64_t)GetTimeOffset()));
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()));
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index f56969cba6..1b0ccad511 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -261,4 +261,66 @@ BOOST_AUTO_TEST_CASE(util_IsHex)
BOOST_CHECK(!IsHex("0x0000"));
}
+BOOST_AUTO_TEST_CASE(util_seed_insecure_rand)
+{
+ // Expected results for the determinstic seed.
+ const uint32_t exp_vals[11] = { 91632771U,1889679809U,3842137544U,3256031132U,
+ 1761911779U, 489223532U,2692793790U,2737472863U,
+ 2796262275U,1309899767U,840571781U};
+ // Expected 0s in rand()%(idx+2) for the determinstic seed.
+ const int exp_count[9] = {5013,3346,2415,1972,1644,1386,1176,1096,1009};
+ int i;
+ int count=0;
+
+ seed_insecure_rand();
+
+ //Does the non-determistic rand give us results that look too like the determinstic one?
+ for (i=0;i<10;i++)
+ {
+ int match = 0;
+ uint32_t rval = insecure_rand();
+ for (int j=0;j<11;j++)match |= rval==exp_vals[j];
+ count += match;
+ }
+ // sum(binomial(10,i)*(11/(2^32))^i*(1-(11/(2^32)))^(10-i),i,0,4) ~= 1-1/2^134.73
+ // So _very_ unlikely to throw a false failure here.
+ BOOST_CHECK(count<=4);
+
+ for (int mod=2;mod<11;mod++)
+ {
+ int mask = 1;
+ // Really rough binomal confidence approximation.
+ int err = 30*10000./mod*sqrt((1./mod*(1-1./mod))/10000.);
+ //mask is 2^ceil(log2(mod))-1
+ while(mask<mod-1)mask=(mask<<1)+1;
+
+ count = 0;
+ //How often does it get a zero from the uniform range [0,mod)?
+ for (i=0;i<10000;i++)
+ {
+ uint32_t rval;
+ do{
+ rval=insecure_rand()&mask;
+ }while(rval>=(uint32_t)mod);
+ count += rval==0;
+ }
+ BOOST_CHECK(count<=10000/mod+err);
+ BOOST_CHECK(count>=10000/mod-err);
+ }
+
+ seed_insecure_rand(true);
+
+ for (i=0;i<11;i++)
+ {
+ BOOST_CHECK_EQUAL(insecure_rand(),exp_vals[i]);
+ }
+
+ for (int mod=2;mod<11;mod++)
+ {
+ count = 0;
+ for (i=0;i<10000;i++) count += insecure_rand()%mod==0;
+ BOOST_CHECK_EQUAL(count,exp_count[mod-2]);
+ }
+}
+
BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/ui_interface.h b/src/ui_interface.h
index 703e15f095..f7dbe20894 100644
--- a/src/ui_interface.h
+++ b/src/ui_interface.h
@@ -68,7 +68,7 @@ public:
};
/** Show message box. */
- boost::signals2::signal<void (const std::string& message, const std::string& caption, unsigned int style)> ThreadSafeMessageBox;
+ boost::signals2::signal<bool (const std::string& message, const std::string& caption, unsigned int style), boost::signals2::last_value<bool> > ThreadSafeMessageBox;
/** Ask the user whether they want to pay a fee or not. */
boost::signals2::signal<bool (int64 nFeeRequired), boost::signals2::last_value<bool> > ThreadSafeAskFee;
diff --git a/src/util.cpp b/src/util.cpp
index d8f05cb9fd..4eff6ce71b 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -1218,9 +1218,14 @@ void SetMockTime(int64 nMockTimeIn)
static int64 nTimeOffset = 0;
+int64 GetTimeOffset()
+{
+ return nTimeOffset;
+}
+
int64 GetAdjustedTime()
{
- return GetTime() + nTimeOffset;
+ return GetTime() + GetTimeOffset();
}
void AddTimeData(const CNetAddr& ip, int64 nTime)
@@ -1276,12 +1281,26 @@ void AddTimeData(const CNetAddr& ip, int64 nTime)
}
}
-
-
-
-
-
-
+uint32_t insecure_rand_Rz = 11;
+uint32_t insecure_rand_Rw = 11;
+void seed_insecure_rand(bool fDeterministic)
+{
+ //The seed values have some unlikely fixed points which we avoid.
+ if(fDeterministic)
+ {
+ insecure_rand_Rz = insecure_rand_Rw = 11;
+ } else {
+ uint32_t tmp;
+ do{
+ RAND_bytes((unsigned char*)&tmp,4);
+ }while(tmp==0 || tmp==0x9068ffffU);
+ insecure_rand_Rz=tmp;
+ do{
+ RAND_bytes((unsigned char*)&tmp,4);
+ }while(tmp==0 || tmp==0x464fffffU);
+ insecure_rand_Rw=tmp;
+ }
+}
string FormatVersion(int nVersion)
{
diff --git a/src/util.h b/src/util.h
index 97911d7493..a6b88206e9 100644
--- a/src/util.h
+++ b/src/util.h
@@ -212,6 +212,7 @@ uint256 GetRandHash();
int64 GetTime();
void SetMockTime(int64 nMockTimeIn);
int64 GetAdjustedTime();
+int64 GetTimeOffset();
std::string FormatFullVersion();
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
void AddTimeData(const CNetAddr& ip, int64 nTime);
@@ -403,13 +404,27 @@ bool SoftSetArg(const std::string& strArg, const std::string& strValue);
*/
bool SoftSetBoolArg(const std::string& strArg, bool fValue);
+/**
+ * MWC RNG of George Marsaglia
+ * This is intended to be fast. It has a period of 2^59.3, though the
+ * least significant 16 bits only have a period of about 2^30.1.
+ *
+ * @return random value
+ */
+extern uint32_t insecure_rand_Rz;
+extern uint32_t insecure_rand_Rw;
+static inline uint32_t insecure_rand(void)
+{
+ insecure_rand_Rz=36969*(insecure_rand_Rz&65535)+(insecure_rand_Rz>>16);
+ insecure_rand_Rw=18000*(insecure_rand_Rw&65535)+(insecure_rand_Rw>>16);
+ return (insecure_rand_Rw<<16)+insecure_rand_Rz;
+}
-
-
-
-
-
-
+/**
+ * Seed insecure_rand using the random pool.
+ * @param Deterministic Use a determinstic seed
+ */
+void seed_insecure_rand(bool fDeterministic=false);
/** Median filter over a stream of values.
* Returns the median of the last N numbers
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 2317ac31ac..eecb7d2d22 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -8,6 +8,7 @@
#include "crypter.h"
#include "ui_interface.h"
#include "base58.h"
+#include <boost/algorithm/string/replace.hpp>
using namespace std;
@@ -476,6 +477,16 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn)
// Notify UI of new or updated transaction
NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED);
+
+ // notify an external script when a wallet transaction comes in or is updated
+ std::string strCmd = GetArg("-walletnotify", "");
+
+ if ( !strCmd.empty())
+ {
+ boost::replace_all(strCmd, "%s", wtxIn.GetHash().GetHex());
+ boost::thread t(runCommand, strCmd); // thread runs free
+ }
+
}
return true;
}
@@ -973,6 +984,8 @@ static void ApproximateBestSubset(vector<pair<int64, pair<const CWalletTx*,unsig
vfBest.assign(vValue.size(), true);
nBest = nTotalLower;
+ seed_insecure_rand();
+
for (int nRep = 0; nRep < iterations && nBest != nTargetValue; nRep++)
{
vfIncluded.assign(vValue.size(), false);
@@ -982,7 +995,13 @@ static void ApproximateBestSubset(vector<pair<int64, pair<const CWalletTx*,unsig
{
for (unsigned int i = 0; i < vValue.size(); i++)
{
- if (nPass == 0 ? rand() % 2 : !vfIncluded[i])
+ //The solver here uses a randomized algorithm,
+ //the randomness serves no real security purpose but is just
+ //needed to prevent degenerate behavior and it is important
+ //that the rng fast. We do not use a constant random sequence,
+ //because there may be some privacy improvement by making
+ //the selection random.
+ if (nPass == 0 ? insecure_rand()&1 : !vfIncluded[i])
{
nTotal += vValue[i].first;
vfIncluded[i] = true;