aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml5
-rw-r--r--CONTRIBUTING.md1
-rw-r--r--README.md2
-rw-r--r--configure.ac23
-rw-r--r--doc/README.md3
-rw-r--r--doc/build-openbsd.md163
-rw-r--r--doc/build-unix.md2
-rw-r--r--doc/translation_process.md2
-rwxr-xr-xqa/pull-tester/rpc-tests.sh6
-rwxr-xr-xqa/rpc-tests/zmq_test.py2
-rw-r--r--src/Makefile.am23
-rw-r--r--src/Makefile.qt.include2
-rw-r--r--src/Makefile.qttest.include2
-rw-r--r--src/Makefile.test.include3
-rw-r--r--src/bitcoin-cli.cpp2
-rw-r--r--src/bitcoin-tx.cpp2
-rw-r--r--src/chainparams.cpp3
-rw-r--r--src/chainparams.h2
-rw-r--r--src/core_read.cpp2
-rw-r--r--src/core_write.cpp2
-rw-r--r--src/main.cpp18
-rw-r--r--src/policy/policy.cpp4
-rw-r--r--src/qt/rpcconsole.cpp2
-rw-r--r--src/rest.cpp2
-rw-r--r--src/rpcblockchain.cpp2
-rw-r--r--src/rpcclient.cpp2
-rw-r--r--src/rpcclient.h2
-rw-r--r--src/rpcmining.cpp2
-rw-r--r--src/rpcmisc.cpp2
-rw-r--r--src/rpcnet.cpp2
-rw-r--r--src/rpcprotocol.h2
-rw-r--r--src/rpcrawtransaction.cpp2
-rw-r--r--src/rpcserver.cpp2
-rw-r--r--src/rpcserver.h2
-rw-r--r--src/script/script.cpp10
-rw-r--r--src/script/script.h2
-rw-r--r--src/script/standard.cpp23
-rw-r--r--src/script/standard.h2
-rw-r--r--src/test/base58_tests.cpp2
-rw-r--r--src/test/rpc_tests.cpp2
-rw-r--r--src/test/rpc_wallet_tests.cpp2
-rw-r--r--src/test/script_tests.cpp2
-rw-r--r--src/test/sighash_tests.cpp2
-rw-r--r--src/test/transaction_tests.cpp23
-rw-r--r--src/test/univalue_tests.cpp2
-rw-r--r--src/univalue/.gitignore22
-rw-r--r--src/univalue/.travis.yml52
-rw-r--r--src/univalue/COPYING19
-rw-r--r--src/univalue/Makefile.am84
-rw-r--r--src/univalue/README7
-rw-r--r--src/univalue/TODO10
-rwxr-xr-xsrc/univalue/autogen.sh9
-rw-r--r--src/univalue/build-aux/m4/.empty0
-rw-r--r--src/univalue/configure.ac69
-rw-r--r--src/univalue/gen/gen.cpp (renamed from src/univalue/gen.cpp)0
-rw-r--r--src/univalue/include/univalue.h (renamed from src/univalue/univalue.h)8
-rw-r--r--src/univalue/lib/.gitignore10
-rw-r--r--src/univalue/lib/univalue.cpp (renamed from src/univalue/univalue.cpp)66
-rw-r--r--src/univalue/lib/univalue_escapes.h (renamed from src/univalue/univalue_escapes.h)0
-rw-r--r--src/univalue/lib/univalue_read.cpp (renamed from src/univalue/univalue_read.cpp)0
-rw-r--r--src/univalue/lib/univalue_write.cpp (renamed from src/univalue/univalue_write.cpp)0
-rw-r--r--src/univalue/pc/libunivalue-uninstalled.pc.in9
-rw-r--r--src/univalue/pc/libunivalue.pc.in10
-rw-r--r--src/univalue/test/.gitignore7
-rw-r--r--src/univalue/test/fail1.json1
-rw-r--r--src/univalue/test/fail10.json1
-rw-r--r--src/univalue/test/fail11.json1
-rw-r--r--src/univalue/test/fail12.json1
-rw-r--r--src/univalue/test/fail13.json1
-rw-r--r--src/univalue/test/fail14.json1
-rw-r--r--src/univalue/test/fail15.json1
-rw-r--r--src/univalue/test/fail16.json1
-rw-r--r--src/univalue/test/fail17.json1
-rw-r--r--src/univalue/test/fail18.json1
-rw-r--r--src/univalue/test/fail19.json1
-rw-r--r--src/univalue/test/fail2.json1
-rw-r--r--src/univalue/test/fail20.json1
-rw-r--r--src/univalue/test/fail21.json1
-rw-r--r--src/univalue/test/fail22.json1
-rw-r--r--src/univalue/test/fail23.json1
-rw-r--r--src/univalue/test/fail24.json1
-rw-r--r--src/univalue/test/fail25.json1
-rw-r--r--src/univalue/test/fail26.json1
-rw-r--r--src/univalue/test/fail27.json2
-rw-r--r--src/univalue/test/fail28.json2
-rw-r--r--src/univalue/test/fail29.json1
-rw-r--r--src/univalue/test/fail3.json1
-rw-r--r--src/univalue/test/fail30.json1
-rw-r--r--src/univalue/test/fail31.json1
-rw-r--r--src/univalue/test/fail32.json1
-rw-r--r--src/univalue/test/fail33.json1
-rw-r--r--src/univalue/test/fail34.json1
-rw-r--r--src/univalue/test/fail4.json1
-rw-r--r--src/univalue/test/fail5.json1
-rw-r--r--src/univalue/test/fail6.json1
-rw-r--r--src/univalue/test/fail7.json1
-rw-r--r--src/univalue/test/fail8.json1
-rw-r--r--src/univalue/test/fail9.json1
-rw-r--r--src/univalue/test/pass1.json58
-rw-r--r--src/univalue/test/pass2.json1
-rw-r--r--src/univalue/test/pass3.json6
-rw-r--r--src/univalue/test/unitester.cpp115
-rw-r--r--src/validationinterface.h5
-rw-r--r--src/wallet/rpcdump.cpp2
-rw-r--r--src/wallet/rpcwallet.cpp2
-rw-r--r--src/wallet/wallet.cpp11
-rw-r--r--src/zmq/zmqabstractnotifier.cpp2
-rw-r--r--src/zmq/zmqabstractnotifier.h4
-rw-r--r--src/zmq/zmqnotificationinterface.cpp4
-rw-r--r--src/zmq/zmqnotificationinterface.h3
-rw-r--r--src/zmq/zmqpublishnotifier.cpp12
-rw-r--r--src/zmq/zmqpublishnotifier.h6
112 files changed, 892 insertions, 127 deletions
diff --git a/.travis.yml b/.travis.yml
index c8785144ad..3e7077ab26 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -33,11 +33,11 @@ matrix:
- compiler: ": Win32"
env: HOST=i686-w64-mingw32 PPA="ppa:ubuntu-wine/ppa" PACKAGES="nsis gcc-mingw-w64-i686 g++-mingw-w64-i686 binutils-mingw-w64-i686 mingw-w64-dev wine1.7 bc" RUN_TESTS=true GOAL="deploy" BITCOIN_CONFIG="--enable-gui --enable-reduce-exports" MAKEJOBS="-j2"
- compiler: ": 32-bit + dash"
- env: HOST=i686-pc-linux-gnu PACKAGES="g++-multilib bc" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports LDFLAGS=-static-libstdc++" USE_SHELL="/bin/dash"
+ env: HOST=i686-pc-linux-gnu PACKAGES="g++-multilib bc python-zmq" PPA="ppa:chris-lea/zeromq" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports LDFLAGS=-static-libstdc++" USE_SHELL="/bin/dash"
- compiler: ": Win64"
env: HOST=x86_64-w64-mingw32 PPA="ppa:ubuntu-wine/ppa" PACKAGES="nsis gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-dev wine1.7 bc" RUN_TESTS=true GOAL="deploy" BITCOIN_CONFIG="--enable-gui --enable-reduce-exports" MAKEJOBS="-j2"
- compiler: ": bitcoind"
- env: HOST=x86_64-unknown-linux-gnu PACKAGES="bc" DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports CPPFLAGS=-DDEBUG_LOCKORDER"
+ env: HOST=x86_64-unknown-linux-gnu PACKAGES="bc python-zmq" PPA="ppa:chris-lea/zeromq" DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports CPPFLAGS=-DDEBUG_LOCKORDER"
- compiler: ": No wallet"
env: HOST=x86_64-unknown-linux-gnu DEP_OPTS="NO_WALLET=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
- compiler: ": Cross-Mac"
@@ -45,6 +45,7 @@ matrix:
exclude:
- compiler: gcc
install:
+ - if [ -n "$PACKAGES" ]; then sudo rm -f /etc/apt/sources.list.d/travis_ci_zeromq3-source.list; fi
- if [ -n "$PPA" ]; then travis_retry sudo add-apt-repository "$PPA" -y; fi
- if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get update; fi
- if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get install --no-install-recommends --no-upgrade -qq $PACKAGES; fi
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 572d166b74..1d42dea843 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -35,6 +35,7 @@ The title of the pull request should be prefixed by the component or area that t
Consensus: Add new opcode for BIP-XXXX OP_CHECKAWESOMESIG
Net: Automatically create hidden service, listen on Tor
Qt: Add feed bump button
+ Trivial: fix typo
If a pull request is specifically not to be considered for merging (yet) please prefix the title with [WIP] or use [Tasks Lists](https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments) in the body of the pull request to indicate tasks are pending.
diff --git a/README.md b/README.md
index baf0457418..275367ebbb 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,7 @@ The developer [mailing list](https://lists.linuxfoundation.org/mailman/listinfo/
should be used to discuss complicated or controversial changes before working
on a patch set.
-Developer IRC can be found on Freenode at #bitcoin-dev.
+Developer IRC can be found on Freenode at #bitcoin-core-dev.
Testing
-------
diff --git a/configure.ac b/configure.ac
index ad3903f14a..ff2c7ab4e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -700,27 +700,12 @@ else
fi
fi
-CFLAGS_TEMP="$CFLAGS"
+CXXFLAGS_TEMP="$CXXFLAGS"
LIBS_TEMP="$LIBS"
-CFLAGS="$CFLAGS $SSL_CFLAGS $CRYPTO_CFLAGS"
+CXXFLAGS="$CXXFLAGS $SSL_CFLAGS $CRYPTO_CFLAGS"
LIBS="$LIBS $SSL_LIBS $CRYPTO_LIBS"
AC_CHECK_HEADER([openssl/ec.h],, AC_MSG_ERROR(OpenSSL ec header missing),)
-
-AC_MSG_CHECKING(for a supported OpenSSL version)
-AC_LINK_IFELSE([AC_LANG_PROGRAM([[
- #include <openssl/rand.h>
- ]],
- [[RAND_egd(NULL);]])],
- [AC_MSG_RESULT(yes)],
- [
- AC_ARG_WITH([libressl],
- [AS_HELP_STRING([--with-libressl],[Build with system LibreSSL (default is no; DANGEROUS; NOT SUPPORTED)])],
- [AC_MSG_WARN([Detected LibreSSL: This is NOT supported, and may break consensus compatibility!])],
- [AC_MSG_ERROR([Detected LibreSSL: This is NOT supported, and may break consensus compatibility!])]
- )]
-)
-
-CFLAGS="$CFLAGS_TEMP"
+CXXFLAGS="$CXXFLAGS_TEMP"
LIBS="$LIBS_TEMP"
BITCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path)
@@ -940,7 +925,7 @@ unset PKG_CONFIG_LIBDIR
PKG_CONFIG_LIBDIR="$PKGCONFIG_LIBDIR_TEMP"
ac_configure_args="${ac_configure_args} --disable-shared --with-pic --with-bignum=no"
-AC_CONFIG_SUBDIRS([src/secp256k1])
+AC_CONFIG_SUBDIRS([src/secp256k1 src/univalue])
AC_OUTPUT
diff --git a/doc/README.md b/doc/README.md
index 7b0c39d383..3e3f4a294f 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -64,7 +64,8 @@ The Bitcoin repo's [root README](https://github.com/bitcoin/bitcoin/blob/master/
### Resources
* Discuss on the [BitcoinTalk](https://bitcointalk.org/) forums, in the [Development & Technical Discussion board](https://bitcointalk.org/index.php?board=6.0).
-* Discuss on [#bitcoin-dev](http://webchat.freenode.net/?channels=bitcoin) on Freenode. If you don't have an IRC client use [webchat here](http://webchat.freenode.net/?channels=bitcoin-dev).
+* Discuss project-specific development on #bitcoin-core-dev on Freenode. If you don't have an IRC client use [webchat here](http://webchat.freenode.net/?channels=bitcoin-core-dev).
+* Discuss general Bitcoin development on #bitcoin-dev on Freenode. If you don't have an IRC client use [webchat here](http://webchat.freenode.net/?channels=bitcoin-dev).
### Miscellaneous
- [Assets Attribution](assets-attribution.md)
diff --git a/doc/build-openbsd.md b/doc/build-openbsd.md
new file mode 100644
index 0000000000..a26b52465e
--- /dev/null
+++ b/doc/build-openbsd.md
@@ -0,0 +1,163 @@
+OpenBSD build guide
+======================
+(updated for OpenBSD 5.7)
+
+This guide describes how to build bitcoind and command-line utilities on OpenBSD.
+
+As OpenBSD is most common as a server OS, we will not bother with the GUI.
+
+Preparation
+-------------
+
+Run the following as root to install the base dependencies for building:
+
+```bash
+pkg_add gmake libtool libevent
+pkg_add autoconf # (select highest version, e.g. 2.69)
+pkg_add automake # (select highest version, e.g. 1.15)
+pkg_add python # (select version 2.7.x, not 3.x)
+ln -sf /usr/local/bin/python2.7 /usr/local/bin/python2
+```
+
+The default C++ compiler that comes with OpenBSD 5.7 is g++ 4.2. This version is old (from 2007), and is not able to compile the current version of Bitcoin Core. It is possible to patch it up to compile, but with the planned transition to C++11 this is a losing battle. So here we will be installing a newer compiler.
+
+GCC
+-------
+
+You can install a newer version of gcc with:
+
+```bash
+pkg_add g++ # (select newest 4.x version, e.g. 4.9.2)
+```
+
+This compiler will not overwrite the system compiler, it will be installed as `egcc` and `eg++` in `/usr/local/bin`.
+
+### Building boost
+
+Do not use `pkg_add boost`! The boost version installed thus is compiled using the `g++` compiler not `eg++`, which will result in a conflict between `/usr/local/lib/libestdc++.so.XX.0` and `/usr/lib/libstdc++.so.XX.0`, resulting in a test crash:
+
+ test_bitcoin:/usr/lib/libstdc++.so.57.0: /usr/local/lib/libestdc++.so.17.0 : WARNING: symbol(_ZN11__gnu_debug17_S_debug_me ssagesE) size mismatch, relink your program
+ ...
+ Segmentation fault (core dumped)
+
+This makes it necessary to build boost, or at least the parts used by Bitcoin Core, manually:
+
+```
+# Pick some path to install boost to, here we create a directory within the bitcoin directory
+BITCOIN_ROOT=$(pwd)
+BOOST_PREFIX="${BITCOIN_ROOT}/boost"
+mkdir -p $BOOST_PREFIX
+
+# Fetch the source and verify that it is not tampered with
+wget http://heanet.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.bz2
+echo '727a932322d94287b62abb1bd2d41723eec4356a7728909e38adb65ca25241ca boost_1_59_0.tar.bz2' | sha256 -c
+# MUST output: (SHA256) boost_1_59_0.tar.bz2: OK
+tar -xjf boost_1_59_0.tar.bz2
+
+# Boost 1.59 needs two small patches for OpenBSD
+cd boost_1_59_0
+# Also here: https://gist.githubusercontent.com/laanwj/bf359281dc319b8ff2e1/raw/92250de8404b97bb99d72ab898f4a8cb35ae1ea3/patch-boost_test_impl_execution_monitor_ipp.patch
+patch -p0 < /usr/ports/devel/boost/patches/patch-boost_test_impl_execution_monitor_ipp
+# https://github.com/boostorg/filesystem/commit/90517e459681790a091566dce27ca3acabf9a70c
+sed 's/__OPEN_BSD__/__OpenBSD__/g' < libs/filesystem/src/path.cpp > libs/filesystem/src/path.cpp.tmp
+mv libs/filesystem/src/path.cpp.tmp libs/filesystem/src/path.cpp
+
+# Build w/ minimum configuration necessary for bitcoin
+echo 'using gcc : : eg++ : <cxxflags>"-fvisibility=hidden -fPIC" <linkflags>"" <archiver>"ar" <striper>"strip" <ranlib>"ranlib" <rc>"" : ;' > user-config.jam
+config_opts="runtime-link=shared threadapi=pthread threading=multi link=static variant=release --layout=tagged --build-type=complete --user-config=user-config.jam -sNO_BZIP2=1"
+./bootstrap.sh --without-icu --with-libraries=chrono,filesystem,program_options,system,thread,test
+./b2 -d2 -j2 -d1 ${config_opts} --prefix=${BOOST_PREFIX} stage
+./b2 -d0 -j4 ${config_opts} --prefix=${BOOST_PREFIX} install
+```
+
+### Building BerkeleyDB
+
+BerkeleyDB is only necessary for the wallet functionality. To skip this, pass `--disable-wallet` to `./configure`.
+
+See "Berkeley DB" in [build_unix.md](build_unix.md) for instructions on how to build BerkeleyDB 4.8.
+You cannot use the BerkeleyDB library from ports, for the same reason as boost above (g++/libstd++ incompatibility).
+
+```bash
+# Pick some path to install BDB to, here we create a directory within the bitcoin directory
+BITCOIN_ROOT=$(pwd)
+BDB_PREFIX="${BITCOIN_ROOT}/db4"
+mkdir -p $BDB_PREFIX
+
+# Fetch the source and verify that it is not tampered with
+wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
+echo '12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef db-4.8.30.NC.tar.gz' | sha256 -c
+# MUST output: (SHA256) db-4.8.30.NC.tar.gz: OK
+tar -xzf db-4.8.30.NC.tar.gz
+
+# Build the library and install to specified prefix
+cd db-4.8.30.NC/build_unix/
+# Note: Do a static build so that it can be embedded into the executable, instead of having to find a .so at runtime
+../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX CC=egcc CXX=eg++ CPP=ecpp
+make install
+```
+
+### Building Bitcoin Core
+
+**Important**: use `gmake`, not `make`. The non-GNU `make` will exit with a horrible error.
+
+Preparation:
+```bash
+export AUTOCONF_VERSION=2.69 # replace this with the autoconf version that you installed
+export AUTOMAKE_VERSION=1.15 # replace this with the automake version that you installed
+./autogen.sh
+```
+Make sure `BDB_PREFIX` and `BOOST_PREFIX` are set to the appropriate paths from the above steps.
+
+To configure with wallet:
+```bash
+./configure --with-gui=no --with-boost=$BOOST_PREFIX \
+ CC=egcc CXX=eg++ CPP=ecpp \
+ LDFLAGS="-L${BDB_PREFIX}/lib/" CPPFLAGS="-I${BDB_PREFIX}/include/"
+```
+
+To configure without wallet:
+```bash
+./configure --disable-wallet --with-gui=no --with-boost=$BOOST_PREFIX \
+ CC=egcc CXX=eg++ CPP=ecpp
+```
+
+Build and run the tests:
+```bash
+gmake
+gmake check
+```
+
+Clang (not currently working)
+------------------------------
+
+Using a newer g++ results in linking the new code to a new libstdc++.
+Libraries built with the old g++, will still import the old library.
+This gives conflicts, necessitating rebuild of all C++ dependencies of the application.
+
+With clang this can - at least theoretically - be avoided because it uses the
+base system's libstdc++.
+
+```bash
+pkg_add llvm boost
+```
+
+```bash
+./configure --disable-wallet --with-gui=no CC=clang CXX=clang++
+gmake
+```
+
+However, this does not appear to work. Compilation succeeds, but link fails
+with many 'local symbol discarded' errors:
+
+ local symbol 150: discarded in section `.text._ZN10tinyformat6detail14FormatIterator6finishEv' from libbitcoin_util.a(libbitcoin_util_a-random.o)
+ local symbol 151: discarded in section `.text._ZN10tinyformat6detail14FormatIterator21streamStateFromFormatERSoRjPKcii' from libbitcoin_util.a(libbitcoin_util_a-random.o)
+ local symbol 152: discarded in section `.text._ZN10tinyformat6detail12convertToIntIA13_cLb0EE6invokeERA13_Kc' from libbitcoin_util.a(libbitcoin_util_a-random.o)
+
+According to similar reported errors this is a binutils (ld) issue in 2.15, the
+version installed by OpenBSD 5.7:
+
+- http://openbsd-archive.7691.n7.nabble.com/UPDATE-cppcheck-1-65-td248900.html
+- https://llvm.org/bugs/show_bug.cgi?id=9758
+
+There is no known workaround for this.
+
diff --git a/doc/build-unix.md b/doc/build-unix.md
index 39f75e6b8d..a9a0028c4a 100644
--- a/doc/build-unix.md
+++ b/doc/build-unix.md
@@ -2,6 +2,8 @@ UNIX BUILD NOTES
====================
Some notes on how to build Bitcoin in Unix.
+(for OpenBSD specific instructions, see [build-openbsd.md](build-openbsd.md))
+
Note
---------------------
Always use absolute paths to configure and compile bitcoin and the dependencies,
diff --git a/doc/translation_process.md b/doc/translation_process.md
index 3653e53021..b06975e1d8 100644
--- a/doc/translation_process.md
+++ b/doc/translation_process.md
@@ -106,6 +106,6 @@ To create a new language template, you will need to edit the languages manifest
**Note:** that the language translation file **must end in `.qm`** (the compiled extension), and not `.ts`.
### Questions and general assistance
-The Bitcoin-Core translation maintainers include *tcatm, seone, Diapolo, wumpus and luke-jr*.You can find them, and others, in the Freenode IRC chatroom - `irc.freenode.net #bitcoin-dev`.
+The Bitcoin-Core translation maintainers include *tcatm, seone, Diapolo, wumpus and luke-jr*. You can find them, and others, in the Freenode IRC chatroom - `irc.freenode.net #bitcoin-core-dev`.
If you are a translator, you should also subscribe to the mailing list, https://groups.google.com/forum/#!forum/bitcoin-translators. Announcements will be posted during application pre-releases to notify translators to check for updates.
diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh
index 2e8a7c69ce..7e1d2e8e50 100755
--- a/qa/pull-tester/rpc-tests.sh
+++ b/qa/pull-tester/rpc-tests.sh
@@ -60,9 +60,9 @@ testScriptsExt=(
'mempool_packages.py'
);
-#if [ "x$ENABLE_ZMQ" = "x1" ]; then
-# testScripts+=('zmq_test.py')
-#fi
+if [ "x$ENABLE_ZMQ" = "x1" ]; then
+ testScripts+=('zmq_test.py')
+fi
extArg="-extended"
passOn=${@#$extArg}
diff --git a/qa/rpc-tests/zmq_test.py b/qa/rpc-tests/zmq_test.py
index fffaf677d6..bcb132321a 100755
--- a/qa/rpc-tests/zmq_test.py
+++ b/qa/rpc-tests/zmq_test.py
@@ -32,8 +32,6 @@ class ZMQTest (BitcoinTestFramework):
self.zmqSubSocket.setsockopt(zmq.SUBSCRIBE, "hashblock")
self.zmqSubSocket.setsockopt(zmq.SUBSCRIBE, "hashtx")
self.zmqSubSocket.connect("tcp://127.0.0.1:%i" % self.port)
- # Note: proxies are not used to connect to local nodes
- # this is because the proxy to use is based on CService.GetNetwork(), which return NET_UNROUTABLE for localhost
return start_nodes(4, self.options.tmpdir, extra_args=[
['-zmqpubhashtx=tcp://127.0.0.1:'+str(self.port), '-zmqpubhashblock=tcp://127.0.0.1:'+str(self.port)],
[],
diff --git a/src/Makefile.am b/src/Makefile.am
index 7fdc766e1c..462774389a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-DIST_SUBDIRS = secp256k1
+DIST_SUBDIRS = secp256k1 univalue
AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS)
@@ -21,6 +21,7 @@ BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config
BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS)
BITCOIN_INCLUDES += -I$(srcdir)/secp256k1/include
+BITCOIN_INCLUDES += -I$(srcdir)/univalue/include
LIBBITCOIN_SERVER=libbitcoin_server.a
LIBBITCOIN_WALLET=libbitcoin_wallet.a
@@ -28,12 +29,15 @@ LIBBITCOIN_COMMON=libbitcoin_common.a
LIBBITCOIN_CLI=libbitcoin_cli.a
LIBBITCOIN_UTIL=libbitcoin_util.a
LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a
-LIBBITCOIN_UNIVALUE=univalue/libbitcoin_univalue.a
LIBBITCOINQT=qt/libbitcoinqt.a
LIBSECP256K1=secp256k1/libsecp256k1.la
+LIBUNIVALUE=univalue/lib/libunivalue.la
$(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*)
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)
+
+$(LIBUNIVALUE): $(wildcard univalue/lib/*)
+ $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue/
# Make is not made aware of per-object dependencies to avoid limiting building parallelization
# But to build the less dependent modules first, we manually select their order here:
@@ -41,7 +45,6 @@ EXTRA_LIBRARIES = \
crypto/libbitcoin_crypto.a \
libbitcoin_util.a \
libbitcoin_common.a \
- univalue/libbitcoin_univalue.a \
libbitcoin_server.a \
libbitcoin_cli.a
if ENABLE_WALLET
@@ -248,14 +251,6 @@ crypto_libbitcoin_crypto_a_SOURCES = \
crypto/sha512.cpp \
crypto/sha512.h
-# univalue JSON library
-univalue_libbitcoin_univalue_a_SOURCES = \
- univalue/univalue.cpp \
- univalue/univalue.h \
- univalue/univalue_escapes.h \
- univalue/univalue_read.cpp \
- univalue/univalue_write.cpp
-
# common: shared between bitcoind, and bitcoin-qt and non-server tools
libbitcoin_common_a_CPPFLAGS = $(BITCOIN_INCLUDES)
libbitcoin_common_a_SOURCES = \
@@ -332,7 +327,7 @@ endif
bitcoind_LDADD = \
$(LIBBITCOIN_SERVER) \
$(LIBBITCOIN_COMMON) \
- $(LIBBITCOIN_UNIVALUE) \
+ $(LIBUNIVALUE) \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_CRYPTO) \
$(LIBLEVELDB) \
@@ -360,7 +355,7 @@ endif
bitcoin_cli_LDADD = \
$(LIBBITCOIN_CLI) \
- $(LIBBITCOIN_UNIVALUE) \
+ $(LIBUNIVALUE) \
$(LIBBITCOIN_UTIL)
bitcoin_cli_LDADD += $(BOOST_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_LIBS)
@@ -376,7 +371,7 @@ bitcoin_tx_SOURCES += bitcoin-tx-res.rc
endif
bitcoin_tx_LDADD = \
- $(LIBBITCOIN_UNIVALUE) \
+ $(LIBUNIVALUE) \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_CRYPTO) \
diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include
index 3330ed2890..67fd7c1076 100644
--- a/src/Makefile.qt.include
+++ b/src/Makefile.qt.include
@@ -367,7 +367,7 @@ endif
if ENABLE_ZMQ
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
endif
-qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
+qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
$(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
qt_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include
index 6554580bea..b8725c872d 100644
--- a/src/Makefile.qttest.include
+++ b/src/Makefile.qttest.include
@@ -33,7 +33,7 @@ endif
if ENABLE_ZMQ
qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
endif
-qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) \
+qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) \
$(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \
$(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
diff --git a/src/Makefile.test.include b/src/Makefile.test.include
index cee35926a5..9a6e43631b 100644
--- a/src/Makefile.test.include
+++ b/src/Makefile.test.include
@@ -91,7 +91,7 @@ endif
test_test_bitcoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
test_test_bitcoin_CPPFLAGS = $(BITCOIN_INCLUDES) -I$(builddir)/test/ $(TESTDEFS)
-test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
+test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
$(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1)
if ENABLE_WALLET
test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET)
@@ -124,6 +124,7 @@ check-local:
@echo "Running test/bitcoin-util-test.py..."
$(AM_V_at)srcdir=$(srcdir) PYTHONPATH=$(builddir)/test $(srcdir)/test/bitcoin-util-test.py
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
+ $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check
%.json.h: %.json
@$(MKDIR_P) $(@D)
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index 7839b3b6b4..e0fe6aa5bf 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -18,7 +18,7 @@
#include <event2/buffer.h>
#include <event2/keyvalq_struct.h>
-#include "univalue/univalue.h"
+#include <univalue.h>
using namespace std;
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp
index 5beab265bc..f7518fab5d 100644
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -12,7 +12,7 @@
#include "primitives/transaction.h"
#include "script/script.h"
#include "script/sign.h"
-#include "univalue/univalue.h"
+#include <univalue.h>
#include "util.h"
#include "utilmoneystr.h"
#include "utilstrencodings.h"
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 15b86cdda6..430b75683b 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -87,6 +87,7 @@ public:
pchMessageStart[3] = 0xd9;
vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
nDefaultPort = 8333;
+ nMaxTipAge = 24 * 60 * 60;
nPruneAfterHeight = 100000;
genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
@@ -160,6 +161,7 @@ public:
pchMessageStart[3] = 0x07;
vAlertPubKey = ParseHex("04302390343f91cc401d56d68b123028bf52e5fca1939df127f63c6467cdf9c8e2c14b61104cf817d0b780da337893ecc4aaff1309e536162dabbdb45200ca2b0a");
nDefaultPort = 18333;
+ nMaxTipAge = 0x7fffffff;
nPruneAfterHeight = 1000;
genesis = CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50 * COIN);
@@ -220,6 +222,7 @@ public:
pchMessageStart[1] = 0xbf;
pchMessageStart[2] = 0xb5;
pchMessageStart[3] = 0xda;
+ nMaxTipAge = 24 * 60 * 60;
nDefaultPort = 18444;
nPruneAfterHeight = 1000;
diff --git a/src/chainparams.h b/src/chainparams.h
index 5db39aa09c..342bccb12f 100644
--- a/src/chainparams.h
+++ b/src/chainparams.h
@@ -64,6 +64,7 @@ public:
bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
/** Policy: Filter transactions that do not match well-defined patterns */
bool RequireStandard() const { return fRequireStandard; }
+ int64_t MaxTipAge() const { return nMaxTipAge; }
int64_t PruneAfterHeight() const { return nPruneAfterHeight; }
/** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
@@ -83,6 +84,7 @@ protected:
//! Raw pub key bytes for the broadcast alert signing key.
std::vector<unsigned char> vAlertPubKey;
int nDefaultPort;
+ long nMaxTipAge;
uint64_t nPruneAfterHeight;
std::vector<CDNSSeedData> vSeeds;
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
diff --git a/src/core_read.cpp b/src/core_read.cpp
index f762f2c3b7..4be24f8e09 100644
--- a/src/core_read.cpp
+++ b/src/core_read.cpp
@@ -9,7 +9,7 @@
#include "script/script.h"
#include "serialize.h"
#include "streams.h"
-#include "univalue/univalue.h"
+#include <univalue.h>
#include "util.h"
#include "utilstrencodings.h"
#include "version.h"
diff --git a/src/core_write.cpp b/src/core_write.cpp
index 2ad42baddf..533fedfe7a 100644
--- a/src/core_write.cpp
+++ b/src/core_write.cpp
@@ -10,7 +10,7 @@
#include "script/standard.h"
#include "serialize.h"
#include "streams.h"
-#include "univalue/univalue.h"
+#include <univalue.h>
#include "util.h"
#include "utilmoneystr.h"
#include "utilstrencodings.h"
diff --git a/src/main.cpp b/src/main.cpp
index 1df4c9fa36..5cfb05b0d2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1112,7 +1112,7 @@ bool IsInitialBlockDownload()
if (lockIBDState)
return false;
bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 ||
- pindexBestHeader->GetBlockTime() < GetTime() - 24 * 60 * 60);
+ pindexBestHeader->GetBlockTime() < GetTime() - chainParams.MaxTipAge());
if (!state)
lockIBDState = true;
return state;
@@ -2320,7 +2320,7 @@ bool ActivateBestChain(CValidationState &state, const CBlock *pblock) {
pnode->PushInventory(CInv(MSG_BLOCK, hashNewTip));
}
// Notify external listeners about the new tip.
- GetMainSignals().UpdatedBlockTip(hashNewTip);
+ GetMainSignals().UpdatedBlockTip(pindexNewTip);
uiInterface.NotifyBlockTip(hashNewTip);
}
} while(pindexMostWork != chainActive.Tip());
@@ -4280,6 +4280,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
mapAlreadyAskedFor.erase(inv);
+ // Check for recently rejected (and do other quick existence checks)
+ if (AlreadyHave(inv))
+ return true;
+
if (AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs))
{
mempool.check(pcoinsTip);
@@ -4355,13 +4359,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
if (nEvicted > 0)
LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted);
} else {
- // AcceptToMemoryPool() returned false, possibly because the tx is
- // already in the mempool; if the tx isn't in the mempool that
- // means it was rejected and we shouldn't ask for it again.
- if (!mempool.exists(tx.GetHash())) {
- assert(recentRejects);
- recentRejects->insert(tx.GetHash());
- }
+ assert(recentRejects);
+ recentRejects->insert(tx.GetHash());
+
if (pfrom->fWhitelisted) {
// Always relay transactions received from whitelisted peers, even
// if they were rejected from the mempool, allowing the node to
diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp
index 169fef4af4..4c96fbf5a5 100644
--- a/src/policy/policy.cpp
+++ b/src/policy/policy.cpp
@@ -49,7 +49,9 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType)
return false;
if (m < 1 || m > n)
return false;
- }
+ } else if (whichType == TX_NULL_DATA &&
+ (!GetBoolArg("-datacarrier", true) || scriptPubKey.size() > nMaxDatacarrierBytes))
+ return false;
return whichType != TX_NONSTANDARD;
}
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 72a3023c9a..f387a3ec8c 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -18,7 +18,7 @@
#include <openssl/crypto.h>
-#include "univalue/univalue.h"
+#include <univalue.h>
#ifdef ENABLE_WALLET
#include <db_cxx.h>
diff --git a/src/rest.cpp b/src/rest.cpp
index 226e237fc6..c46d7a8bd2 100644
--- a/src/rest.cpp
+++ b/src/rest.cpp
@@ -18,7 +18,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/dynamic_bitset.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
using namespace std;
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index 1c201ef99d..545ac12890 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -20,7 +20,7 @@
#include <stdint.h>
-#include "univalue/univalue.h"
+#include <univalue.h>
using namespace std;
diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp
index 0c8e6d6d66..4064c2fee3 100644
--- a/src/rpcclient.cpp
+++ b/src/rpcclient.cpp
@@ -12,7 +12,7 @@
#include <stdint.h>
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
-#include "univalue/univalue.h"
+#include <univalue.h>
using namespace std;
diff --git a/src/rpcclient.h b/src/rpcclient.h
index d68b4ed6ae..8937a56f03 100644
--- a/src/rpcclient.h
+++ b/src/rpcclient.h
@@ -6,7 +6,7 @@
#ifndef BITCOIN_RPCCLIENT_H
#define BITCOIN_RPCCLIENT_H
-#include "univalue/univalue.h"
+#include <univalue.h>
UniValue RPCConvertValues(const std::string& strMethod, const std::vector<std::string>& strParams);
/** Non-RFC4627 JSON parser, accepts internal values (such as numbers, true, false, null)
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index 8dd0ff2f7e..c49c3e5194 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -25,7 +25,7 @@
#include <boost/assign/list_of.hpp>
#include <boost/shared_ptr.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
using namespace std;
diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp
index e2b6d5826c..0f0457c5cf 100644
--- a/src/rpcmisc.cpp
+++ b/src/rpcmisc.cpp
@@ -22,7 +22,7 @@
#include <boost/assign/list_of.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
using namespace std;
diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp
index 5d490c70ca..7746be25f7 100644
--- a/src/rpcnet.cpp
+++ b/src/rpcnet.cpp
@@ -19,7 +19,7 @@
#include <boost/foreach.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
using namespace std;
diff --git a/src/rpcprotocol.h b/src/rpcprotocol.h
index 5381e4bcfd..9cf1ab6d99 100644
--- a/src/rpcprotocol.h
+++ b/src/rpcprotocol.h
@@ -12,7 +12,7 @@
#include <string>
#include <boost/filesystem.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
//! HTTP status codes
enum HTTPStatusCode
diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp
index fa3150cd7f..4dec53396d 100644
--- a/src/rpcrawtransaction.cpp
+++ b/src/rpcrawtransaction.cpp
@@ -31,7 +31,7 @@
#include <boost/assign/list_of.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
using namespace std;
diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp
index dbee61efc8..fa60f8c833 100644
--- a/src/rpcserver.cpp
+++ b/src/rpcserver.cpp
@@ -13,7 +13,7 @@
#include "util.h"
#include "utilstrencodings.h"
-#include "univalue/univalue.h"
+#include <univalue.h>
#include <boost/bind.hpp>
#include <boost/filesystem.hpp>
diff --git a/src/rpcserver.h b/src/rpcserver.h
index 83cc37918b..dde8dfdcc3 100644
--- a/src/rpcserver.h
+++ b/src/rpcserver.h
@@ -17,7 +17,7 @@
#include <boost/function.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
class CRPCCommand;
diff --git a/src/script/script.cpp b/src/script/script.cpp
index 58dbade0e2..9a0c067a33 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -144,7 +144,7 @@ const char* GetOpName(opcodetype opcode)
case OP_INVALIDOPCODE : return "OP_INVALIDOPCODE";
// Note:
- // The template matching params OP_SMALLDATA/etc are defined in opcodetype enum
+ // The template matching params OP_SMALLINTEGER/etc are defined in opcodetype enum
// as kind of implementation hack, they are *NOT* real opcodes. If found in real
// Script, just let the default: case deal with them.
@@ -210,9 +210,8 @@ bool CScript::IsPayToScriptHash() const
this->at(22) == OP_EQUAL);
}
-bool CScript::IsPushOnly() const
+bool CScript::IsPushOnly(const_iterator pc) const
{
- const_iterator pc = begin();
while (pc < end())
{
opcodetype opcode;
@@ -227,3 +226,8 @@ bool CScript::IsPushOnly() const
}
return true;
}
+
+bool CScript::IsPushOnly() const
+{
+ return this->IsPushOnly(begin());
+}
diff --git a/src/script/script.h b/src/script/script.h
index f0725bbbf6..cdc9a71bb2 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -167,7 +167,6 @@ enum opcodetype
// template matching params
- OP_SMALLDATA = 0xf9,
OP_SMALLINTEGER = 0xfa,
OP_PUBKEYS = 0xfb,
OP_PUBKEYHASH = 0xfd,
@@ -589,6 +588,7 @@ public:
bool IsPayToScriptHash() const;
/** Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical). */
+ bool IsPushOnly(const_iterator pc) const;
bool IsPushOnly() const;
/**
diff --git a/src/script/standard.cpp b/src/script/standard.cpp
index 1d5aac7b34..bfef8afa17 100644
--- a/src/script/standard.cpp
+++ b/src/script/standard.cpp
@@ -51,13 +51,10 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
// Sender provides N pubkeys, receivers provides M signatures
mTemplates.insert(make_pair(TX_MULTISIG, CScript() << OP_SMALLINTEGER << OP_PUBKEYS << OP_SMALLINTEGER << OP_CHECKMULTISIG));
-
- // Empty, provably prunable, data-carrying output
- if (GetBoolArg("-datacarrier", true))
- mTemplates.insert(make_pair(TX_NULL_DATA, CScript() << OP_RETURN << OP_SMALLDATA));
- mTemplates.insert(make_pair(TX_NULL_DATA, CScript() << OP_RETURN));
}
+ vSolutionsRet.clear();
+
// Shortcut for pay-to-script-hash, which are more constrained than the other types:
// it is always OP_HASH160 20 [20 byte hash] OP_EQUAL
if (scriptPubKey.IsPayToScriptHash())
@@ -68,6 +65,16 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
return true;
}
+ // Provably prunable, data-carrying output
+ //
+ // So long as script passes the IsUnspendable() test and all but the first
+ // byte passes the IsPushOnly() test we don't care what exactly is in the
+ // script.
+ if (scriptPubKey.size() >= 1 && scriptPubKey[0] == OP_RETURN && scriptPubKey.IsPushOnly(scriptPubKey.begin()+1)) {
+ typeRet = TX_NULL_DATA;
+ return true;
+ }
+
// Scan templates
const CScript& script1 = scriptPubKey;
BOOST_FOREACH(const PAIRTYPE(txnouttype, CScript)& tplate, mTemplates)
@@ -140,12 +147,6 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
else
break;
}
- else if (opcode2 == OP_SMALLDATA)
- {
- // small pushdata, <= nMaxDatacarrierBytes
- if (vch1.size() > nMaxDatacarrierBytes)
- break;
- }
else if (opcode1 != opcode2 || vch1 != vch2)
{
// Others must match exactly
diff --git a/src/script/standard.h b/src/script/standard.h
index 9e17dac700..ae1bbecca0 100644
--- a/src/script/standard.h
+++ b/src/script/standard.h
@@ -25,7 +25,7 @@ public:
CScriptID(const uint160& in) : uint160(in) {}
};
-static const unsigned int MAX_OP_RETURN_RELAY = 80; //! bytes
+static const unsigned int MAX_OP_RETURN_RELAY = 83; //! bytes (+1 for OP_RETURN, +2 for the pushdata opcodes)
extern unsigned nMaxDatacarrierBytes;
/**
diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp
index 9e74f5f427..9845df697f 100644
--- a/src/test/base58_tests.cpp
+++ b/src/test/base58_tests.cpp
@@ -18,7 +18,7 @@
#include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
extern UniValue read_json(const std::string& jsondata);
diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp
index 1bd59497ff..2a486f08e4 100644
--- a/src/test/rpc_tests.cpp
+++ b/src/test/rpc_tests.cpp
@@ -13,7 +13,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/test/unit_test.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
using namespace std;
diff --git a/src/test/rpc_wallet_tests.cpp b/src/test/rpc_wallet_tests.cpp
index 52f41be8ae..2e652f76e2 100644
--- a/src/test/rpc_wallet_tests.cpp
+++ b/src/test/rpc_wallet_tests.cpp
@@ -14,7 +14,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/test/unit_test.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
using namespace std;
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index 225da0801a..882f9eb199 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -27,7 +27,7 @@
#include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
using namespace std;
diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp
index 4b96461562..6fca64d5da 100644
--- a/src/test/sighash_tests.cpp
+++ b/src/test/sighash_tests.cpp
@@ -20,7 +20,7 @@
#include <boost/test/unit_test.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
extern UniValue read_json(const std::string& jsondata);
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
index e70ebddc2f..9847f6512e 100644
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -26,7 +26,7 @@
#include <boost/test/unit_test.hpp>
#include <boost/assign/list_of.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
using namespace std;
@@ -351,12 +351,29 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
t.vout[0].scriptPubKey = CScript() << OP_1;
BOOST_CHECK(!IsStandardTx(t, reason));
- // 80-byte TX_NULL_DATA (standard)
+ // MAX_OP_RETURN_RELAY-byte TX_NULL_DATA (standard)
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
+ BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY, t.vout[0].scriptPubKey.size());
BOOST_CHECK(IsStandardTx(t, reason));
- // 81-byte TX_NULL_DATA (non-standard)
+ // MAX_OP_RETURN_RELAY+1-byte TX_NULL_DATA (non-standard)
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3800");
+ BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY + 1, t.vout[0].scriptPubKey.size());
+ BOOST_CHECK(!IsStandardTx(t, reason));
+
+ // Data payload can be encoded in any way...
+ t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("");
+ BOOST_CHECK(IsStandardTx(t, reason));
+ t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("00") << ParseHex("01");
+ BOOST_CHECK(IsStandardTx(t, reason));
+ // OP_RESERVED *is* considered to be a PUSHDATA type opcode by IsPushOnly()!
+ t.vout[0].scriptPubKey = CScript() << OP_RETURN << OP_RESERVED << -1 << 0 << ParseHex("01") << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16;
+ BOOST_CHECK(IsStandardTx(t, reason));
+ t.vout[0].scriptPubKey = CScript() << OP_RETURN << 0 << ParseHex("01") << 2 << ParseHex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
+ BOOST_CHECK(IsStandardTx(t, reason));
+
+ // ...so long as it only contains PUSHDATA's
+ t.vout[0].scriptPubKey = CScript() << OP_RETURN << OP_RETURN;
BOOST_CHECK(!IsStandardTx(t, reason));
// TX_NULL_DATA w/o PUSHDATA
diff --git a/src/test/univalue_tests.cpp b/src/test/univalue_tests.cpp
index ee31c0955b..945c1acbeb 100644
--- a/src/test/univalue_tests.cpp
+++ b/src/test/univalue_tests.cpp
@@ -6,7 +6,7 @@
#include <vector>
#include <string>
#include <map>
-#include "univalue/univalue.h"
+#include <univalue.h>
#include "test/test_bitcoin.h"
#include <boost/test/unit_test.hpp>
diff --git a/src/univalue/.gitignore b/src/univalue/.gitignore
new file mode 100644
index 0000000000..ca9e842348
--- /dev/null
+++ b/src/univalue/.gitignore
@@ -0,0 +1,22 @@
+.deps/
+INSTALL
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache/
+compile
+config.log
+config.status
+config.guess
+config.sub
+configure
+depcomp
+install-sh
+missing
+stamp-h1
+univalue-config.h*
+test-driver
+libtool
+ltmain.sh
+
+*.o
diff --git a/src/univalue/.travis.yml b/src/univalue/.travis.yml
new file mode 100644
index 0000000000..af632c78d9
--- /dev/null
+++ b/src/univalue/.travis.yml
@@ -0,0 +1,52 @@
+
+language: cpp
+
+compiler:
+ - clang
+ - gcc
+
+os:
+ - linux
+ - osx
+
+sudo: false
+
+env:
+ global:
+ - MAKEJOBS=-j3
+ - RUN_TESTS=true
+ - BASE_OUTDIR=$TRAVIS_BUILD_DIR/out
+
+cache:
+ apt: true
+
+addons:
+ apt:
+ packages:
+ - pkg-config
+
+before_script:
+ - if [ -n "$USE_SHELL" ]; then export CONFIG_SHELL="$USE_SHELL"; fi
+ - test -n "$USE_SHELL" && eval '"$USE_SHELL" -c "./autogen.sh"' || ./autogen.sh
+
+script:
+ - if [ -n "$UNIVALUE_CONFIG" ]; then unset CC; unset CXX; fi
+ - OUTDIR=$BASE_OUTDIR/$TRAVIS_PULL_REQUEST/$TRAVIS_JOB_NUMBER-$HOST
+ - UNIVALUE_CONFIG_ALL="--prefix=$TRAVIS_BUILD_DIR/depends/$HOST --bindir=$OUTDIR/bin --libdir=$OUTDIR/lib"
+ - ./configure --cache-file=config.cache $UNIVALUE_CONFIG_ALL $UNIVALUE_CONFIG || ( cat config.log && false)
+ - make -s $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && make $GOAL ; false )
+ - export LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib
+ - if [ "$RUN_TESTS" = "true" ]; then make check; fi
+
+matrix:
+ fast_finish: true
+ include:
+ - os: linux
+ compiler: gcc
+ env: UNIVALUE_CONFIG=--host=x86_64-w64-mingw32 RUN_TESTS=false
+ addons:
+ apt:
+ packages:
+ - g++-mingw-w64-x86-64
+ - gcc-mingw-w64-x86-64
+ - binutils-mingw-w64-x86-64
diff --git a/src/univalue/COPYING b/src/univalue/COPYING
new file mode 100644
index 0000000000..1fb429f356
--- /dev/null
+++ b/src/univalue/COPYING
@@ -0,0 +1,19 @@
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
diff --git a/src/univalue/Makefile.am b/src/univalue/Makefile.am
new file mode 100644
index 0000000000..2800f466dc
--- /dev/null
+++ b/src/univalue/Makefile.am
@@ -0,0 +1,84 @@
+ACLOCAL_AMFLAGS = -I build-aux/m4
+.PHONY: gen
+.INTERMEDIATE: $(GENBIN)
+
+include_HEADERS = include/univalue.h
+noinst_HEADERS = lib/univalue_escapes.h
+
+lib_LTLIBRARIES = lib/libunivalue.la
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = pc/libunivalue.pc
+
+lib_libunivalue_la_SOURCES = \
+ lib/univalue.cpp \
+ lib/univalue_read.cpp \
+ lib/univalue_write.cpp
+
+lib_libunivalue_la_LDFLAGS = \
+ -version-info $(LIBUNIVALUE_CURRENT):$(LIBUNIVALUE_REVISION):$(LIBUNIVALUE_AGE) \
+ -no-undefined
+lib_libunivalue_la_CXXFLAGS = -I$(top_srcdir)/include
+
+TESTS = test/unitester
+
+GENBIN = gen/gen$(BUILD_EXEEXT)
+GEN_SRCS = gen/gen.cpp
+
+$(GENBIN): $(GEN_SRCS)
+ @echo Building $@
+ $(AM_V_at)c++ -I$(top_srcdir)/include -o $@ $<
+
+gen: lib/univalue_escapes.h $(GENBIN)
+ @echo Updating $<
+ $(AM_V_at)$(GENBIN) > lib/univalue_escapes.h
+
+noinst_PROGRAMS = $(TESTS)
+
+TEST_DATA_DIR=test
+
+test_unitester_SOURCES = test/unitester.cpp
+test_unitester_LDADD = lib/libunivalue.la
+test_unitester_CXXFLAGS = -I$(top_srcdir)/include -DJSON_TEST_SRC=\"$(srcdir)/$(TEST_DATA_DIR)\"
+test_unitester_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS)
+
+TEST_FILES = \
+ $(TEST_DATA_DIR)/fail10.json \
+ $(TEST_DATA_DIR)/fail11.json \
+ $(TEST_DATA_DIR)/fail12.json \
+ $(TEST_DATA_DIR)/fail13.json \
+ $(TEST_DATA_DIR)/fail14.json \
+ $(TEST_DATA_DIR)/fail15.json \
+ $(TEST_DATA_DIR)/fail16.json \
+ $(TEST_DATA_DIR)/fail17.json \
+ $(TEST_DATA_DIR)/fail18.json \
+ $(TEST_DATA_DIR)/fail19.json \
+ $(TEST_DATA_DIR)/fail1.json \
+ $(TEST_DATA_DIR)/fail20.json \
+ $(TEST_DATA_DIR)/fail21.json \
+ $(TEST_DATA_DIR)/fail22.json \
+ $(TEST_DATA_DIR)/fail23.json \
+ $(TEST_DATA_DIR)/fail24.json \
+ $(TEST_DATA_DIR)/fail25.json \
+ $(TEST_DATA_DIR)/fail26.json \
+ $(TEST_DATA_DIR)/fail27.json \
+ $(TEST_DATA_DIR)/fail28.json \
+ $(TEST_DATA_DIR)/fail29.json \
+ $(TEST_DATA_DIR)/fail2.json \
+ $(TEST_DATA_DIR)/fail30.json \
+ $(TEST_DATA_DIR)/fail31.json \
+ $(TEST_DATA_DIR)/fail32.json \
+ $(TEST_DATA_DIR)/fail33.json \
+ $(TEST_DATA_DIR)/fail34.json \
+ $(TEST_DATA_DIR)/fail3.json \
+ $(TEST_DATA_DIR)/fail4.json \
+ $(TEST_DATA_DIR)/fail5.json \
+ $(TEST_DATA_DIR)/fail6.json \
+ $(TEST_DATA_DIR)/fail7.json \
+ $(TEST_DATA_DIR)/fail8.json \
+ $(TEST_DATA_DIR)/fail9.json \
+ $(TEST_DATA_DIR)/pass1.json \
+ $(TEST_DATA_DIR)/pass2.json \
+ $(TEST_DATA_DIR)/pass3.json
+
+EXTRA_DIST=$(TEST_FILES) $(GEN_SRCS)
diff --git a/src/univalue/README b/src/univalue/README
new file mode 100644
index 0000000000..48167b083b
--- /dev/null
+++ b/src/univalue/README
@@ -0,0 +1,7 @@
+
+ UniValue
+
+A universal value object, with JSON encoding (output) and decoding (input).
+
+Built as a single dynamic RAII C++ object class, and no templates.
+
diff --git a/src/univalue/TODO b/src/univalue/TODO
new file mode 100644
index 0000000000..5530048e92
--- /dev/null
+++ b/src/univalue/TODO
@@ -0,0 +1,10 @@
+
+Rearrange tree for easier 'git subtree' style use
+
+Move towards C++11 etc.
+
+Namespace support - must come up with useful shorthand, avoiding
+long Univalue::Univalue::Univalue usages forced upon library users.
+
+Improve test suite
+
diff --git a/src/univalue/autogen.sh b/src/univalue/autogen.sh
new file mode 100755
index 0000000000..4b38721faa
--- /dev/null
+++ b/src/univalue/autogen.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+set -e
+srcdir="$(dirname $0)"
+cd "$srcdir"
+if [ -z ${LIBTOOLIZE} ] && GLIBTOOLIZE="`which glibtoolize 2>/dev/null`"; then
+ LIBTOOLIZE="${GLIBTOOLIZE}"
+ export LIBTOOLIZE
+fi
+autoreconf --install --force
diff --git a/src/univalue/build-aux/m4/.empty b/src/univalue/build-aux/m4/.empty
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/src/univalue/build-aux/m4/.empty
diff --git a/src/univalue/configure.ac b/src/univalue/configure.ac
new file mode 100644
index 0000000000..6cd9516229
--- /dev/null
+++ b/src/univalue/configure.ac
@@ -0,0 +1,69 @@
+m4_define([libunivalue_major_version], [1])
+m4_define([libunivalue_minor_version], [1])
+m4_define([libunivalue_micro_version], [1])
+m4_define([libunivalue_interface_age], [1])
+# If you need a modifier for the version number.
+# Normally empty, but can be used to make "fixup" releases.
+m4_define([libunivalue_extraversion], [])
+
+dnl libtool versioning from libunivalue
+m4_define([libunivalue_current], [m4_eval(100 * libunivalue_minor_version + libunivalue_micro_version - libunivalue_interface_age)])
+m4_define([libunivalue_binary_age], [m4_eval(100 * libunivalue_minor_version + libunivalue_micro_version)])
+m4_define([libunivalue_revision], [libunivalue_interface_age])
+m4_define([libunivalue_age], [m4_eval(libunivalue_binary_age - libunivalue_interface_age)])
+m4_define([libunivalue_version], [libunivalue_major_version().libunivalue_minor_version().libunivalue_micro_version()libunivalue_extraversion()])
+
+
+AC_INIT([univalue], [1.0.0],
+ [http://github.com/jgarzik/univalue/])
+
+dnl make the compilation flags quiet unless V=1 is used
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+AC_PREREQ(2.60)
+AC_CONFIG_SRCDIR([lib/univalue.cpp])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIR([build-aux/m4])
+AC_CONFIG_HEADERS([univalue-config.h])
+AM_INIT_AUTOMAKE([subdir-objects foreign])
+
+LIBUNIVALUE_MAJOR_VERSION=libunivalue_major_version
+LIBUNIVALUE_MINOR_VERSION=libunivalue_minor_version
+LIBUNIVALUE_MICRO_VERSION=libunivalue_micro_version
+LIBUNIVALUE_INTERFACE_AGE=libunivalue_interface_age
+
+# ABI version
+# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
+LIBUNIVALUE_CURRENT=libunivalue_current
+LIBUNIVALUE_REVISION=libunivalue_revision
+LIBUNIVALUE_AGE=libunivalue_age
+
+AC_SUBST(LIBUNIVALUE_CURRENT)
+AC_SUBST(LIBUNIVALUE_REVISION)
+AC_SUBST(LIBUNIVALUE_AGE)
+
+LT_INIT
+LT_LANG([C++])
+
+case $host in
+ *mingw*)
+ LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static"
+ ;;
+esac
+
+BUILD_EXEEXT=
+case $build in
+ *mingw*)
+ BUILD_EXEEXT=".exe"
+ ;;
+esac
+
+AC_CONFIG_FILES([
+ Makefile
+ pc/libunivalue.pc
+ pc/libunivalue-uninstalled.pc])
+
+AC_SUBST(LIBTOOL_APP_LDFLAGS)
+AC_SUBST(BUILD_EXEEXT)
+AC_OUTPUT
+
diff --git a/src/univalue/gen.cpp b/src/univalue/gen/gen.cpp
index 5e5a4d4aed..5e5a4d4aed 100644
--- a/src/univalue/gen.cpp
+++ b/src/univalue/gen/gen.cpp
diff --git a/src/univalue/univalue.h b/src/univalue/include/univalue.h
index 4742b56f3d..ac05116011 100644
--- a/src/univalue/univalue.h
+++ b/src/univalue/include/univalue.h
@@ -1,11 +1,13 @@
// Copyright 2014 BitPay Inc.
+// Copyright 2015 Bitcoin Core Developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef BITCOIN_UNIVALUE_UNIVALUE_H
-#define BITCOIN_UNIVALUE_UNIVALUE_H
+#ifndef __UNIVALUE_H__
+#define __UNIVALUE_H__
#include <stdint.h>
+
#include <string>
#include <vector>
#include <map>
@@ -245,4 +247,4 @@ extern const UniValue NullUniValue;
const UniValue& find_value( const UniValue& obj, const std::string& name);
-#endif // BITCOIN_UNIVALUE_UNIVALUE_H
+#endif // __UNIVALUE_H__ \ No newline at end of file
diff --git a/src/univalue/lib/.gitignore b/src/univalue/lib/.gitignore
new file mode 100644
index 0000000000..ca8c16dcd4
--- /dev/null
+++ b/src/univalue/lib/.gitignore
@@ -0,0 +1,10 @@
+
+libunivalue-uninstalled.pc
+libunivalue.pc
+libunivalue.a
+gen
+
+.libs
+*.lo
+*.la
+
diff --git a/src/univalue/univalue.cpp b/src/univalue/lib/univalue.cpp
index 1d49a2cfc9..883e8651fe 100644
--- a/src/univalue/univalue.cpp
+++ b/src/univalue/lib/univalue.cpp
@@ -1,16 +1,78 @@
// Copyright 2014 BitPay Inc.
+// Copyright 2015 Bitcoin Core Developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <stdint.h>
#include <ctype.h>
+#include <errno.h>
#include <iomanip>
+#include <limits>
#include <sstream>
-#include <stdexcept> // std::runtime_error
+#include <stdexcept>
+#include <stdlib.h>
+#include <string.h>
#include "univalue.h"
-#include "utilstrencodings.h" // ParseXX
+namespace
+{
+static bool ParsePrechecks(const std::string& str)
+{
+ if (str.empty()) // No empty string allowed
+ return false;
+ if (str.size() >= 1 && (isspace(str[0]) || isspace(str[str.size()-1]))) // No padding allowed
+ return false;
+ if (str.size() != strlen(str.c_str())) // No embedded NUL characters allowed
+ return false;
+ return true;
+}
+
+bool ParseInt32(const std::string& str, int32_t *out)
+{
+ if (!ParsePrechecks(str))
+ return false;
+ char *endp = NULL;
+ errno = 0; // strtol will not set errno if valid
+ long int n = strtol(str.c_str(), &endp, 10);
+ if(out) *out = (int32_t)n;
+ // Note that strtol returns a *long int*, so even if strtol doesn't report a over/underflow
+ // we still have to check that the returned value is within the range of an *int32_t*. On 64-bit
+ // platforms the size of these types may be different.
+ return endp && *endp == 0 && !errno &&
+ n >= std::numeric_limits<int32_t>::min() &&
+ n <= std::numeric_limits<int32_t>::max();
+}
+
+bool ParseInt64(const std::string& str, int64_t *out)
+{
+ if (!ParsePrechecks(str))
+ return false;
+ char *endp = NULL;
+ errno = 0; // strtoll will not set errno if valid
+ long long int n = strtoll(str.c_str(), &endp, 10);
+ if(out) *out = (int64_t)n;
+ // Note that strtoll returns a *long long int*, so even if strtol doesn't report a over/underflow
+ // we still have to check that the returned value is within the range of an *int64_t*.
+ return endp && *endp == 0 && !errno &&
+ n >= std::numeric_limits<int64_t>::min() &&
+ n <= std::numeric_limits<int64_t>::max();
+}
+
+bool ParseDouble(const std::string& str, double *out)
+{
+ if (!ParsePrechecks(str))
+ return false;
+ if (str.size() >= 2 && str[0] == '0' && str[1] == 'x') // No hexadecimal floats allowed
+ return false;
+ std::istringstream text(str);
+ text.imbue(std::locale::classic());
+ double result;
+ text >> result;
+ if(out) *out = result;
+ return text.eof() && !text.fail();
+}
+}
using namespace std;
diff --git a/src/univalue/univalue_escapes.h b/src/univalue/lib/univalue_escapes.h
index 4133b24ca1..4133b24ca1 100644
--- a/src/univalue/univalue_escapes.h
+++ b/src/univalue/lib/univalue_escapes.h
diff --git a/src/univalue/univalue_read.cpp b/src/univalue/lib/univalue_read.cpp
index 64591234cb..64591234cb 100644
--- a/src/univalue/univalue_read.cpp
+++ b/src/univalue/lib/univalue_read.cpp
diff --git a/src/univalue/univalue_write.cpp b/src/univalue/lib/univalue_write.cpp
index bce3997af7..bce3997af7 100644
--- a/src/univalue/univalue_write.cpp
+++ b/src/univalue/lib/univalue_write.cpp
diff --git a/src/univalue/pc/libunivalue-uninstalled.pc.in b/src/univalue/pc/libunivalue-uninstalled.pc.in
new file mode 100644
index 0000000000..b7f53e875e
--- /dev/null
+++ b/src/univalue/pc/libunivalue-uninstalled.pc.in
@@ -0,0 +1,9 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libunivalue
+Description: libunivalue, C++ universal value object and JSON library
+Version: @VERSION@
+Libs: ${pc_top_builddir}/${pcfiledir}/libunivalue.la
diff --git a/src/univalue/pc/libunivalue.pc.in b/src/univalue/pc/libunivalue.pc.in
new file mode 100644
index 0000000000..358a2d5f73
--- /dev/null
+++ b/src/univalue/pc/libunivalue.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libunivalue
+Description: libunivalue, C++ universal value object and JSON library
+Version: @VERSION@
+Libs: -L${libdir} -lunivalue
+Cflags: -I${includedir}
diff --git a/src/univalue/test/.gitignore b/src/univalue/test/.gitignore
new file mode 100644
index 0000000000..e4dea0df72
--- /dev/null
+++ b/src/univalue/test/.gitignore
@@ -0,0 +1,7 @@
+
+unitester
+
+*.log
+*.trs
+
+.libs
diff --git a/src/univalue/test/fail1.json b/src/univalue/test/fail1.json
new file mode 100644
index 0000000000..6216b865f1
--- /dev/null
+++ b/src/univalue/test/fail1.json
@@ -0,0 +1 @@
+"A JSON payload should be an object or array, not a string." \ No newline at end of file
diff --git a/src/univalue/test/fail10.json b/src/univalue/test/fail10.json
new file mode 100644
index 0000000000..5d8c0047bd
--- /dev/null
+++ b/src/univalue/test/fail10.json
@@ -0,0 +1 @@
+{"Extra value after close": true} "misplaced quoted value" \ No newline at end of file
diff --git a/src/univalue/test/fail11.json b/src/univalue/test/fail11.json
new file mode 100644
index 0000000000..76eb95b458
--- /dev/null
+++ b/src/univalue/test/fail11.json
@@ -0,0 +1 @@
+{"Illegal expression": 1 + 2} \ No newline at end of file
diff --git a/src/univalue/test/fail12.json b/src/univalue/test/fail12.json
new file mode 100644
index 0000000000..77580a4522
--- /dev/null
+++ b/src/univalue/test/fail12.json
@@ -0,0 +1 @@
+{"Illegal invocation": alert()} \ No newline at end of file
diff --git a/src/univalue/test/fail13.json b/src/univalue/test/fail13.json
new file mode 100644
index 0000000000..379406b59b
--- /dev/null
+++ b/src/univalue/test/fail13.json
@@ -0,0 +1 @@
+{"Numbers cannot have leading zeroes": 013} \ No newline at end of file
diff --git a/src/univalue/test/fail14.json b/src/univalue/test/fail14.json
new file mode 100644
index 0000000000..0ed366b38a
--- /dev/null
+++ b/src/univalue/test/fail14.json
@@ -0,0 +1 @@
+{"Numbers cannot be hex": 0x14} \ No newline at end of file
diff --git a/src/univalue/test/fail15.json b/src/univalue/test/fail15.json
new file mode 100644
index 0000000000..fc8376b605
--- /dev/null
+++ b/src/univalue/test/fail15.json
@@ -0,0 +1 @@
+["Illegal backslash escape: \x15"] \ No newline at end of file
diff --git a/src/univalue/test/fail16.json b/src/univalue/test/fail16.json
new file mode 100644
index 0000000000..3fe21d4b53
--- /dev/null
+++ b/src/univalue/test/fail16.json
@@ -0,0 +1 @@
+[\naked] \ No newline at end of file
diff --git a/src/univalue/test/fail17.json b/src/univalue/test/fail17.json
new file mode 100644
index 0000000000..62b9214aed
--- /dev/null
+++ b/src/univalue/test/fail17.json
@@ -0,0 +1 @@
+["Illegal backslash escape: \017"] \ No newline at end of file
diff --git a/src/univalue/test/fail18.json b/src/univalue/test/fail18.json
new file mode 100644
index 0000000000..edac92716f
--- /dev/null
+++ b/src/univalue/test/fail18.json
@@ -0,0 +1 @@
+[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]] \ No newline at end of file
diff --git a/src/univalue/test/fail19.json b/src/univalue/test/fail19.json
new file mode 100644
index 0000000000..3b9c46fa9a
--- /dev/null
+++ b/src/univalue/test/fail19.json
@@ -0,0 +1 @@
+{"Missing colon" null} \ No newline at end of file
diff --git a/src/univalue/test/fail2.json b/src/univalue/test/fail2.json
new file mode 100644
index 0000000000..6b7c11e5a5
--- /dev/null
+++ b/src/univalue/test/fail2.json
@@ -0,0 +1 @@
+["Unclosed array" \ No newline at end of file
diff --git a/src/univalue/test/fail20.json b/src/univalue/test/fail20.json
new file mode 100644
index 0000000000..27c1af3e72
--- /dev/null
+++ b/src/univalue/test/fail20.json
@@ -0,0 +1 @@
+{"Double colon":: null} \ No newline at end of file
diff --git a/src/univalue/test/fail21.json b/src/univalue/test/fail21.json
new file mode 100644
index 0000000000..62474573b2
--- /dev/null
+++ b/src/univalue/test/fail21.json
@@ -0,0 +1 @@
+{"Comma instead of colon", null} \ No newline at end of file
diff --git a/src/univalue/test/fail22.json b/src/univalue/test/fail22.json
new file mode 100644
index 0000000000..a7752581bc
--- /dev/null
+++ b/src/univalue/test/fail22.json
@@ -0,0 +1 @@
+["Colon instead of comma": false] \ No newline at end of file
diff --git a/src/univalue/test/fail23.json b/src/univalue/test/fail23.json
new file mode 100644
index 0000000000..494add1ca1
--- /dev/null
+++ b/src/univalue/test/fail23.json
@@ -0,0 +1 @@
+["Bad value", truth] \ No newline at end of file
diff --git a/src/univalue/test/fail24.json b/src/univalue/test/fail24.json
new file mode 100644
index 0000000000..caff239bfc
--- /dev/null
+++ b/src/univalue/test/fail24.json
@@ -0,0 +1 @@
+['single quote'] \ No newline at end of file
diff --git a/src/univalue/test/fail25.json b/src/univalue/test/fail25.json
new file mode 100644
index 0000000000..8b7ad23e01
--- /dev/null
+++ b/src/univalue/test/fail25.json
@@ -0,0 +1 @@
+[" tab character in string "] \ No newline at end of file
diff --git a/src/univalue/test/fail26.json b/src/univalue/test/fail26.json
new file mode 100644
index 0000000000..845d26a6a5
--- /dev/null
+++ b/src/univalue/test/fail26.json
@@ -0,0 +1 @@
+["tab\ character\ in\ string\ "] \ No newline at end of file
diff --git a/src/univalue/test/fail27.json b/src/univalue/test/fail27.json
new file mode 100644
index 0000000000..6b01a2ca4a
--- /dev/null
+++ b/src/univalue/test/fail27.json
@@ -0,0 +1,2 @@
+["line
+break"] \ No newline at end of file
diff --git a/src/univalue/test/fail28.json b/src/univalue/test/fail28.json
new file mode 100644
index 0000000000..621a0101c6
--- /dev/null
+++ b/src/univalue/test/fail28.json
@@ -0,0 +1,2 @@
+["line\
+break"] \ No newline at end of file
diff --git a/src/univalue/test/fail29.json b/src/univalue/test/fail29.json
new file mode 100644
index 0000000000..47ec421bb6
--- /dev/null
+++ b/src/univalue/test/fail29.json
@@ -0,0 +1 @@
+[0e] \ No newline at end of file
diff --git a/src/univalue/test/fail3.json b/src/univalue/test/fail3.json
new file mode 100644
index 0000000000..168c81eb78
--- /dev/null
+++ b/src/univalue/test/fail3.json
@@ -0,0 +1 @@
+{unquoted_key: "keys must be quoted"} \ No newline at end of file
diff --git a/src/univalue/test/fail30.json b/src/univalue/test/fail30.json
new file mode 100644
index 0000000000..8ab0bc4b8b
--- /dev/null
+++ b/src/univalue/test/fail30.json
@@ -0,0 +1 @@
+[0e+] \ No newline at end of file
diff --git a/src/univalue/test/fail31.json b/src/univalue/test/fail31.json
new file mode 100644
index 0000000000..1cce602b51
--- /dev/null
+++ b/src/univalue/test/fail31.json
@@ -0,0 +1 @@
+[0e+-1] \ No newline at end of file
diff --git a/src/univalue/test/fail32.json b/src/univalue/test/fail32.json
new file mode 100644
index 0000000000..45cba7396f
--- /dev/null
+++ b/src/univalue/test/fail32.json
@@ -0,0 +1 @@
+{"Comma instead if closing brace": true, \ No newline at end of file
diff --git a/src/univalue/test/fail33.json b/src/univalue/test/fail33.json
new file mode 100644
index 0000000000..ca5eb19dc9
--- /dev/null
+++ b/src/univalue/test/fail33.json
@@ -0,0 +1 @@
+["mismatch"} \ No newline at end of file
diff --git a/src/univalue/test/fail34.json b/src/univalue/test/fail34.json
new file mode 100644
index 0000000000..3f8be17286
--- /dev/null
+++ b/src/univalue/test/fail34.json
@@ -0,0 +1 @@
+{} garbage \ No newline at end of file
diff --git a/src/univalue/test/fail4.json b/src/univalue/test/fail4.json
new file mode 100644
index 0000000000..9de168bf34
--- /dev/null
+++ b/src/univalue/test/fail4.json
@@ -0,0 +1 @@
+["extra comma",] \ No newline at end of file
diff --git a/src/univalue/test/fail5.json b/src/univalue/test/fail5.json
new file mode 100644
index 0000000000..ddf3ce3d24
--- /dev/null
+++ b/src/univalue/test/fail5.json
@@ -0,0 +1 @@
+["double extra comma",,] \ No newline at end of file
diff --git a/src/univalue/test/fail6.json b/src/univalue/test/fail6.json
new file mode 100644
index 0000000000..ed91580e1b
--- /dev/null
+++ b/src/univalue/test/fail6.json
@@ -0,0 +1 @@
+[ , "<-- missing value"] \ No newline at end of file
diff --git a/src/univalue/test/fail7.json b/src/univalue/test/fail7.json
new file mode 100644
index 0000000000..8a96af3e4e
--- /dev/null
+++ b/src/univalue/test/fail7.json
@@ -0,0 +1 @@
+["Comma after the close"], \ No newline at end of file
diff --git a/src/univalue/test/fail8.json b/src/univalue/test/fail8.json
new file mode 100644
index 0000000000..b28479c6ec
--- /dev/null
+++ b/src/univalue/test/fail8.json
@@ -0,0 +1 @@
+["Extra close"]] \ No newline at end of file
diff --git a/src/univalue/test/fail9.json b/src/univalue/test/fail9.json
new file mode 100644
index 0000000000..5815574f36
--- /dev/null
+++ b/src/univalue/test/fail9.json
@@ -0,0 +1 @@
+{"Extra comma": true,} \ No newline at end of file
diff --git a/src/univalue/test/pass1.json b/src/univalue/test/pass1.json
new file mode 100644
index 0000000000..70e2685436
--- /dev/null
+++ b/src/univalue/test/pass1.json
@@ -0,0 +1,58 @@
+[
+ "JSON Test Pattern pass1",
+ {"object with 1 member":["array with 1 element"]},
+ {},
+ [],
+ -42,
+ true,
+ false,
+ null,
+ {
+ "integer": 1234567890,
+ "real": -9876.543210,
+ "e": 0.123456789e-12,
+ "E": 1.234567890E+34,
+ "": 23456789012E66,
+ "zero": 0,
+ "one": 1,
+ "space": " ",
+ "quote": "\"",
+ "backslash": "\\",
+ "controls": "\b\f\n\r\t",
+ "slash": "/ & \/",
+ "alpha": "abcdefghijklmnopqrstuvwyz",
+ "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
+ "digit": "0123456789",
+ "0123456789": "digit",
+ "special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?",
+ "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
+ "true": true,
+ "false": false,
+ "null": null,
+ "array":[ ],
+ "object":{ },
+ "address": "50 St. James Street",
+ "url": "http://www.JSON.org/",
+ "comment": "// /* <!-- --",
+ "# -- --> */": " ",
+ " s p a c e d " :[1,2 , 3
+
+,
+
+4 , 5 , 6 ,7 ],"compact":[1,2,3,4,5,6,7],
+ "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
+ "quotes": "&#34; \u0022 %22 0x22 034 &#x22;",
+ "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"
+: "A key can be any string"
+ },
+ 0.5 ,98.6
+,
+99.44
+,
+
+1066,
+1e1,
+0.1e1,
+1e-1,
+1e00,2e+00,2e-00
+,"rosebud"] \ No newline at end of file
diff --git a/src/univalue/test/pass2.json b/src/univalue/test/pass2.json
new file mode 100644
index 0000000000..d3c63c7ad8
--- /dev/null
+++ b/src/univalue/test/pass2.json
@@ -0,0 +1 @@
+[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] \ No newline at end of file
diff --git a/src/univalue/test/pass3.json b/src/univalue/test/pass3.json
new file mode 100644
index 0000000000..4528d51f1a
--- /dev/null
+++ b/src/univalue/test/pass3.json
@@ -0,0 +1,6 @@
+{
+ "JSON Test Pattern pass3": {
+ "The outermost value": "must be an object or array.",
+ "In this test": "It is an object."
+ }
+}
diff --git a/src/univalue/test/unitester.cpp b/src/univalue/test/unitester.cpp
new file mode 100644
index 0000000000..835556e031
--- /dev/null
+++ b/src/univalue/test/unitester.cpp
@@ -0,0 +1,115 @@
+// Copyright 2014 BitPay Inc.
+// Distributed under the MIT/X11 software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <cassert>
+#include <string>
+#include "univalue.h"
+
+#ifndef JSON_TEST_SRC
+#error JSON_TEST_SRC must point to test source directory
+#endif
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+#endif
+
+using namespace std;
+string srcdir(JSON_TEST_SRC);
+
+static void runtest(string filename, const string& jdata)
+{
+ fprintf(stderr, "test %s\n", filename.c_str());
+
+ string prefix = filename.substr(0, 4);
+
+ bool wantPass = (prefix == "pass");
+ bool wantFail = (prefix == "fail");
+ assert(wantPass || wantFail);
+
+ UniValue val;
+ bool testResult = val.read(jdata);
+
+ if (wantPass) {
+ assert(testResult == true);
+ } else {
+ assert(testResult == false);
+ }
+}
+
+static void runtest_file(const char *filename_)
+{
+ string basename(filename_);
+ string filename = srcdir + "/" + basename;
+ FILE *f = fopen(filename.c_str(), "r");
+ assert(f != NULL);
+
+ string jdata;
+
+ char buf[4096];
+ while (!feof(f)) {
+ int bread = fread(buf, 1, sizeof(buf), f);
+ assert(!ferror(f));
+
+ string s(buf, bread);
+ jdata += s;
+ }
+
+ assert(!ferror(f));
+ fclose(f);
+
+ runtest(basename, jdata);
+}
+
+static const char *filenames[] = {
+ "fail10.json",
+ "fail11.json",
+ "fail12.json",
+ "fail13.json",
+ "fail14.json",
+ "fail15.json",
+ "fail16.json",
+ "fail17.json",
+ //"fail18.json", // investigate
+ "fail19.json",
+ "fail1.json",
+ "fail20.json",
+ "fail21.json",
+ "fail22.json",
+ "fail23.json",
+ "fail24.json",
+ "fail25.json",
+ "fail26.json",
+ "fail27.json",
+ "fail28.json",
+ "fail29.json",
+ "fail2.json",
+ "fail30.json",
+ "fail31.json",
+ "fail32.json",
+ "fail33.json",
+ "fail34.json",
+ "fail3.json",
+ "fail4.json", // extra comma
+ "fail5.json",
+ "fail6.json",
+ "fail7.json",
+ "fail8.json",
+ "fail9.json", // extra comma
+ "pass1.json",
+ "pass2.json",
+ "pass3.json",
+};
+
+int main (int argc, char *argv[])
+{
+ for (unsigned int fidx = 0; fidx < ARRAY_SIZE(filenames); fidx++) {
+ runtest_file(filenames[fidx]);
+ }
+
+ return 0;
+}
+
diff --git a/src/validationinterface.h b/src/validationinterface.h
index 6f95ad74eb..ffb56d266b 100644
--- a/src/validationinterface.h
+++ b/src/validationinterface.h
@@ -11,6 +11,7 @@
class CBlock;
struct CBlockLocator;
+class CBlockIndex;
class CReserveScript;
class CTransaction;
class CValidationInterface;
@@ -30,7 +31,7 @@ void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL);
class CValidationInterface {
protected:
- virtual void UpdatedBlockTip(const uint256 &newHashTip) {}
+ virtual void UpdatedBlockTip(const CBlockIndex *pindex) {}
virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock) {}
virtual void SetBestChain(const CBlockLocator &locator) {}
virtual void UpdatedTransaction(const uint256 &hash) {}
@@ -46,7 +47,7 @@ protected:
struct CMainSignals {
/** Notifies listeners of updated block chain tip */
- boost::signals2::signal<void (const uint256 &)> UpdatedBlockTip;
+ boost::signals2::signal<void (const CBlockIndex *)> UpdatedBlockTip;
/** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */
boost::signals2::signal<void (const CTransaction &, const CBlock *)> SyncTransaction;
/** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
index 7e22faac37..c431fc4013 100644
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -20,7 +20,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
#include <boost/foreach.hpp>
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 5d182f3d42..30b854477b 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -22,7 +22,7 @@
#include <boost/assign/list_of.hpp>
-#include "univalue/univalue.h"
+#include <univalue.h>
using namespace std;
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 39eff3af30..bd3004061b 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1852,9 +1852,9 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
nChangePosRet = -1;
bool fFirst = true;
- CAmount nTotalValue = nValue;
+ CAmount nValueToSelect = nValue;
if (nSubtractFeeFromAmount == 0)
- nTotalValue += nFeeRet;
+ nValueToSelect += nFeeRet;
double dPriority = 0;
// vouts to the payees
BOOST_FOREACH (const CRecipient& recipient, vecSend)
@@ -1891,7 +1891,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
// Choose coins to use
set<pair<const CWalletTx*,unsigned int> > setCoins;
CAmount nValueIn = 0;
- if (!SelectCoins(nTotalValue, setCoins, nValueIn, coinControl))
+ if (!SelectCoins(nValueToSelect, setCoins, nValueIn, coinControl))
{
strFailReason = _("Insufficient funds");
return false;
@@ -1909,10 +1909,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
dPriority += (double)nCredit * age;
}
- CAmount nChange = nValueIn - nValue;
- if (nSubtractFeeFromAmount == 0)
- nChange -= nFeeRet;
-
+ const CAmount nChange = nValueIn - nValueToSelect;
if (nChange > 0)
{
// Fill a vout to ourself
diff --git a/src/zmq/zmqabstractnotifier.cpp b/src/zmq/zmqabstractnotifier.cpp
index 744ec59234..9f5cb3ba67 100644
--- a/src/zmq/zmqabstractnotifier.cpp
+++ b/src/zmq/zmqabstractnotifier.cpp
@@ -11,7 +11,7 @@ CZMQAbstractNotifier::~CZMQAbstractNotifier()
assert(!psocket);
}
-bool CZMQAbstractNotifier::NotifyBlock(const uint256 &/*hash*/)
+bool CZMQAbstractNotifier::NotifyBlock(const CBlockIndex * /*CBlockIndex*/)
{
return true;
}
diff --git a/src/zmq/zmqabstractnotifier.h b/src/zmq/zmqabstractnotifier.h
index 626d1ddf92..77cf5141e2 100644
--- a/src/zmq/zmqabstractnotifier.h
+++ b/src/zmq/zmqabstractnotifier.h
@@ -7,7 +7,9 @@
#include "zmqconfig.h"
+class CBlockIndex;
class CZMQAbstractNotifier;
+
typedef CZMQAbstractNotifier* (*CZMQNotifierFactory)();
class CZMQAbstractNotifier
@@ -30,7 +32,7 @@ public:
virtual bool Initialize(void *pcontext) = 0;
virtual void Shutdown() = 0;
- virtual bool NotifyBlock(const uint256 &hash);
+ virtual bool NotifyBlock(const CBlockIndex *pindex);
virtual bool NotifyTransaction(const CTransaction &transaction);
protected:
diff --git a/src/zmq/zmqnotificationinterface.cpp b/src/zmq/zmqnotificationinterface.cpp
index 71ccb59a4a..388b86707b 100644
--- a/src/zmq/zmqnotificationinterface.cpp
+++ b/src/zmq/zmqnotificationinterface.cpp
@@ -120,12 +120,12 @@ void CZMQNotificationInterface::Shutdown()
}
}
-void CZMQNotificationInterface::UpdatedBlockTip(const uint256 &hash)
+void CZMQNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindex)
{
for (std::list<CZMQAbstractNotifier*>::iterator i = notifiers.begin(); i!=notifiers.end(); )
{
CZMQAbstractNotifier *notifier = *i;
- if (notifier->NotifyBlock(hash))
+ if (notifier->NotifyBlock(pindex))
{
i++;
}
diff --git a/src/zmq/zmqnotificationinterface.h b/src/zmq/zmqnotificationinterface.h
index afc0b8d24e..8eea15c068 100644
--- a/src/zmq/zmqnotificationinterface.h
+++ b/src/zmq/zmqnotificationinterface.h
@@ -9,6 +9,7 @@
#include <string>
#include <map>
+class CBlockIndex;
class CZMQAbstractNotifier;
class CZMQNotificationInterface : public CValidationInterface
@@ -23,7 +24,7 @@ public:
protected: // CValidationInterface
void SyncTransaction(const CTransaction &tx, const CBlock *pblock);
- void UpdatedBlockTip(const uint256 &newHashTip);
+ void UpdatedBlockTip(const CBlockIndex *pindex);
private:
CZMQNotificationInterface();
diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp
index 0a6d7d0dbc..4c3eb8f2d9 100644
--- a/src/zmq/zmqpublishnotifier.cpp
+++ b/src/zmq/zmqpublishnotifier.cpp
@@ -116,8 +116,9 @@ void CZMQAbstractPublishNotifier::Shutdown()
psocket = 0;
}
-bool CZMQPublishHashBlockNotifier::NotifyBlock(const uint256 &hash)
+bool CZMQPublishHashBlockNotifier::NotifyBlock(const CBlockIndex *pindex)
{
+ uint256 hash = pindex->GetBlockHash();
LogPrint("zmq", "Publish hash block %s\n", hash.GetHex());
char data[32];
for (unsigned int i = 0; i < 32; i++)
@@ -137,18 +138,15 @@ bool CZMQPublishHashTransactionNotifier::NotifyTransaction(const CTransaction &t
return rc == 0;
}
-bool CZMQPublishRawBlockNotifier::NotifyBlock(const uint256 &hash)
+bool CZMQPublishRawBlockNotifier::NotifyBlock(const CBlockIndex *pindex)
{
- LogPrint("zmq", "Publish raw block %s\n", hash.GetHex());
+ LogPrint("zmq", "Publish raw block %s\n", pindex->GetBlockHash().GetHex());
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
{
LOCK(cs_main);
-
CBlock block;
- CBlockIndex* pblockindex = mapBlockIndex[hash];
-
- if(!ReadBlockFromDisk(block, pblockindex))
+ if(!ReadBlockFromDisk(block, pindex))
{
zmqError("Can't read block from disk");
return false;
diff --git a/src/zmq/zmqpublishnotifier.h b/src/zmq/zmqpublishnotifier.h
index a0eb26f5e2..44d5cbea67 100644
--- a/src/zmq/zmqpublishnotifier.h
+++ b/src/zmq/zmqpublishnotifier.h
@@ -7,6 +7,8 @@
#include "zmqabstractnotifier.h"
+class CBlockIndex;
+
class CZMQAbstractPublishNotifier : public CZMQAbstractNotifier
{
public:
@@ -17,7 +19,7 @@ public:
class CZMQPublishHashBlockNotifier : public CZMQAbstractPublishNotifier
{
public:
- bool NotifyBlock(const uint256 &hash);
+ bool NotifyBlock(const CBlockIndex *pindex);
};
class CZMQPublishHashTransactionNotifier : public CZMQAbstractPublishNotifier
@@ -29,7 +31,7 @@ public:
class CZMQPublishRawBlockNotifier : public CZMQAbstractPublishNotifier
{
public:
- bool NotifyBlock(const uint256 &hash);
+ bool NotifyBlock(const CBlockIndex *pindex);
};
class CZMQPublishRawTransactionNotifier : public CZMQAbstractPublishNotifier