aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore23
-rw-r--r--.travis.yml6
-rw-r--r--Makefile.am2
-rw-r--r--README.md10
-rwxr-xr-xautogen.sh2
-rw-r--r--build-aux/m4/ax_boost_base.m4 (renamed from src/m4/ax_boost_base.m4)0
-rw-r--r--build-aux/m4/ax_boost_chrono.m4 (renamed from src/m4/ax_boost_chrono.m4)0
-rw-r--r--build-aux/m4/ax_boost_filesystem.m4 (renamed from src/m4/ax_boost_filesystem.m4)0
-rw-r--r--build-aux/m4/ax_boost_program_options.m4 (renamed from src/m4/ax_boost_program_options.m4)0
-rw-r--r--build-aux/m4/ax_boost_system.m4 (renamed from src/m4/ax_boost_system.m4)0
-rw-r--r--build-aux/m4/ax_boost_thread.m4 (renamed from src/m4/ax_boost_thread.m4)0
-rw-r--r--build-aux/m4/ax_boost_unit_test_framework.m4 (renamed from src/m4/ax_boost_unit_test_framework.m4)0
-rw-r--r--build-aux/m4/ax_check_compile_flag.m4 (renamed from src/m4/ax_check_compile_flag.m4)0
-rw-r--r--build-aux/m4/ax_check_link_flag.m4 (renamed from src/m4/ax_check_link_flag.m4)0
-rw-r--r--build-aux/m4/ax_check_preproc_flag.m4 (renamed from src/m4/ax_check_preproc_flag.m4)0
-rw-r--r--build-aux/m4/ax_pthread.m4 (renamed from src/m4/ax_pthread.m4)0
-rw-r--r--build-aux/m4/bitcoin_find_bdb48.m4 (renamed from src/m4/bitcoin_find_bdb48.m4)14
-rw-r--r--build-aux/m4/bitcoin_qt.m4 (renamed from src/m4/bitcoin_qt.m4)28
-rw-r--r--build-aux/m4/bitcoin_subdir_to_include.m4 (renamed from src/m4/bitcoin_subdir_to_include.m4)0
-rw-r--r--configure.ac78
-rw-r--r--contrib/debian/changelog6
-rw-r--r--contrib/debian/control1
-rw-r--r--contrib/init/README.md10
-rw-r--r--contrib/init/bitcoind.conf65
-rw-r--r--contrib/init/bitcoind.openrc86
-rw-r--r--contrib/init/bitcoind.openrcconf27
-rw-r--r--contrib/init/bitcoind.service (renamed from contrib/systemd/bitcoind.service)11
-rwxr-xr-xcontrib/linearize/linearize-data.py6
-rwxr-xr-xcontrib/macdeploy/macdeployqtplus29
-rw-r--r--depends/config.site.in2
-rw-r--r--depends/packages/qt.mk5
-rw-r--r--depends/patches/qt/qt5-tablet-osx.patch20
-rw-r--r--doc/README.md2
-rw-r--r--doc/build-osx.md52
-rw-r--r--doc/init.md92
-rw-r--r--doc/release-process.md16
-rw-r--r--doc/systemd.md47
-rwxr-xr-xshare/genbuild.sh2
-rw-r--r--src/Makefile.am10
-rw-r--r--src/Makefile.test.include3
-rw-r--r--src/addrman.cpp225
-rw-r--r--src/addrman.h2
-rw-r--r--src/allocators.cpp11
-rw-r--r--src/allocators.h91
-rw-r--r--src/base58.cpp138
-rw-r--r--src/base58.h2
-rw-r--r--src/bitcoin-cli.cpp4
-rw-r--r--src/bitcoin-tx.cpp29
-rw-r--r--src/bitcoind.cpp1
-rw-r--r--src/chainparams.cpp19
-rw-r--r--src/chainparams.h3
-rw-r--r--src/chainparamsbase.cpp56
-rw-r--r--src/chainparamsbase.h5
-rw-r--r--src/checkpoints.h20
-rw-r--r--src/checkqueue.h59
-rw-r--r--src/clientversion.h12
-rw-r--r--src/coincontrol.h1
-rw-r--r--src/coins.cpp38
-rw-r--r--src/coins.h12
-rw-r--r--src/compat/glibc_compat.cpp4
-rw-r--r--src/compat/glibc_sanity.cpp14
-rw-r--r--src/compat/glibcxx_compat.cpp19
-rw-r--r--src/compat/glibcxx_sanity.cpp24
-rw-r--r--src/core.cpp19
-rw-r--r--src/core.h3
-rw-r--r--src/core_io.h2
-rw-r--r--src/core_read.cpp13
-rw-r--r--src/core_write.cpp7
-rw-r--r--src/crypter.cpp12
-rw-r--r--src/crypto/common.h55
-rw-r--r--src/crypto/ripemd160.cpp324
-rw-r--r--src/crypto/ripemd160.h5
-rw-r--r--src/crypto/sha1.cpp199
-rw-r--r--src/crypto/sha1.h5
-rw-r--r--src/crypto/sha2.cpp383
-rw-r--r--src/crypto/sha2.h18
-rw-r--r--src/db.cpp159
-rw-r--r--src/db.h41
-rw-r--r--src/hash.cpp63
-rw-r--r--src/hash.h2
-rw-r--r--src/init.cpp22
-rw-r--r--src/init.h8
-rw-r--r--src/key.cpp8
-rw-r--r--src/key.h131
-rw-r--r--src/leveldbwrapper.cpp15
-rw-r--r--src/leveldbwrapper.h48
-rw-r--r--src/limitedmap.h33
-rw-r--r--src/main.cpp221
-rw-r--r--src/main.h16
-rw-r--r--src/miner.cpp7
-rw-r--r--src/mruset.h18
-rw-r--r--src/net.cpp16
-rw-r--r--src/net.h2
-rw-r--r--src/netbase.cpp90
-rw-r--r--src/noui.cpp2
-rw-r--r--src/pow.h2
-rw-r--r--src/protocol.h151
-rw-r--r--src/qt/bitcoin.cpp13
-rw-r--r--src/qt/bitcoinamountfield.h4
-rw-r--r--src/qt/bitcoingui.cpp19
-rw-r--r--src/qt/bitcoinunits.cpp5
-rw-r--r--src/qt/coincontroldialog.cpp4
-rw-r--r--src/qt/coincontroldialog.h8
-rw-r--r--src/qt/forms/addressbookpage.ui15
-rw-r--r--src/qt/forms/coincontroldialog.ui3
-rw-r--r--src/qt/forms/openuridialog.ui6
-rw-r--r--src/qt/forms/optionsdialog.ui6
-rw-r--r--src/qt/forms/receivecoinsdialog.ui380
-rw-r--r--src/qt/forms/receiverequestdialog.ui9
-rw-r--r--src/qt/forms/rpcconsole.ui3
-rw-r--r--src/qt/forms/sendcoinsdialog.ui9
-rw-r--r--src/qt/forms/signverifymessagedialog.ui3
-rw-r--r--src/qt/guiconstants.h6
-rw-r--r--src/qt/guiutil.cpp4
-rw-r--r--src/qt/intro.h2
-rw-r--r--src/qt/openuridialog.h2
-rw-r--r--src/qt/optionsdialog.cpp2
-rw-r--r--src/qt/optionsmodel.cpp1
-rw-r--r--src/qt/paymentrequestplus.cpp1
-rw-r--r--src/qt/paymentserver.cpp12
-rw-r--r--src/qt/receivecoinsdialog.h7
-rw-r--r--src/qt/rpcconsole.cpp4
-rw-r--r--src/qt/rpcconsole.h8
-rw-r--r--src/qt/sendcoinsdialog.h8
-rw-r--r--src/qt/splashscreen.cpp63
-rw-r--r--src/qt/splashscreen.h22
-rw-r--r--src/qt/transactiondesc.cpp4
-rw-r--r--src/qt/transactiontablemodel.cpp29
-rw-r--r--src/qt/utilitydialog.cpp26
-rw-r--r--src/qt/utilitydialog.h6
-rw-r--r--src/qt/walletmodel.cpp5
-rw-r--r--src/random.cpp32
-rw-r--r--src/random.h2
-rw-r--r--src/rpcclient.cpp4
-rw-r--r--src/rpcclient.h2
-rw-r--r--src/rpcdump.cpp7
-rw-r--r--src/rpcmining.cpp6
-rw-r--r--src/rpcmisc.cpp7
-rw-r--r--src/rpcnet.cpp8
-rw-r--r--src/rpcprotocol.cpp2
-rw-r--r--src/rpcrawtransaction.cpp23
-rw-r--r--src/rpcserver.cpp2
-rw-r--r--src/rpcwallet.cpp14
-rw-r--r--src/script/compressor.cpp4
-rw-r--r--src/script/compressor.h6
-rw-r--r--src/script/interpreter.cpp38
-rw-r--r--src/script/interpreter.h14
-rw-r--r--src/script/script.cpp44
-rw-r--r--src/script/script.h29
-rw-r--r--src/script/sign.cpp12
-rw-r--r--src/script/sign.h7
-rw-r--r--src/script/standard.cpp51
-rw-r--r--src/script/standard.h23
-rw-r--r--src/serialize.h10
-rw-r--r--src/sync.cpp51
-rw-r--r--src/sync.h70
-rw-r--r--src/test/DoS_tests.cpp33
-rw-r--r--src/test/base58_tests.cpp2
-rw-r--r--src/test/checkblock_tests.cpp2
-rw-r--r--src/test/crypto_tests.cpp2
-rw-r--r--src/test/data/bitcoin-util-test.json3
-rw-r--r--src/test/data/script_invalid.json682
-rw-r--r--src/test/data/script_valid.json964
-rw-r--r--src/test/data/txcreate2.hex1
-rw-r--r--src/test/miner_tests.cpp2
-rw-r--r--src/test/multisig_tests.cpp31
-rw-r--r--src/test/script_P2SH_tests.cpp58
-rw-r--r--src/test/script_tests.cpp97
-rw-r--r--src/test/sigopcount_tests.cpp9
-rw-r--r--src/test/transaction_tests.cpp16
-rw-r--r--src/threadsafety.h40
-rw-r--r--src/timedata.h27
-rw-r--r--src/txdb.cpp3
-rw-r--r--src/txmempool.cpp20
-rw-r--r--src/txmempool.h1
-rw-r--r--src/uint256.cpp133
-rw-r--r--src/uint256.h2
-rw-r--r--src/util.cpp7
-rw-r--r--src/util.h4
-rw-r--r--src/utilstrencodings.cpp9
-rw-r--r--src/version.cpp45
-rw-r--r--src/wallet.cpp102
-rw-r--r--src/wallet.h4
-rw-r--r--src/wallet_ismine.cpp (renamed from src/scriptutils.cpp)45
-rw-r--r--src/wallet_ismine.h (renamed from src/scriptutils.h)14
-rw-r--r--src/walletdb.cpp6
-rw-r--r--src/walletdb.h19
187 files changed, 4008 insertions, 3086 deletions
diff --git a/.gitignore b/.gitignore
index 24af4cb72e..7d00051f23 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,25 +8,32 @@ src/bitcoin-tx
src/test/test_bitcoin
src/qt/test/test_bitcoin-qt
+# autoreconf
Makefile.in
aclocal.m4
autom4te.cache/
+build-aux/config.guess
+build-aux/config.sub
+build-aux/depcomp
+build-aux/install-sh
+build-aux/ltmain.sh
+build-aux/m4/libtool.m4
+build-aux/m4/lt~obsolete.m4
+build-aux/m4/ltoptions.m4
+build-aux/m4/ltsugar.m4
+build-aux/m4/ltversion.m4
+build-aux/missing
+build-aux/compile
+build-aux/test-driver
config.log
config.status
configure
+libtool
src/config/bitcoin-config.h
src/config/bitcoin-config.h.in
src/config/stamp-h1
-src/build-aux/
share/setup.nsi
share/qt/Info.plist
-# Libtool
-libtool
-src/m4/libtool.m4
-src/m4/ltoptions.m4
-src/m4/ltsugar.m4
-src/m4/ltversion.m4
-src/m4/lt~obsolete.m4
src/univalue/gen
diff --git a/.travis.yml b/.travis.yml
index 379a0e1df7..54799362a2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,9 +25,9 @@ matrix:
fast_finish: true
include:
- compiler: "true 1"
- env: HOST=arm-linux-gnueabihf PACKAGES="g++-arm-linux-gnueabihf" DEP_OPTS="NO_QT=1" GOAL="install" BITCOIN_CONFIG"--enable-glibc-back-compat"
+ env: HOST=arm-linux-gnueabihf PACKAGES="g++-arm-linux-gnueabihf" DEP_OPTS="NO_QT=1" GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat"
- compiler: "true 2"
- env: HOST=x86_64-unknown-linux-gnu DEP_OPTS="NO_QT=1 NO_WALLET=1 NO_UPNP=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat"
+ env: HOST=x86_64-unknown-linux-gnu DEP_OPTS="NO_QT=1 NO_WALLET=1 NO_UPNP=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat CPPFLAGS=-DDEBUG_LOCKORDER"
- compiler: "true 3"
env: HOST=x86_64-unknown-linux-gnu RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat"
- compiler: "true 4"
@@ -58,6 +58,6 @@ script:
- cd bitcoin-$HOST
- ./configure --cache-file=../config.cache $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false)
- make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && make $GOAL V=1 ; false )
- - if [ "$RUN_TESTS" = "true" ]; then make check; fi
+ - if [ "$RUN_TESTS" = "true" ]; then travis_retry make check; fi
after_script:
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then (echo "Upload goes here. Something like: scp -r $BASE_OUTDIR server" || echo "upload failed"); fi
diff --git a/Makefile.am b/Makefile.am
index a64666a32b..fe7244edf8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-ACLOCAL_AMFLAGS = -I src/m4
+ACLOCAL_AMFLAGS = -I build-aux/m4
SUBDIRS = src
.PHONY: deploy FORCE
diff --git a/README.md b/README.md
index 43be738c62..cf650fe543 100644
--- a/README.md
+++ b/README.md
@@ -97,7 +97,7 @@ CXXFLAGS="-g -ggdb -O0" or whatever debug flags you need.
**debug.log**
If the code is behaving strangely, take a look in the debug.log file in the data directory;
-error and debugging message are written there.
+error and debugging messages are written there.
The -debug=... command-line option controls debugging; running with just -debug will turn
on all categories (and give you a very large debug.log file).
@@ -111,12 +111,12 @@ Run with the -testnet option to run with "play bitcoins" on the test network, if
are testing multi-machine code that needs to operate across the internet.
If you are testing something that can run on one machine, run with the -regtest option.
-In regression test mode blocks can be created on-demand; see qa/rpc-tests/ for tests
-that run in -regest mode.
+In regression test mode, blocks can be created on-demand; see qa/rpc-tests/ for tests
+that run in -regtest mode.
**DEBUG_LOCKORDER**
Bitcoin Core is a multithreaded application, and deadlocks or other multithreading bugs
can be very difficult to track down. Compiling with -DDEBUG_LOCKORDER (configure
-CXXFLAGS="-DDEBUG_LOCKORDER -g") inserts run-time checks to keep track of what locks
-are held, and adds warning to the debug.log file if inconsistencies are detected.
+CXXFLAGS="-DDEBUG_LOCKORDER -g") inserts run-time checks to keep track of which locks
+are held, and adds warnings to the debug.log file if inconsistencies are detected.
diff --git a/autogen.sh b/autogen.sh
index 50b85bcba0..ddfc09607e 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -5,4 +5,4 @@ cd "$srcdir"
if [ -z ${LIBTOOLIZE} ] && GLIBTOOLIZE="`which glibtoolize 2>/dev/null`"; then
export LIBTOOLIZE="${GLIBTOOLIZE}"
fi
-autoreconf --install --force
+autoreconf --install --force --warnings=all
diff --git a/src/m4/ax_boost_base.m4 b/build-aux/m4/ax_boost_base.m4
index 3f24d5ddc6..3f24d5ddc6 100644
--- a/src/m4/ax_boost_base.m4
+++ b/build-aux/m4/ax_boost_base.m4
diff --git a/src/m4/ax_boost_chrono.m4 b/build-aux/m4/ax_boost_chrono.m4
index 318ecea17f..318ecea17f 100644
--- a/src/m4/ax_boost_chrono.m4
+++ b/build-aux/m4/ax_boost_chrono.m4
diff --git a/src/m4/ax_boost_filesystem.m4 b/build-aux/m4/ax_boost_filesystem.m4
index f5c9d56470..f5c9d56470 100644
--- a/src/m4/ax_boost_filesystem.m4
+++ b/build-aux/m4/ax_boost_filesystem.m4
diff --git a/src/m4/ax_boost_program_options.m4 b/build-aux/m4/ax_boost_program_options.m4
index f591441854..f591441854 100644
--- a/src/m4/ax_boost_program_options.m4
+++ b/build-aux/m4/ax_boost_program_options.m4
diff --git a/src/m4/ax_boost_system.m4 b/build-aux/m4/ax_boost_system.m4
index 9c78280fca..9c78280fca 100644
--- a/src/m4/ax_boost_system.m4
+++ b/build-aux/m4/ax_boost_system.m4
diff --git a/src/m4/ax_boost_thread.m4 b/build-aux/m4/ax_boost_thread.m4
index 9f0bd0b23c..9f0bd0b23c 100644
--- a/src/m4/ax_boost_thread.m4
+++ b/build-aux/m4/ax_boost_thread.m4
diff --git a/src/m4/ax_boost_unit_test_framework.m4 b/build-aux/m4/ax_boost_unit_test_framework.m4
index 4efd1e2f18..4efd1e2f18 100644
--- a/src/m4/ax_boost_unit_test_framework.m4
+++ b/build-aux/m4/ax_boost_unit_test_framework.m4
diff --git a/src/m4/ax_check_compile_flag.m4 b/build-aux/m4/ax_check_compile_flag.m4
index c3a8d695a1..c3a8d695a1 100644
--- a/src/m4/ax_check_compile_flag.m4
+++ b/build-aux/m4/ax_check_compile_flag.m4
diff --git a/src/m4/ax_check_link_flag.m4 b/build-aux/m4/ax_check_link_flag.m4
index e2d0d363e4..e2d0d363e4 100644
--- a/src/m4/ax_check_link_flag.m4
+++ b/build-aux/m4/ax_check_link_flag.m4
diff --git a/src/m4/ax_check_preproc_flag.m4 b/build-aux/m4/ax_check_preproc_flag.m4
index b1cfef6b86..b1cfef6b86 100644
--- a/src/m4/ax_check_preproc_flag.m4
+++ b/build-aux/m4/ax_check_preproc_flag.m4
diff --git a/src/m4/ax_pthread.m4 b/build-aux/m4/ax_pthread.m4
index d383ad5c6d..d383ad5c6d 100644
--- a/src/m4/ax_pthread.m4
+++ b/build-aux/m4/ax_pthread.m4
diff --git a/src/m4/bitcoin_find_bdb48.m4 b/build-aux/m4/bitcoin_find_bdb48.m4
index 5223163fe5..f3b14461eb 100644
--- a/src/m4/bitcoin_find_bdb48.m4
+++ b/build-aux/m4/bitcoin_find_bdb48.m4
@@ -12,29 +12,29 @@ AC_DEFUN([BITCOIN_FIND_BDB48],[
done
for searchpath in $bdbdirlist ''; do
test -n "${searchpath}" && searchpath="${searchpath}/"
- AC_TRY_COMPILE([
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <${searchpath}db_cxx.h>
- ],[
+ ]],[[
#if !((DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 8) || DB_VERSION_MAJOR > 4)
#error "failed to find bdb 4.8+"
#endif
- ],[
+ ]])],[
if test "x$bdbpath" = "xX"; then
bdbpath="${searchpath}"
fi
],[
continue
])
- AC_TRY_COMPILE([
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <${searchpath}db_cxx.h>
- ],[
+ ]],[[
#if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8)
#error "failed to find bdb 4.8"
#endif
- ],[
+ ]])],[
bdb48path="${searchpath}"
break
- ])
+ ],[])
done
if test "x$bdbpath" = "xX"; then
AC_MSG_RESULT([no])
diff --git a/src/m4/bitcoin_qt.m4 b/build-aux/m4/bitcoin_qt.m4
index e141033b19..edfde4cd79 100644
--- a/src/m4/bitcoin_qt.m4
+++ b/build-aux/m4/bitcoin_qt.m4
@@ -217,17 +217,17 @@ dnl Requires: INCLUDES must be populated as necessary.
dnl Output: bitcoin_cv_qt5=yes|no
AC_DEFUN([_BITCOIN_QT_CHECK_QT5],[
AC_CACHE_CHECK(for Qt 5, bitcoin_cv_qt5,[
- AC_TRY_COMPILE(
- [#include <QtCore>],
- [
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+ [[#include <QtCore>]],
+ [[
#if QT_VERSION < 0x050000
choke me
#else
return 0;
#endif
- ],
- bitcoin_cv_qt5=yes,
- bitcoin_cv_qt5=no)
+ ]])],
+ [bitcoin_cv_qt5=yes],
+ [bitcoin_cv_qt5=no])
])])
dnl Internal. Check if the linked version of Qt was built as static libs.
@@ -237,15 +237,15 @@ dnl Output: bitcoin_cv_static_qt=yes|no
dnl Output: Defines QT_STATICPLUGIN if plugins are static.
AC_DEFUN([_BITCOIN_QT_IS_STATIC],[
AC_CACHE_CHECK(for static Qt, bitcoin_cv_static_qt,[
- AC_TRY_COMPILE(
- [#include <QtCore>],
- [
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+ [[#include <QtCore>]],
+ [[
#if defined(QT_STATIC)
return 0;
#else
choke me
#endif
- ],
+ ]])],
[bitcoin_cv_static_qt=yes],
[bitcoin_cv_static_qt=no])
])
@@ -263,13 +263,13 @@ AC_DEFUN([_BITCOIN_QT_CHECK_STATIC_PLUGINS],[
AC_MSG_CHECKING(for static Qt plugins: $2)
CHECK_STATIC_PLUGINS_TEMP_LIBS="$LIBS"
LIBS="$2 $QT_LIBS $LIBS"
- AC_TRY_LINK([
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#define QT_STATICPLUGIN
#include <QtPlugin>
- $1],
- [return 0;],
+ $1]],
+ [[return 0;]])],
[AC_MSG_RESULT(yes); QT_LIBS="$2 $QT_LIBS"],
- [AC_MSG_RESULT(no)]; BITCOIN_QT_FAIL(Could not resolve: $2))
+ [AC_MSG_RESULT(no); BITCOIN_QT_FAIL(Could not resolve: $2)])
LIBS="$CHECK_STATIC_PLUGINS_TEMP_LIBS"
])
diff --git a/src/m4/bitcoin_subdir_to_include.m4 b/build-aux/m4/bitcoin_subdir_to_include.m4
index 66f106c7d4..66f106c7d4 100644
--- a/src/m4/bitcoin_subdir_to_include.m4
+++ b/build-aux/m4/bitcoin_subdir_to_include.m4
diff --git a/configure.ac b/configure.ac
index 6dc71292df..0f9e78b74f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,8 +7,10 @@ define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, false)
define(_COPYRIGHT_YEAR, 2014)
AC_INIT([Bitcoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@bitcoin.org],[bitcoin])
-AC_CONFIG_AUX_DIR([src/build-aux])
-AC_CONFIG_MACRO_DIR([src/m4])
+AC_CONFIG_SRCDIR([src/main.cpp])
+AC_CONFIG_HEADERS([src/config/bitcoin-config.h])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIR([build-aux/m4])
LT_INIT([disable-shared])
AC_CANONICAL_HOST
AH_TOP([#ifndef BITCOIN_CONFIG_H])
@@ -44,6 +46,30 @@ AM_MAINTAINER_MODE([enable])
dnl make the compilation flags quiet unless V=1 is used
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+dnl Checks for programs.
+AC_PROG_CXX
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_CXXCPP
+AC_PROG_INSTALL
+AC_PROG_OBJC
+AC_PROG_LN_S
+m4_ifdef([AC_PROG_OBJCXX],[AC_PROG_OBJCXX])
+AC_PROG_MKDIR_P
+AC_PROG_SED
+AC_PATH_TOOL(AR, ar)
+AC_PATH_TOOL(RANLIB, ranlib)
+AC_PATH_TOOL(STRIP, strip)
+AC_PATH_TOOL(GCOV, gcov)
+AC_PATH_PROG(LCOV, lcov)
+AC_PATH_PROG(JAVA, java)
+AC_PATH_PROG(GENHTML, genhtml)
+AC_PATH_PROG([GIT], [git])
+AC_PATH_PROG(CCACHE,ccache)
+AC_PATH_PROG(XGETTEXT,xgettext)
+AC_PATH_PROG(HEXDUMP,hexdump)
+PKG_PROG_PKG_CONFIG
+
# Enable wallet
AC_ARG_ENABLE([wallet],
[AS_HELP_STRING([--enable-wallet],
@@ -116,34 +142,6 @@ AC_ARG_ENABLE([glibc-back-compat],
AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[specify protoc bin path])], [protoc_bin_path=$withval], [])
-
-AC_CONFIG_SRCDIR([src])
-AC_CONFIG_HEADERS([src/config/bitcoin-config.h])
-
-dnl Checks for programs.
-AC_PROG_CXX
-AC_PROG_CC
-AC_PROG_CPP
-AC_PROG_CXXCPP
-AC_PROG_INSTALL
-AC_PROG_OBJC
-AC_PROG_LN_S
-m4_ifdef([AC_PROG_OBJCXX],[AC_PROG_OBJCXX])
-AC_PROG_MKDIR_P
-AC_PROG_SED
-AC_PATH_TOOL(AR, ar)
-AC_PATH_TOOL(RANLIB, ranlib)
-AC_PATH_TOOL(STRIP, strip)
-AC_PATH_TOOL(GCOV, gcov)
-AC_PATH_PROG(LCOV, lcov)
-AC_PATH_PROG(JAVA, java)
-AC_PATH_PROG(GENHTML, genhtml)
-AC_PATH_PROG([GIT], [git])
-AC_PATH_PROG(CCACHE,ccache)
-AC_PATH_PROG(XGETTEXT,xgettext)
-AC_PATH_PROG(HEXDUMP,hexdump)
-PKG_PROG_PKG_CONFIG
-
# Enable debug
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
@@ -337,12 +335,12 @@ if test x$use_glibc_compat != xno; then
#__fdelt_chk's params and return type have changed from long unsigned int to long int.
# See which one is present here.
AC_MSG_CHECKING(__fdelt_chk type)
- AC_TRY_COMPILE([#ifdef _FORTIFY_SOURCE
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef _FORTIFY_SOURCE
#undef _FORTIFY_SOURCE
#endif
#define _FORTIFY_SOURCE 2
#include <sys/select.h>
- extern "C" long unsigned int __fdelt_warn(long unsigned int);],[],
+ extern "C" long unsigned int __fdelt_warn(long unsigned int);]],[[]])],
[ fdelt_type="long unsigned int"],
[ fdelt_type="long int"])
AC_MSG_RESULT($fdelt_type)
@@ -394,8 +392,8 @@ AC_CHECK_DECLS([le32toh, le64toh, htole32, htole64, be32toh, be64toh, htobe32, h
dnl Check for MSG_NOSIGNAL
AC_MSG_CHECKING(for MSG_NOSIGNAL)
-AC_TRY_COMPILE([#include <sys/socket.h>],
- [ int f = MSG_NOSIGNAL; ],
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]],
+ [[ int f = MSG_NOSIGNAL; ]])],
[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MSG_NOSIGNAL, 1,[Define this symbol if you have MSG_NOSIGNAL]) ],
[ AC_MSG_RESULT(no)]
)
@@ -537,16 +535,16 @@ TEMP_LIBS="$LIBS"
LIBS="$BOOST_LIBS $BOOST_CHRONO_LIB $LIBS"
TEMP_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
-AC_TRY_LINK([
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <boost/thread/thread.hpp>
#include <boost/version.hpp>
- ],[
+ ]],[[
#if BOOST_VERSION >= 105000 && (!defined(BOOST_HAS_NANOSLEEP) || BOOST_VERSION >= 105200)
boost::this_thread::sleep_for(boost::chrono::milliseconds(0));
#else
choke me
#endif
- ],
+ ]])],
[boost_sleep=yes; BOOST_LIBS="$BOOST_LIBS $BOOST_CHRONO_LIB";
AC_DEFINE(HAVE_WORKING_BOOST_SLEEP_FOR, 1, [Define this symbol if boost sleep_for works])],
[boost_sleep=no])
@@ -559,17 +557,17 @@ TEMP_LIBS="$LIBS"
LIBS="$BOOST_LIBS $LIBS"
TEMP_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
-AC_TRY_LINK([
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <boost/version.hpp>
#include <boost/thread.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
- ],[
+ ]],[[
#if BOOST_VERSION <= 105600
boost::this_thread::sleep(boost::posix_time::milliseconds(0));
#else
choke me
#endif
- ],
+ ]])],
[boost_sleep=yes; AC_DEFINE(HAVE_WORKING_BOOST_SLEEP, 1, [Define this symbol if boost sleep works])],
[boost_sleep=no])
LIBS="$TEMP_LIBS"
diff --git a/contrib/debian/changelog b/contrib/debian/changelog
index 4f22567f85..fe910b65a5 100644
--- a/contrib/debian/changelog
+++ b/contrib/debian/changelog
@@ -1,3 +1,9 @@
+bitcoin (0.9.3-precise1) precise; urgency=medium
+
+ * New upstream releases.
+
+ -- Matt Corallo (BlueMatt) <matt@mattcorallo.com> Fri, 26 Sep 2014 12:01:00 -0700
+
bitcoin (0.9.1-precise1) precise; urgency=medium
* New upstream release.
diff --git a/contrib/debian/control b/contrib/debian/control
index ac635f43e0..a653260ad3 100644
--- a/contrib/debian/control
+++ b/contrib/debian/control
@@ -39,7 +39,6 @@ Description: peer-to-peer network based digital currency - daemon
Full transaction history is stored locally at each client. This
requires 20+ GB of space, slowly growing.
.
-
This package provides the daemon, bitcoind, and the CLI tool
bitcoin-cli to interact with the daemon.
diff --git a/contrib/init/README.md b/contrib/init/README.md
new file mode 100644
index 0000000000..d3fa966583
--- /dev/null
+++ b/contrib/init/README.md
@@ -0,0 +1,10 @@
+Sample configuration files for:
+
+SystemD: bitcoind.service
+Upstart: bitcoind.conf
+OpenRC: bitcoind.openrc
+ bitcoind.openrcconf
+
+have been made available to assist packagers in creating node packages here.
+
+See doc/init.md for more information.
diff --git a/contrib/init/bitcoind.conf b/contrib/init/bitcoind.conf
new file mode 100644
index 0000000000..f9554eecde
--- /dev/null
+++ b/contrib/init/bitcoind.conf
@@ -0,0 +1,65 @@
+description "Bitcoin Core Daemon"
+
+start on runlevel [2345]
+stop on starting rc RUNLEVEL=[016]
+
+env BITCOIND_BIN="/usr/bin/bitcoind"
+env BITCOIND_USER="bitcoin"
+env BITCOIND_GROUP="bitcoin"
+env BITCOIND_PIDDIR="/var/run/bitcoind"
+# upstart can't handle variables constructed with other variables
+env BITCOIND_PIDFILE="/var/run/bitcoind/bitcoind.pid"
+env BITCOIND_CONFIGFILE="/etc/bitcoin/bitcoin.conf"
+env BITCOIND_DATADIR="/var/lib/bitcoind"
+
+expect fork
+
+respawn
+respawn limit 5 120
+kill timeout 60
+
+pre-start script
+ # this will catch non-existent config files
+ # bitcoind will check and exit with this very warning, but it can do so
+ # long after forking, leaving upstart to think everything started fine.
+ # since this is a commonly encountered case on install, just check and
+ # warn here.
+ if ! grep -qs '^rpcpassword=' "$BITCOIND_CONFIGFILE" ; then
+ echo "ERROR: You must set a secure rpcpassword to run bitcoind."
+ echo "The setting must appear in $BITCOIND_CONFIGFILE"
+ echo
+ echo "This password is security critical to securing wallets "
+ echo "and must not be the same as the rpcuser setting."
+ echo "You can generate a suitable random password using the following"
+ echo "command from the shell:"
+ echo
+ echo "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
+ echo
+ echo "It is also recommended that you also set alertnotify so you are "
+ echo "notified of problems:"
+ echo
+ echo "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \
+ "admin@foo.com"
+ echo
+ exit 1
+ fi
+
+ mkdir -p "$BITCOIND_PIDDIR"
+ chmod 0755 "$BITCOIND_PIDDIR"
+ chown $BITCOIND_USER:$BITCOIND_GROUP "$BITCOIND_PIDDIR"
+ chown $BITCOIND_USER:$BITCOIND_GROUP "$BITCOIND_CONFIGFILE"
+ chmod 0660 "$BITCOIND_CONFIGFILE"
+end script
+
+exec start-stop-daemon \
+ --start \
+ --pidfile "$BITCOIND_PIDFILE" \
+ --chuid $BITCOIND_USER:$BITCOIND_GROUP \
+ --exec "$BITCOIND_BIN" \
+ -- \
+ -pid="$BITCOIND_PIDFILE" \
+ -conf="$BITCOIND_CONFIGFILE" \
+ -datadir="$BITCOIND_DATADIR" \
+ -disablewallet \
+ -daemon
+
diff --git a/contrib/init/bitcoind.openrc b/contrib/init/bitcoind.openrc
new file mode 100644
index 0000000000..1f7758c920
--- /dev/null
+++ b/contrib/init/bitcoind.openrc
@@ -0,0 +1,86 @@
+#!/sbin/runscript
+
+# backward compatibility for existing gentoo layout
+#
+if [ -d "/var/lib/bitcoin/.bitcoin" ]; then
+ BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoin/.bitcoin"
+else
+ BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoind"
+fi
+
+BITCOIND_CONFIGFILE=${BITCOIND_CONFIGFILE:-/etc/bitcoin/bitcoin.conf}
+BITCOIND_PIDDIR=${BITCOIND_PIDDIR:-/var/run/bitcoind}
+BITCOIND_PIDFILE=${BITCOIND_PIDFILE:-${BITCOIND_PIDDIR}/bitcoind.pid}
+BITCOIND_DATADIR=${BITCOIND_DATADIR:-${BITCOIND_DEFAULT_DATADIR}}
+BITCOIND_USER=${BITCOIND_USER:-bitcoin}
+BITCOIND_GROUP=${BITCOIND_GROUP:-bitcoin}
+BITCOIND_BIN=${BITCOIND_BIN:-/usr/bin/bitcoind}
+
+name="Bitcoin Core Daemon"
+description="Bitcoin crypto-currency p2p network daemon"
+
+command="/usr/bin/bitcoind"
+command_args="-pid=\"${BITCOIND_PIDFILE}\" \
+ -conf=\"${BITCOIND_CONFIGFILE}\" \
+ -datadir=\"${BITCOIND_DATADIR}\" \
+ -daemon \
+ ${BITCOIND_OPTS}"
+
+required_files="${BITCOIND_CONFIGFILE}"
+start_stop_daemon_args="-u ${BITCOIND_USER} \
+ -N ${BITCOIND_NICE:-0} -w 2000"
+pidfile="${BITCOIND_PIDFILE}"
+retry=60
+
+depend() {
+ need localmount net
+}
+
+# verify
+# 1) that the datadir exists and is writable (or create it)
+# 2) that a directory for the pid exists and is writable
+# 3) ownership and permissions on the config file
+start_pre() {
+ checkpath \
+ -d \
+ --mode 0750 \
+ --owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \
+ "${BITCOIND_DATADIR}"
+
+ checkpath \
+ -d \
+ --mode 0755 \
+ --owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \
+ "${BITCOIND_PIDDIR}"
+
+ checkpath -f \
+ -o ${BITCOIND_USER}:${BITCOIND_GROUP} \
+ -m 0660 \
+ ${BITCOIND_CONFIGFILE}
+
+ checkconfig || return 1
+}
+
+checkconfig()
+{
+ if ! grep -qs '^rpcpassword=' "${BITCOIND_CONFIGFILE}" ; then
+ eerror ""
+ eerror "ERROR: You must set a secure rpcpassword to run bitcoind."
+ eerror "The setting must appear in ${BITCOIND_CONFIGFILE}"
+ eerror ""
+ eerror "This password is security critical to securing wallets "
+ eerror "and must not be the same as the rpcuser setting."
+ eerror "You can generate a suitable random password using the following"
+ eerror "command from the shell:"
+ eerror ""
+ eerror "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
+ eerror ""
+ eerror "It is also recommended that you also set alertnotify so you are "
+ eerror "notified of problems:"
+ eerror ""
+ eerror "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \
+ "admin@foo.com"
+ eerror ""
+ return 1
+ fi
+}
diff --git a/contrib/init/bitcoind.openrcconf b/contrib/init/bitcoind.openrcconf
new file mode 100644
index 0000000000..d8d7f58337
--- /dev/null
+++ b/contrib/init/bitcoind.openrcconf
@@ -0,0 +1,27 @@
+# /etc/conf.d/bitcoind: config file for /etc/init.d/bitcoind
+
+# Config file location
+#BITCOIND_CONFIGFILE="/etc/bitcoin/bitcoin.conf"
+
+# What directory to write pidfile to? (created and owned by $BITCOIND_USER)
+#BITCOIND_PIDDIR="/var/run/bitcoind"
+
+# What filename to give the pidfile
+#BITCOIND_PIDFILE="${BITCOIND_PIDDIR}/bitcoind.pid"
+
+# Where to write bitcoind data (be mindful that the blockchain is large)
+#BITCOIND_DATADIR="/var/lib/bitcoind"
+
+# User and group to own bitcoind process
+#BITCOIND_USER="bitcoin"
+#BITCOIND_GROUP="bitcoin"
+
+# Path to bitcoind executable
+#BITCOIND_BIN="/usr/bin/bitcoind"
+
+# Nice value to run bitcoind under
+#BITCOIND_NICE=0
+
+# Additional options (avoid -conf and -datadir, use flags above)
+BITCOIND_OPTS="-disablewallet"
+
diff --git a/contrib/systemd/bitcoind.service b/contrib/init/bitcoind.service
index edc81cc763..9132957c38 100644
--- a/contrib/systemd/bitcoind.service
+++ b/contrib/init/bitcoind.service
@@ -3,15 +3,20 @@ Description=Bitcoin's distributed currency daemon
After=network.target
[Service]
-User=bitcoind
-Group=bitcoind
+User=bitcoin
+Group=bitcoin
Type=forking
PIDFile=/var/lib/bitcoind/bitcoind.pid
-ExecStart=/usr/bin/bitcoind -daemon -pid=/var/lib/bitcoind/bitcoind.pid -conf=/etc/bitcoind.conf -datadir=/var/lib/bitcoind
+ExecStart=/usr/bin/bitcoind -daemon -pid=/var/lib/bitcoind/bitcoind.pid \
+-conf=/etc/bitcoin/bitcoin.conf -datadir=/var/lib/bitcoind -disablewallet
Restart=always
PrivateTmp=true
+TimeoutStopSec=60s
+TimeoutStartSec=2s
+StartLimitInterval=120s
+StartLimitBurst=5
[Install]
WantedBy=multi-user.target
diff --git a/contrib/linearize/linearize-data.py b/contrib/linearize/linearize-data.py
index 383bb38198..3b5d198c14 100755
--- a/contrib/linearize/linearize-data.py
+++ b/contrib/linearize/linearize-data.py
@@ -110,7 +110,11 @@ def copydata(settings, blkindex, blkset):
if not inF:
fname = "%s/blk%05d.dat" % (settings['input'], inFn)
print("Input file" + fname)
- inF = open(fname, "rb")
+ try:
+ inF = open(fname, "rb")
+ except IOError:
+ print "Done"
+ return
inhdr = inF.read(8)
if (not inhdr or (inhdr[0] == "\0")):
diff --git a/contrib/macdeploy/macdeployqtplus b/contrib/macdeploy/macdeployqtplus
index 23b57a76b3..5ab6a222dd 100755
--- a/contrib/macdeploy/macdeployqtplus
+++ b/contrib/macdeploy/macdeployqtplus
@@ -37,7 +37,10 @@ class FrameworkInfo(object):
self.sourceFilePath = ""
self.destinationDirectory = ""
self.sourceResourcesDirectory = ""
+ self.sourceVersionContentsDirectory = ""
+ self.sourceContentsDirectory = ""
self.destinationResourcesDirectory = ""
+ self.destinationVersionContentsDirectory = ""
def __eq__(self, other):
if self.__class__ == other.__class__:
@@ -141,7 +144,11 @@ class FrameworkInfo(object):
info.destinationDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, info.binaryDirectory)
info.sourceResourcesDirectory = os.path.join(info.frameworkPath, "Resources")
+ info.sourceContentsDirectory = os.path.join(info.frameworkPath, "Contents")
+ info.sourceVersionContentsDirectory = os.path.join(info.frameworkPath, "Versions", info.version, "Contents")
info.destinationResourcesDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, "Resources")
+ info.destinationContentsDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, "Contents")
+ info.destinationVersionContentsDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, "Versions", info.version, "Contents")
return info
@@ -275,6 +282,13 @@ def copyFramework(framework, path, verbose):
os.chmod(toPath, permissions.st_mode | stat.S_IWRITE)
if not framework.isDylib(): # Copy resources for real frameworks
+
+ linkfrom = os.path.join(path, "Contents/Frameworks/", framework.frameworkName, framework.binaryName)
+ linkto = os.path.join(framework.binaryPath)
+ if not os.path.exists(linkfrom):
+ os.symlink(linkto, linkfrom)
+ if verbose >= 2:
+ print "Linked:", linkfrom, "->", linkto
fromResourcesDir = framework.sourceResourcesDirectory
if os.path.exists(fromResourcesDir):
toResourcesDir = os.path.join(path, framework.destinationResourcesDirectory)
@@ -282,6 +296,21 @@ def copyFramework(framework, path, verbose):
if verbose >= 3:
print "Copied resources:", fromResourcesDir
print " to:", toResourcesDir
+ fromContentsDir = framework.sourceVersionContentsDirectory
+ if not os.path.exists(fromContentsDir):
+ fromContentsDir = framework.sourceContentsDirectory
+ if os.path.exists(fromContentsDir):
+ toContentsDir = os.path.join(path, framework.destinationVersionContentsDirectory)
+ shutil.copytree(fromContentsDir, toContentsDir)
+ contentslinkfrom = os.path.join(path, framework.destinationContentsDirectory)
+ if not os.path.exists(contentslinkfrom):
+ contentslinkto = os.path.join("Versions/", framework.version, "Contents")
+ os.symlink(contentslinkto, contentslinkfrom)
+ if verbose >= 3:
+ print "Linked:", contentslinkfrom, "->", contentslinkto
+ if verbose >= 3:
+ print "Copied Contents:", fromContentsDir
+ print " to:", toContentsDir
elif framework.frameworkName.startswith("libQtGui"): # Copy qt_menu.nib (applies to non-framework layout)
qtMenuNibSourcePath = os.path.join(framework.frameworkDirectory, "Resources", "qt_menu.nib")
qtMenuNibDestinationPath = os.path.join(path, "Contents", "Resources", "qt_menu.nib")
diff --git a/depends/config.site.in b/depends/config.site.in
index 4012f5a8d1..1df04eec3f 100644
--- a/depends/config.site.in
+++ b/depends/config.site.in
@@ -52,7 +52,7 @@ export PATH=$prefix/native/bin:$PATH
export PKG_CONFIG="`which pkg-config` --static"
export PKG_CONFIG_LIBDIR=$prefix/lib/pkgconfig
export PKG_CONFIG_PATH=$prefix/share/pkgconfig
-export CPPFLAGS=-I$prefix/include/
+export CPPFLAGS="-I$prefix/include/ $CPPFLAGS"
export CC="@CC@"
export CXX="@CXX@"
diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk
index cce7d6e6ef..e719e2e506 100644
--- a/depends/packages/qt.mk
+++ b/depends/packages/qt.mk
@@ -7,7 +7,7 @@ $(package)_dependencies=openssl
$(package)_linux_dependencies=freetype fontconfig dbus libxcb libX11 xproto libXext
$(package)_build_subdir=qtbase
$(package)_qt_libs=corelib network widgets gui plugins testlib
-$(package)_patches=mac-qmake.conf fix-xcb-include-order.patch
+$(package)_patches=mac-qmake.conf fix-xcb-include-order.patch qt5-tablet-osx.patch
define $(package)_set_vars
$(package)_config_opts = -release -opensource -confirm-license
@@ -52,7 +52,8 @@ define $(package)_preprocess_cmds
cp -f qtbase/mkspecs/macx-clang/Info.plist.app qtbase/mkspecs/macx-clang-linux/ &&\
cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\
cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \
- patch -p1 < $($(package)_patch_dir)/fix-xcb-include-order.patch
+ patch -p1 < $($(package)_patch_dir)/fix-xcb-include-order.patch && \
+ patch -p1 < $($(package)_patch_dir)/qt5-tablet-osx.patch
endef
define $(package)_config_cmds
diff --git a/depends/patches/qt/qt5-tablet-osx.patch b/depends/patches/qt/qt5-tablet-osx.patch
new file mode 100644
index 0000000000..7deabf8d4e
--- /dev/null
+++ b/depends/patches/qt/qt5-tablet-osx.patch
@@ -0,0 +1,20 @@
+--- old/qtbase/src/widgets/kernel/qwidgetwindow.cpp 2014-09-05 20:45:18.717570370 -0400
++++ new/qtbase/src/widgets/kernel/qwidgetwindow.cpp 2014-09-05 20:52:38.653576561 -0400
+@@ -57,7 +57,7 @@
+ Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets();
+
+ QWidget *qt_button_down = 0; // widget got last button-down
+-static QWidget *qt_tablet_target = 0;
++static QPointer<QWidget> qt_tablet_target = 0;
+
+ // popup control
+ QWidget *qt_popup_down = 0; // popup that contains the pressed widget
+@@ -96,8 +96,6 @@
+
+ QWidgetWindow::~QWidgetWindow()
+ {
+- if (m_widget == qt_tablet_target)
+- qt_tablet_target = 0;
+ }
+
+ #ifndef QT_NO_ACCESSIBILITY
diff --git a/doc/README.md b/doc/README.md
index 10c9ad1799..d5d61738e8 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -67,7 +67,7 @@ The Bitcoin repo's [root README](https://github.com/bitcoin/bitcoin/blob/master/
- [Assets Attribution](assets-attribution.md)
- [Files](files.md)
- [Tor Support](tor.md)
-- [Systemd](systemd.md)
+- [Init Scripts (systemd/upstart/openrc)](init.md)
License
---------------------
diff --git a/doc/build-osx.md b/doc/build-osx.md
index ade9eb466b..0364d3a01b 100644
--- a/doc/build-osx.md
+++ b/doc/build-osx.md
@@ -26,44 +26,14 @@ There's also an assumption that you already have `git` installed. If
not, it's the path of least resistance to install [Github for Mac](https://mac.github.com/)
(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.
+available via Homebrew.
-You will also need to install [Homebrew](http://brew.sh)
-or [MacPorts](https://www.macports.org/) in order to install library
-dependencies. It's largely a religious decision which to choose, however, Homebrew
-is now used for building release versions.
+You will also need to install [Homebrew](http://brew.sh) in order to install library
+dependencies.
The installation of the actual dependencies is covered in the Instructions
sections below.
-Instructions: MacPorts
-----------------------
-
-### Install dependencies
-
- sudo port install boost db48@+no_java openssl miniupnpc autoconf pkgconfig automake libtool
-
-Optional: install Qt4
-
- sudo port install qt4-mac qrencode protobuf-cpp
-
-### 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 (and Bitcoin-Qt, if configured):
-
- ./autogen.sh
- ./configure
- make
-
-3. It is a good idea to build and run the unit tests, too:
-
- make check
-
Instructions: Homebrew
----------------------
@@ -80,7 +50,7 @@ Running this command takes you into brew's interactive mode, which allows you to
$ brew install https://raw.github.com/mxcl/homebrew/master/Library/Formula/berkeley-db4.rb -–without-java
```
-These rest of these commands are run inside brew interactive mode:
+The rest of these commands are run inside brew interactive mode:
```
/private/tmp/berkeley-db4-UGpd0O/db-4.8.30 $ cd ..
/private/tmp/berkeley-db4-UGpd0O $ db-4.8.30/dist/configure --prefix=/usr/local/Cellar/berkeley-db4/4.8.30 --mandir=/usr/local/Cellar/berkeley-db4/4.8.30/share/man --enable-cxx
@@ -91,7 +61,7 @@ These rest of these commands are run inside brew interactive mode:
After exiting, you'll get a warning that the install is keg-only, which means it wasn't symlinked to `/usr/local`. You don't need it to link it to build bitcoin, but if you want to, here's how:
- $ brew --force link berkeley-db4
+ $ brew link --force berkeley-db4
### Building `bitcoind`
@@ -126,18 +96,6 @@ All dependencies should be compiled with these flags:
-arch x86_64
-isysroot $(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk
-For MacPorts, that means editing your macports.conf and setting
-`macosx_deployment_target` and `build_arch`:
-
- macosx_deployment_target=10.6
- build_arch=x86_64
-
-... 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 `https://gavinandresen-bitcoin.s3.amazonaws.com/boost_macports_fix.zip`
-for a fix.
-
Once dependencies are compiled, see release-process.md for how the Bitcoin-Qt.app
bundle is packaged and signed to create the .dmg disk image that is distributed.
diff --git a/doc/init.md b/doc/init.md
new file mode 100644
index 0000000000..3d14025ab4
--- /dev/null
+++ b/doc/init.md
@@ -0,0 +1,92 @@
+Sample init scripts and service configuration for bitcoind
+==========================================================
+
+Sample scripts and configuration files for systemd, Upstart and OpenRC
+can be found in the contrib/init folder.
+
+contrib/init/bitcoind.service: systemd service unit configuration
+contrib/init/bitcoind.openrc: OpenRC compatible SysV style init script
+contrib/init/bitcoind.openrcconf: OpenRC conf.d file
+contrib/init/bitcoind.conf: Upstart service configuration file
+
+1. Service User
+---------------------------------
+
+All three startup configurations assume the existence of a "bitcoin" user
+and group. They must be created before attempting to use these scripts.
+
+2. Configuration
+---------------------------------
+
+At a bare minimum, bitcoind requires that the rpcpassword setting be set
+when running as a daemon. If the configuration file does not exist or this
+setting is not set, bitcoind will shutdown promptly after startup.
+
+This password does not have to be remembered or typed as it is mostly used
+as a fixed token that bitcoind and client programs read from the configuration
+file, however it is recommended that a strong and secure password be used
+as this password is security critical to securing the wallet should the
+wallet be enabled.
+
+If bitcoind is run with "-daemon" flag, and no rpcpassword is set, it will
+print a randomly generated suitable password to stderr. You can also
+generate one from the shell yourself like this:
+
+bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'
+
+Once you have a password in hand, set rpcpassword= in /etc/bitcoin/bitcoin.conf
+
+For an example configuration file that describes the configuration settings,
+see contrib/debian/examples/bitcoin.conf.
+
+3. Paths
+---------------------------------
+
+All three configurations assume several paths that might need to be adjusted.
+
+Binary: /usr/bin/bitcoind
+Configuration file: /etc/bitcoin/bitcoin.conf
+Data directory: /var/lib/bitcoind
+PID file: /var/run/bitcoind/bitcoind.pid (OpenRC and Upstart)
+ /var/lib/bitcoind/bitcoind.pid (systemd)
+
+The configuration file, PID directory (if applicable) and data directory
+should all be owned by the bitcoin user and group. It is advised for security
+reasons to make the configuration file and data directory only readable by the
+bitcoin user and group. Access to bitcoin-cli and other bitcoind rpc clients
+can then be controlled by group membership.
+
+4. Installing Service Configuration
+-----------------------------------
+
+4a) systemd
+
+Installing this .service file consists on just copying it to
+/usr/lib/systemd/system directory, followed by the command
+"systemctl daemon-reload" in order to update running systemd configuration.
+
+To test, run "systemctl start bitcoind" and to enable for system startup run
+"systemctl enable bitcoind"
+
+4b) OpenRC
+
+Rename bitcoind.openrc to bitcoind and drop it in /etc/init.d. Double
+check ownership and permissions and make it executable. Test it with
+"/etc/init.d/bitcoind start" and configure it to run on startup with
+"rc-update add bitcoind"
+
+4c) Upstart (for Debian/Ubuntu based distributions)
+
+Drop bitcoind.conf in /etc/init. Test by running "service bitcoind start"
+it will automatically start on reboot.
+
+NOTE: This script is incompatible with CentOS 5 and Amazon Linux 2014 as they
+use old versions of Upstart and do not supply the start-stop-daemon uitility.
+
+5. Auto-respawn
+-----------------------------------
+
+Auto respawning is currently only configured for Upstart and systemd.
+Reasonable defaults have been chosen but YMMV.
+
+
diff --git a/doc/release-process.md b/doc/release-process.md
index c5ead4199b..5b8029955d 100644
--- a/doc/release-process.md
+++ b/doc/release-process.md
@@ -64,7 +64,7 @@ Release Process
wget 'http://www.opensource.apple.com/tarballs/cctools/cctools-809.tar.gz'
wget 'http://www.opensource.apple.com/tarballs/dyld/dyld-195.5.tar.gz'
wget 'http://www.opensource.apple.com/tarballs/ld64/ld64-127.2.tar.gz'
- wget 'http://cdrkit.org/releases/cdrkit-1.1.11.tar.gz'
+ wget 'http://pkgs.fedoraproject.org/repo/pkgs/cdrkit/cdrkit-1.1.11.tar.gz/efe08e2f3ca478486037b053acd512e9/cdrkit-1.1.11.tar.gz'
wget 'https://github.com/theuni/libdmg-hfsplus/archive/libdmg-hfsplus-v0.1.tar.gz'
wget 'http://llvm.org/releases/3.2/clang+llvm-3.2-x86-linux-ubuntu-12.04.tar.gz' -O clang-llvm-3.2-x86-linux-ubuntu-12.04.tar.gz
wget 'https://raw.githubusercontent.com/theuni/osx-cross-depends/master/patches/cdrtools/genisoimage.diff' -O cdrkit-deterministic.patch
@@ -178,15 +178,11 @@ Commit your signature to gitian.sigs:
Note: only Gavin has the code-signing keys currently.
-- Create `SHA256SUMS.asc` for builds, and PGP-sign it. This is done manually.
- Include all the files to be uploaded. The file has `sha256sum` format with a
- simple header at the top:
-
-```
-Hash: SHA256
-
-0060f7d38b98113ab912d4c184000291d7f026eaf77ca5830deec15059678f54 bitcoin-x.y.z-linux.tar.gz
-...
+- Create `SHA256SUMS.asc` for the builds, and GPG-sign it:
+```bash
+sha256sum * > SHA256SUMS
+gpg --clearsign SHA256SUMS # outputs SHA256SUMS.asc
+rm SHA256SUMS
```
- Upload zips and installers, as well as `SHA256SUMS.asc` from last step, to the bitcoin.org server
diff --git a/doc/systemd.md b/doc/systemd.md
deleted file mode 100644
index 96202c1532..0000000000
--- a/doc/systemd.md
+++ /dev/null
@@ -1,47 +0,0 @@
-SYSTEMD SUPPORT IN BITCOIN
-==========================
-
-Packagers can find a .service file in this repo in order to integrate bitcoin's
-daemon into systemd based distributions.
-
-bitcoind.service file is located in contrib/systemd/ folder.
-
-1. Users
----------------------------------
-
-This .service file assumes bitcoind user and group exist in the system, so packager
-should make sure they are created on installation.
-
-2. Files
----------------------------------
-
-The .service file assumes several paths that might need to be adjusted according
-to packager's needs.
-
-Daemon's config file is assumed to be located at /etc/bitcoind.conf (you can
-use contrib/debian/examples/bitcoin.conf as an example). Once installed, users
-must edit the file in order to update at least these two
-values: rpcuser and rpcpassword . Failing to do so will make the daemon fail
-to boot. However, the message written to /var/lib/bitcoind/debug.log file is
-very helpful and no default values should be set:
-
- YYYY-MM-DD HH:MM:DD Error: To use the "-server" option, you must set a rpcpassword in the configuration file:
- /etc/bitcoind.conf
- It is recommended you use the following random password:
- rpcuser=bitcoinrpc
- rpcpassword=HdYZ5HGtAF7mx8aTw6uCATtD2maMAK4E12Ysp4YNZQcX
- (you do not need to remember this password)
- The username and password MUST NOT be the same.
- If the file does not exist, create it with owner-readable-only file permissions.
- It is also recommended to set alertnotify so you are notified of problems;
- for example: alertnotify=echo %s | mail -s "Bitcoin Alert" admin@foo.com
-
-Daemon's data and pid files will be stored in /var/lib/bitcoind directory, so it
-should be created on installation and make bitcoind user/group it's owner.
-
-3. Installing .service file
----------------------------------
-
-Installing this .service file consists on just copying it to /usr/lib/systemd/system
-directory, followed by the command "systemctl daemon-reload" in order to update
-running systemd configuration.
diff --git a/share/genbuild.sh b/share/genbuild.sh
index 0800b31229..679566e596 100755
--- a/share/genbuild.sh
+++ b/share/genbuild.sh
@@ -16,7 +16,7 @@ fi
DESC=""
SUFFIX=""
LAST_COMMIT_DATE=""
-if [ -e "$(which git 2>/dev/null)" -a -d ".git" ]; then
+if [ -e "$(which git 2>/dev/null)" -a $(git rev-parse --is-inside-work-tree 2>/dev/null) = "true" ]; then
# clean 'dirty' status of touched files that haven't been modified
git diff >/dev/null 2>/dev/null
diff --git a/src/Makefile.am b/src/Makefile.am
index 56e141532a..2c64cb74a0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -99,12 +99,11 @@ BITCOIN_CORE_H = \
rpcclient.h \
rpcprotocol.h \
rpcserver.h \
- script/interpreter.h \
script/compressor.h \
+ script/interpreter.h \
script/script.h \
script/sign.h \
script/standard.h \
- scriptutils.h \
serialize.h \
sync.h \
threadsafety.h \
@@ -119,8 +118,9 @@ BITCOIN_CORE_H = \
utilmoneystr.h \
utiltime.h \
version.h \
- walletdb.h \
wallet.h \
+ wallet_ismine.h \
+ walletdb.h \
compat/sanity.h
JSON_H = \
@@ -176,6 +176,7 @@ libbitcoin_wallet_a_SOURCES = \
rpcdump.cpp \
rpcwallet.cpp \
wallet.cpp \
+ wallet_ismine.cpp \
walletdb.cpp \
$(BITCOIN_CORE_H)
@@ -213,12 +214,11 @@ libbitcoin_common_a_SOURCES = \
keystore.cpp \
netbase.cpp \
protocol.cpp \
- script/interpreter.cpp \
script/compressor.cpp \
+ script/interpreter.cpp \
script/script.cpp \
script/sign.cpp \
script/standard.cpp \
- scriptutils.cpp \
$(BITCOIN_CORE_H)
# util: shared between all executables.
diff --git a/src/Makefile.test.include b/src/Makefile.test.include
index b4360831bb..ab449f3e71 100644
--- a/src/Makefile.test.include
+++ b/src/Makefile.test.include
@@ -13,7 +13,8 @@ EXTRA_DIST += \
test/data/tt-delout1-out.hex \
test/data/tt-locktime317000-out.hex \
test/data/tx394b54bb.hex \
- test/data/txcreate1.hex
+ test/data/txcreate1.hex \
+ test/data/txcreate2.hex
JSON_TEST_FILES = \
test/data/script_valid.json \
diff --git a/src/addrman.cpp b/src/addrman.cpp
index 68948ac7ff..7b674a66e7 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -9,7 +9,7 @@
using namespace std;
-int CAddrInfo::GetTriedBucket(const std::vector<unsigned char> &nKey) const
+int CAddrInfo::GetTriedBucket(const std::vector<unsigned char>& nKey) const
{
CDataStream ss1(SER_GETHASH, 0);
std::vector<unsigned char> vchKey = GetKey();
@@ -23,7 +23,7 @@ int CAddrInfo::GetTriedBucket(const std::vector<unsigned char> &nKey) const
return hash2 % ADDRMAN_TRIED_BUCKET_COUNT;
}
-int CAddrInfo::GetNewBucket(const std::vector<unsigned char> &nKey, const CNetAddr& src) const
+int CAddrInfo::GetNewBucket(const std::vector<unsigned char>& nKey, const CNetAddr& src) const
{
CDataStream ss1(SER_GETHASH, 0);
std::vector<unsigned char> vchGroupKey = GetGroup();
@@ -39,19 +39,19 @@ int CAddrInfo::GetNewBucket(const std::vector<unsigned char> &nKey, const CNetAd
bool CAddrInfo::IsTerrible(int64_t nNow) const
{
- if (nLastTry && nLastTry >= nNow-60) // never remove things tried the last minute
+ if (nLastTry && nLastTry >= nNow - 60) // never remove things tried the last minute
return false;
- if (nTime > nNow + 10*60) // came in a flying DeLorean
+ if (nTime > nNow + 10 * 60) // came in a flying DeLorean
return true;
- if (nTime==0 || nNow-nTime > ADDRMAN_HORIZON_DAYS*24*60*60) // not seen in recent history
+ if (nTime == 0 || nNow - nTime > ADDRMAN_HORIZON_DAYS * 24 * 60 * 60) // not seen in recent history
return true;
- if (nLastSuccess==0 && nAttempts>=ADDRMAN_RETRIES) // tried N times and never a success
+ if (nLastSuccess == 0 && nAttempts >= ADDRMAN_RETRIES) // tried N times and never a success
return true;
- if (nNow-nLastSuccess > ADDRMAN_MIN_FAIL_DAYS*24*60*60 && nAttempts>=ADDRMAN_MAX_FAILURES) // N successive failures in the last week
+ if (nNow - nLastSuccess > ADDRMAN_MIN_FAIL_DAYS * 24 * 60 * 60 && nAttempts >= ADDRMAN_MAX_FAILURES) // N successive failures in the last week
return true;
return false;
@@ -64,23 +64,25 @@ double CAddrInfo::GetChance(int64_t nNow) const
int64_t nSinceLastSeen = nNow - nTime;
int64_t nSinceLastTry = nNow - nLastTry;
- if (nSinceLastSeen < 0) nSinceLastSeen = 0;
- if (nSinceLastTry < 0) nSinceLastTry = 0;
+ if (nSinceLastSeen < 0)
+ nSinceLastSeen = 0;
+ if (nSinceLastTry < 0)
+ nSinceLastTry = 0;
fChance *= 600.0 / (600.0 + nSinceLastSeen);
// deprioritize very recent attempts away
- if (nSinceLastTry < 60*10)
+ if (nSinceLastTry < 60 * 10)
fChance *= 0.01;
// deprioritize 50% after each failed attempt
- for (int n=0; n<nAttempts; n++)
+ for (int n = 0; n < nAttempts; n++)
fChance /= 1.5;
return fChance;
}
-CAddrInfo* CAddrMan::Find(const CNetAddr& addr, int *pnId)
+CAddrInfo* CAddrMan::Find(const CNetAddr& addr, int* pnId)
{
std::map<CNetAddr, int>::iterator it = mapAddr.find(addr);
if (it == mapAddr.end())
@@ -93,7 +95,7 @@ CAddrInfo* CAddrMan::Find(const CNetAddr& addr, int *pnId)
return NULL;
}
-CAddrInfo* CAddrMan::Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId)
+CAddrInfo* CAddrMan::Create(const CAddress& addr, const CNetAddr& addrSource, int* pnId)
{
int nId = nIdCount++;
mapInfo[nId] = CAddrInfo(addr, addrSource);
@@ -127,22 +129,21 @@ void CAddrMan::SwapRandom(unsigned int nRndPos1, unsigned int nRndPos2)
int CAddrMan::SelectTried(int nKBucket)
{
- std::vector<int> &vTried = vvTried[nKBucket];
+ std::vector<int>& vTried = vvTried[nKBucket];
// random shuffle the first few elements (using the entire list)
// find the least recently tried among them
int64_t nOldest = -1;
int nOldestPos = -1;
- for (unsigned int i = 0; i < ADDRMAN_TRIED_ENTRIES_INSPECT_ON_EVICT && i < vTried.size(); i++)
- {
+ for (unsigned int i = 0; i < ADDRMAN_TRIED_ENTRIES_INSPECT_ON_EVICT && i < vTried.size(); i++) {
int nPos = GetRandInt(vTried.size() - i) + i;
int nTemp = vTried[nPos];
vTried[nPos] = vTried[i];
vTried[i] = nTemp;
assert(nOldest == -1 || mapInfo.count(nTemp) == 1);
if (nOldest == -1 || mapInfo[nTemp].nLastSuccess < mapInfo[nOldest].nLastSuccess) {
- nOldest = nTemp;
- nOldestPos = nPos;
+ nOldest = nTemp;
+ nOldestPos = nPos;
}
}
@@ -152,18 +153,15 @@ int CAddrMan::SelectTried(int nKBucket)
int CAddrMan::ShrinkNew(int nUBucket)
{
assert(nUBucket >= 0 && (unsigned int)nUBucket < vvNew.size());
- std::set<int> &vNew = vvNew[nUBucket];
+ std::set<int>& vNew = vvNew[nUBucket];
// first look for deletable items
- for (std::set<int>::iterator it = vNew.begin(); it != vNew.end(); it++)
- {
+ for (std::set<int>::iterator it = vNew.begin(); it != vNew.end(); it++) {
assert(mapInfo.count(*it));
- CAddrInfo &info = mapInfo[*it];
- if (info.IsTerrible())
- {
- if (--info.nRefCount == 0)
- {
- SwapRandom(info.nRandomPos, vRandom.size()-1);
+ CAddrInfo& info = mapInfo[*it];
+ if (info.IsTerrible()) {
+ if (--info.nRefCount == 0) {
+ SwapRandom(info.nRandomPos, vRandom.size() - 1);
vRandom.pop_back();
mapAddr.erase(info);
mapInfo.erase(*it);
@@ -178,10 +176,8 @@ int CAddrMan::ShrinkNew(int nUBucket)
int n[4] = {GetRandInt(vNew.size()), GetRandInt(vNew.size()), GetRandInt(vNew.size()), GetRandInt(vNew.size())};
int nI = 0;
int nOldest = -1;
- for (std::set<int>::iterator it = vNew.begin(); it != vNew.end(); it++)
- {
- if (nI == n[0] || nI == n[1] || nI == n[2] || nI == n[3])
- {
+ for (std::set<int>::iterator it = vNew.begin(); it != vNew.end(); it++) {
+ if (nI == n[0] || nI == n[1] || nI == n[2] || nI == n[3]) {
assert(nOldest == -1 || mapInfo.count(*it) == 1);
if (nOldest == -1 || mapInfo[*it].nTime < mapInfo[nOldest].nTime)
nOldest = *it;
@@ -189,10 +185,9 @@ int CAddrMan::ShrinkNew(int nUBucket)
nI++;
}
assert(mapInfo.count(nOldest) == 1);
- CAddrInfo &info = mapInfo[nOldest];
- if (--info.nRefCount == 0)
- {
- SwapRandom(info.nRandomPos, vRandom.size()-1);
+ CAddrInfo& info = mapInfo[nOldest];
+ if (--info.nRefCount == 0) {
+ SwapRandom(info.nRandomPos, vRandom.size() - 1);
vRandom.pop_back();
mapAddr.erase(info);
mapInfo.erase(nOldest);
@@ -208,8 +203,7 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId, int nOrigin)
assert(vvNew[nOrigin].count(nId) == 1);
// remove the entry from all new buckets
- for (std::vector<std::set<int> >::iterator it = vvNew.begin(); it != vvNew.end(); it++)
- {
+ for (std::vector<std::set<int> >::iterator it = vvNew.begin(); it != vvNew.end(); it++) {
if ((*it).erase(nId))
info.nRefCount--;
}
@@ -219,11 +213,10 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId, int nOrigin)
// what tried bucket to move the entry to
int nKBucket = info.GetTriedBucket(nKey);
- std::vector<int> &vTried = vvTried[nKBucket];
+ std::vector<int>& vTried = vvTried[nKBucket];
// first check whether there is place to just add it
- if (vTried.size() < ADDRMAN_TRIED_BUCKET_SIZE)
- {
+ if (vTried.size() < ADDRMAN_TRIED_BUCKET_SIZE) {
vTried.push_back(nId);
nTried++;
info.fInTried = true;
@@ -236,7 +229,7 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId, int nOrigin)
// find which new bucket it belongs to
assert(mapInfo.count(vTried[nPos]) == 1);
int nUBucket = mapInfo[vTried[nPos]].GetNewBucket(nKey);
- std::set<int> &vNew = vvNew[nUBucket];
+ std::set<int>& vNew = vvNew[nUBucket];
// remove the to-be-replaced tried entry from the tried set
CAddrInfo& infoOld = mapInfo[vTried[nPos]];
@@ -245,8 +238,7 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId, int nOrigin)
// do not update nTried, as we are going to move something else there immediately
// check whether there is place in that one,
- if (vNew.size() < ADDRMAN_NEW_BUCKET_SIZE)
- {
+ if (vNew.size() < ADDRMAN_NEW_BUCKET_SIZE) {
// if so, move it back there
vNew.insert(vTried[nPos]);
} else {
@@ -261,16 +253,16 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId, int nOrigin)
return;
}
-void CAddrMan::Good_(const CService &addr, int64_t nTime)
+void CAddrMan::Good_(const CService& addr, int64_t nTime)
{
int nId;
- CAddrInfo *pinfo = Find(addr, &nId);
+ CAddrInfo* pinfo = Find(addr, &nId);
// if not found, bail out
if (!pinfo)
return;
- CAddrInfo &info = *pinfo;
+ CAddrInfo& info = *pinfo;
// check whether we are talking about the exact same CService (including same port)
if (info != addr)
@@ -289,12 +281,10 @@ void CAddrMan::Good_(const CService &addr, int64_t nTime)
// find a bucket it is in now
int nRnd = GetRandInt(vvNew.size());
int nUBucket = -1;
- for (unsigned int n = 0; n < vvNew.size(); n++)
- {
- int nB = (n+nRnd) % vvNew.size();
- std::set<int> &vNew = vvNew[nB];
- if (vNew.count(nId))
- {
+ for (unsigned int n = 0; n < vvNew.size(); n++) {
+ int nB = (n + nRnd) % vvNew.size();
+ std::set<int>& vNew = vvNew[nB];
+ if (vNew.count(nId)) {
nUBucket = nB;
break;
}
@@ -302,7 +292,8 @@ void CAddrMan::Good_(const CService &addr, int64_t nTime)
// if no bucket is found, something bad happened;
// TODO: maybe re-add the node, but for now, just bail out
- if (nUBucket == -1) return;
+ if (nUBucket == -1)
+ return;
LogPrint("addrman", "Moving %s to tried\n", addr.ToString());
@@ -310,17 +301,16 @@ void CAddrMan::Good_(const CService &addr, int64_t nTime)
MakeTried(info, nId, nUBucket);
}
-bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty)
+bool CAddrMan::Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimePenalty)
{
if (!addr.IsRoutable())
return false;
bool fNew = false;
int nId;
- CAddrInfo *pinfo = Find(addr, &nId);
+ CAddrInfo* pinfo = Find(addr, &nId);
- if (pinfo)
- {
+ if (pinfo) {
// periodically update nTime
bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60);
int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
@@ -344,7 +334,7 @@ bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimeP
// stochastic test: previous nRefCount == N: 2^N times harder to increase it
int nFactor = 1;
- for (int n=0; n<pinfo->nRefCount; n++)
+ for (int n = 0; n < pinfo->nRefCount; n++)
nFactor *= 2;
if (nFactor > 1 && (GetRandInt(nFactor) != 0))
return false;
@@ -356,9 +346,8 @@ bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimeP
}
int nUBucket = pinfo->GetNewBucket(nKey, source);
- std::set<int> &vNew = vvNew[nUBucket];
- if (!vNew.count(nId))
- {
+ std::set<int>& vNew = vvNew[nUBucket];
+ if (!vNew.count(nId)) {
pinfo->nRefCount++;
if (vNew.size() == ADDRMAN_NEW_BUCKET_SIZE)
ShrinkNew(nUBucket);
@@ -367,15 +356,15 @@ bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimeP
return fNew;
}
-void CAddrMan::Attempt_(const CService &addr, int64_t nTime)
+void CAddrMan::Attempt_(const CService& addr, int64_t nTime)
{
- CAddrInfo *pinfo = Find(addr);
+ CAddrInfo* pinfo = Find(addr);
// if not found, bail out
if (!pinfo)
return;
- CAddrInfo &info = *pinfo;
+ CAddrInfo& info = *pinfo;
// check whether we are talking about the exact same CService (including same port)
if (info != addr)
@@ -393,37 +382,36 @@ CAddress CAddrMan::Select_(int nUnkBias)
double nCorTried = sqrt(nTried) * (100.0 - nUnkBias);
double nCorNew = sqrt(nNew) * nUnkBias;
- if ((nCorTried + nCorNew)*GetRandInt(1<<30)/(1<<30) < nCorTried)
- {
+ if ((nCorTried + nCorNew) * GetRandInt(1 << 30) / (1 << 30) < nCorTried) {
// use a tried node
double fChanceFactor = 1.0;
- while(1)
- {
+ while (1) {
int nKBucket = GetRandInt(vvTried.size());
- std::vector<int> &vTried = vvTried[nKBucket];
- if (vTried.size() == 0) continue;
+ std::vector<int>& vTried = vvTried[nKBucket];
+ if (vTried.size() == 0)
+ continue;
int nPos = GetRandInt(vTried.size());
assert(mapInfo.count(vTried[nPos]) == 1);
- CAddrInfo &info = mapInfo[vTried[nPos]];
- if (GetRandInt(1<<30) < fChanceFactor*info.GetChance()*(1<<30))
+ CAddrInfo& info = mapInfo[vTried[nPos]];
+ if (GetRandInt(1 << 30) < fChanceFactor * info.GetChance() * (1 << 30))
return info;
fChanceFactor *= 1.2;
}
} else {
// use a new node
double fChanceFactor = 1.0;
- while(1)
- {
+ while (1) {
int nUBucket = GetRandInt(vvNew.size());
- std::set<int> &vNew = vvNew[nUBucket];
- if (vNew.size() == 0) continue;
+ std::set<int>& vNew = vvNew[nUBucket];
+ if (vNew.size() == 0)
+ continue;
int nPos = GetRandInt(vNew.size());
std::set<int>::iterator it = vNew.begin();
while (nPos--)
it++;
assert(mapInfo.count(*it) == 1);
- CAddrInfo &info = mapInfo[*it];
- if (GetRandInt(1<<30) < fChanceFactor*info.GetChance()*(1<<30))
+ CAddrInfo& info = mapInfo[*it];
+ if (GetRandInt(1 << 30) < fChanceFactor * info.GetChance() * (1 << 30))
return info;
fChanceFactor *= 1.2;
}
@@ -436,69 +424,76 @@ int CAddrMan::Check_()
std::set<int> setTried;
std::map<int, int> mapNew;
- if (vRandom.size() != nTried + nNew) return -7;
+ if (vRandom.size() != nTried + nNew)
+ return -7;
- for (std::map<int, CAddrInfo>::iterator it = mapInfo.begin(); it != mapInfo.end(); it++)
- {
+ for (std::map<int, CAddrInfo>::iterator it = mapInfo.begin(); it != mapInfo.end(); it++) {
int n = (*it).first;
- CAddrInfo &info = (*it).second;
- if (info.fInTried)
- {
-
- if (!info.nLastSuccess) return -1;
- if (info.nRefCount) return -2;
+ CAddrInfo& info = (*it).second;
+ if (info.fInTried) {
+ if (!info.nLastSuccess)
+ return -1;
+ if (info.nRefCount)
+ return -2;
setTried.insert(n);
} else {
- if (info.nRefCount < 0 || info.nRefCount > ADDRMAN_NEW_BUCKETS_PER_ADDRESS) return -3;
- if (!info.nRefCount) return -4;
+ if (info.nRefCount < 0 || info.nRefCount > ADDRMAN_NEW_BUCKETS_PER_ADDRESS)
+ return -3;
+ if (!info.nRefCount)
+ return -4;
mapNew[n] = info.nRefCount;
}
- if (mapAddr[info] != n) return -5;
- if (info.nRandomPos<0 || info.nRandomPos>=vRandom.size() || vRandom[info.nRandomPos] != n) return -14;
- if (info.nLastTry < 0) return -6;
- if (info.nLastSuccess < 0) return -8;
+ if (mapAddr[info] != n)
+ return -5;
+ if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
+ return -14;
+ if (info.nLastTry < 0)
+ return -6;
+ if (info.nLastSuccess < 0)
+ return -8;
}
- if (setTried.size() != nTried) return -9;
- if (mapNew.size() != nNew) return -10;
+ if (setTried.size() != nTried)
+ return -9;
+ if (mapNew.size() != nNew)
+ return -10;
- for (int n=0; n<vvTried.size(); n++)
- {
- std::vector<int> &vTried = vvTried[n];
- for (std::vector<int>::iterator it = vTried.begin(); it != vTried.end(); it++)
- {
- if (!setTried.count(*it)) return -11;
+ for (int n = 0; n < vvTried.size(); n++) {
+ std::vector<int>& vTried = vvTried[n];
+ for (std::vector<int>::iterator it = vTried.begin(); it != vTried.end(); it++) {
+ if (!setTried.count(*it))
+ return -11;
setTried.erase(*it);
}
}
- for (int n=0; n<vvNew.size(); n++)
- {
- std::set<int> &vNew = vvNew[n];
- for (std::set<int>::iterator it = vNew.begin(); it != vNew.end(); it++)
- {
- if (!mapNew.count(*it)) return -12;
+ for (int n = 0; n < vvNew.size(); n++) {
+ std::set<int>& vNew = vvNew[n];
+ for (std::set<int>::iterator it = vNew.begin(); it != vNew.end(); it++) {
+ if (!mapNew.count(*it))
+ return -12;
if (--mapNew[*it] == 0)
mapNew.erase(*it);
}
}
- if (setTried.size()) return -13;
- if (mapNew.size()) return -15;
+ if (setTried.size())
+ return -13;
+ if (mapNew.size())
+ return -15;
return 0;
}
#endif
-void CAddrMan::GetAddr_(std::vector<CAddress> &vAddr)
+void CAddrMan::GetAddr_(std::vector<CAddress>& vAddr)
{
unsigned int nNodes = ADDRMAN_GETADDR_MAX_PCT * vRandom.size() / 100;
if (nNodes > ADDRMAN_GETADDR_MAX)
nNodes = ADDRMAN_GETADDR_MAX;
// gather a list of random nodes, skipping those of low quality
- for (unsigned int n = 0; n < vRandom.size(); n++)
- {
+ for (unsigned int n = 0; n < vRandom.size(); n++) {
if (vAddr.size() >= nNodes)
break;
@@ -512,15 +507,15 @@ void CAddrMan::GetAddr_(std::vector<CAddress> &vAddr)
}
}
-void CAddrMan::Connected_(const CService &addr, int64_t nTime)
+void CAddrMan::Connected_(const CService& addr, int64_t nTime)
{
- CAddrInfo *pinfo = Find(addr);
+ CAddrInfo* pinfo = Find(addr);
// if not found, bail out
if (!pinfo)
return;
- CAddrInfo &info = *pinfo;
+ CAddrInfo& info = *pinfo;
// check whether we are talking about the exact same CService (including same port)
if (info != addr)
diff --git a/src/addrman.h b/src/addrman.h
index 90507cb458..5fd698f18a 100644
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -424,7 +424,7 @@ public:
Check();
}
if (fRet)
- LogPrint("addrman", "Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort().c_str(), source.ToString(), nTried, nNew);
+ LogPrint("addrman", "Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort(), source.ToString(), nTried, nNew);
return fRet;
}
diff --git a/src/allocators.cpp b/src/allocators.cpp
index 15f34aa2c8..dfe26f1b1e 100644
--- a/src/allocators.cpp
+++ b/src/allocators.cpp
@@ -37,25 +37,25 @@ static inline size_t GetSystemPageSize()
page_size = sSysInfo.dwPageSize;
#elif defined(PAGESIZE) // defined in limits.h
page_size = PAGESIZE;
-#else // assume some POSIX OS
+#else // assume some POSIX OS
page_size = sysconf(_SC_PAGESIZE);
#endif
return page_size;
}
-bool MemoryPageLocker::Lock(const void *addr, size_t len)
+bool MemoryPageLocker::Lock(const void* addr, size_t len)
{
#ifdef WIN32
- return VirtualLock(const_cast<void*>(addr), len);
+ return VirtualLock(const_cast<void*>(addr), len) != 0;
#else
return mlock(addr, len) == 0;
#endif
}
-bool MemoryPageLocker::Unlock(const void *addr, size_t len)
+bool MemoryPageLocker::Unlock(const void* addr, size_t len)
{
#ifdef WIN32
- return VirtualUnlock(const_cast<void*>(addr), len);
+ return VirtualUnlock(const_cast<void*>(addr), len) != 0;
#else
return munlock(addr, len) == 0;
#endif
@@ -64,4 +64,3 @@ bool MemoryPageLocker::Unlock(const void *addr, size_t len)
LockedPageManager::LockedPageManager() : LockedPageManagerBase<MemoryPageLocker>(GetSystemPageSize())
{
}
-
diff --git a/src/allocators.h b/src/allocators.h
index 0b1c9fea68..6b69e7ae69 100644
--- a/src/allocators.h
+++ b/src/allocators.h
@@ -12,6 +12,7 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/once.hpp>
+
#include <openssl/crypto.h> // for OPENSSL_cleanse()
/**
@@ -25,14 +26,14 @@
* small objects that span up to a few pages, mostly smaller than a page. To support large allocations,
* something like an interval tree would be the preferred data structure.
*/
-template <class Locker> class LockedPageManagerBase
+template <class Locker>
+class LockedPageManagerBase
{
public:
- LockedPageManagerBase(size_t page_size):
- page_size(page_size)
+ LockedPageManagerBase(size_t page_size) : page_size(page_size)
{
// Determine bitmask for extracting page from address
- assert(!(page_size & (page_size-1))); // size must be power of two
+ assert(!(page_size & (page_size - 1))); // size must be power of two
page_mask = ~(page_size - 1);
}
@@ -43,22 +44,21 @@ public:
// For all pages in affected range, increase lock count
- void LockRange(void *p, size_t size)
+ void LockRange(void* p, size_t size)
{
boost::mutex::scoped_lock lock(mutex);
- if(!size) return;
+ if (!size)
+ return;
const size_t base_addr = reinterpret_cast<size_t>(p);
const size_t start_page = base_addr & page_mask;
const size_t end_page = (base_addr + size - 1) & page_mask;
- for(size_t page = start_page; page <= end_page; page += page_size)
- {
+ for (size_t page = start_page; page <= end_page; page += page_size) {
Histogram::iterator it = histogram.find(page);
- if(it == histogram.end()) // Newly locked page
+ if (it == histogram.end()) // Newly locked page
{
locker.Lock(reinterpret_cast<void*>(page), page_size);
histogram.insert(std::make_pair(page, 1));
- }
- else // Page was already locked; increase counter
+ } else // Page was already locked; increase counter
{
it->second += 1;
}
@@ -66,20 +66,20 @@ public:
}
// For all pages in affected range, decrease lock count
- void UnlockRange(void *p, size_t size)
+ void UnlockRange(void* p, size_t size)
{
boost::mutex::scoped_lock lock(mutex);
- if(!size) return;
+ if (!size)
+ return;
const size_t base_addr = reinterpret_cast<size_t>(p);
const size_t start_page = base_addr & page_mask;
const size_t end_page = (base_addr + size - 1) & page_mask;
- for(size_t page = start_page; page <= end_page; page += page_size)
- {
+ for (size_t page = start_page; page <= end_page; page += page_size) {
Histogram::iterator it = histogram.find(page);
assert(it != histogram.end()); // Cannot unlock an area that was not locked
// Decrease counter for page, when it is zero, the page will be unlocked
it->second -= 1;
- if(it->second == 0) // Nothing on the page anymore that keeps it locked
+ if (it->second == 0) // Nothing on the page anymore that keeps it locked
{
// Unlock page and remove the count from histogram
locker.Unlock(reinterpret_cast<void*>(page), page_size);
@@ -100,7 +100,7 @@ private:
boost::mutex mutex;
size_t page_size, page_mask;
// map of page base address to lock count
- typedef std::map<size_t,int> Histogram;
+ typedef std::map<size_t, int> Histogram;
Histogram histogram;
};
@@ -115,11 +115,11 @@ public:
/** Lock memory pages.
* addr and len must be a multiple of the system page size
*/
- bool Lock(const void *addr, size_t len);
+ bool Lock(const void* addr, size_t len);
/** Unlock memory pages.
* addr and len must be a multiple of the system page size
*/
- bool Unlock(const void *addr, size_t len);
+ bool Unlock(const void* addr, size_t len);
};
/**
@@ -133,10 +133,10 @@ public:
* secure_allocator are created. So instead of having LockedPageManager also be
* static-initialized, it is created on demand.
*/
-class LockedPageManager: public LockedPageManagerBase<MemoryPageLocker>
+class LockedPageManager : public LockedPageManagerBase<MemoryPageLocker>
{
public:
- static LockedPageManager& Instance()
+ static LockedPageManager& Instance()
{
boost::call_once(LockedPageManager::CreateInstance, LockedPageManager::init_flag);
return *LockedPageManager::_instance;
@@ -164,11 +164,15 @@ private:
// Functions for directly locking/unlocking memory objects.
// Intended for non-dynamically allocated structures.
//
-template<typename T> void LockObject(const T &t) {
+template <typename T>
+void LockObject(const T& t)
+{
LockedPageManager::Instance().LockRange((void*)(&t), sizeof(T));
}
-template<typename T> void UnlockObject(const T &t) {
+template <typename T>
+void UnlockObject(const T& t)
+{
OPENSSL_cleanse((void*)(&t), sizeof(T));
LockedPageManager::Instance().UnlockRange((void*)(&t), sizeof(T));
}
@@ -177,13 +181,12 @@ template<typename T> void UnlockObject(const T &t) {
// Allocator that locks its contents from being paged
// out of memory and clears its contents before deletion.
//
-template<typename T>
-struct secure_allocator : public std::allocator<T>
-{
+template <typename T>
+struct secure_allocator : public std::allocator<T> {
// MSVC8 default copy constructor is broken
typedef std::allocator<T> base;
typedef typename base::size_type size_type;
- typedef typename base::difference_type difference_type;
+ typedef typename base::difference_type difference_type;
typedef typename base::pointer pointer;
typedef typename base::const_pointer const_pointer;
typedef typename base::reference reference;
@@ -192,14 +195,18 @@ struct secure_allocator : public std::allocator<T>
secure_allocator() throw() {}
secure_allocator(const secure_allocator& a) throw() : base(a) {}
template <typename U>
- secure_allocator(const secure_allocator<U>& a) throw() : base(a) {}
+ secure_allocator(const secure_allocator<U>& a) throw() : base(a)
+ {
+ }
~secure_allocator() throw() {}
- template<typename _Other> struct rebind
- { typedef secure_allocator<_Other> other; };
+ template <typename _Other>
+ struct rebind {
+ typedef secure_allocator<_Other> other;
+ };
- T* allocate(std::size_t n, const void *hint = 0)
+ T* allocate(std::size_t n, const void* hint = 0)
{
- T *p;
+ T* p;
p = std::allocator<T>::allocate(n, hint);
if (p != NULL)
LockedPageManager::Instance().LockRange(p, sizeof(T) * n);
@@ -208,8 +215,7 @@ struct secure_allocator : public std::allocator<T>
void deallocate(T* p, std::size_t n)
{
- if (p != NULL)
- {
+ if (p != NULL) {
OPENSSL_cleanse(p, sizeof(T) * n);
LockedPageManager::Instance().UnlockRange(p, sizeof(T) * n);
}
@@ -221,13 +227,12 @@ struct secure_allocator : public std::allocator<T>
//
// Allocator that clears its contents before deletion.
//
-template<typename T>
-struct zero_after_free_allocator : public std::allocator<T>
-{
+template <typename T>
+struct zero_after_free_allocator : public std::allocator<T> {
// MSVC8 default copy constructor is broken
typedef std::allocator<T> base;
typedef typename base::size_type size_type;
- typedef typename base::difference_type difference_type;
+ typedef typename base::difference_type difference_type;
typedef typename base::pointer pointer;
typedef typename base::const_pointer const_pointer;
typedef typename base::reference reference;
@@ -236,10 +241,14 @@ struct zero_after_free_allocator : public std::allocator<T>
zero_after_free_allocator() throw() {}
zero_after_free_allocator(const zero_after_free_allocator& a) throw() : base(a) {}
template <typename U>
- zero_after_free_allocator(const zero_after_free_allocator<U>& a) throw() : base(a) {}
+ zero_after_free_allocator(const zero_after_free_allocator<U>& a) throw() : base(a)
+ {
+ }
~zero_after_free_allocator() throw() {}
- template<typename _Other> struct rebind
- { typedef zero_after_free_allocator<_Other> other; };
+ template <typename _Other>
+ struct rebind {
+ typedef zero_after_free_allocator<_Other> other;
+ };
void deallocate(T* p, std::size_t n)
{
diff --git a/src/base58.cpp b/src/base58.cpp
index c9e91beef1..d94db2c51b 100644
--- a/src/base58.cpp
+++ b/src/base58.cpp
@@ -18,7 +18,8 @@
/* All alphanumeric characters except for "0", "I", "O", and "l" */
static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
-bool DecodeBase58(const char *psz, std::vector<unsigned char>& vch) {
+bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch)
+{
// Skip leading spaces.
while (*psz && isspace(*psz))
psz++;
@@ -33,7 +34,7 @@ bool DecodeBase58(const char *psz, std::vector<unsigned char>& vch) {
// Process the characters.
while (*psz && !isspace(*psz)) {
// Decode base58 character
- const char *ch = strchr(pszBase58, *psz);
+ const char* ch = strchr(pszBase58, *psz);
if (ch == NULL)
return false;
// Apply "b256 = b256 * 58 + ch".
@@ -59,11 +60,12 @@ bool DecodeBase58(const char *psz, std::vector<unsigned char>& vch) {
vch.reserve(zeroes + (b256.end() - it));
vch.assign(zeroes, 0x00);
while (it != b256.end())
- vch.push_back(*(it++));
+ vch.push_back(*(it++));
return true;
}
-std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend) {
+std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend)
+{
// Skip & count leading zeroes.
int zeroes = 0;
while (pbegin != pend && *pbegin == 0) {
@@ -97,15 +99,18 @@ std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend)
return str;
}
-std::string EncodeBase58(const std::vector<unsigned char>& vch) {
+std::string EncodeBase58(const std::vector<unsigned char>& vch)
+{
return EncodeBase58(&vch[0], &vch[0] + vch.size());
}
-bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet) {
+bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet)
+{
return DecodeBase58(str.c_str(), vchRet);
}
-std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn) {
+std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn)
+{
// add 4-byte hash check to the end
std::vector<unsigned char> vch(vchIn);
uint256 hash = Hash(vch.begin(), vch.end());
@@ -113,45 +118,49 @@ std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn) {
return EncodeBase58(vch);
}
-bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet) {
+bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet)
+{
if (!DecodeBase58(psz, vchRet) ||
- (vchRet.size() < 4))
- {
+ (vchRet.size() < 4)) {
vchRet.clear();
return false;
}
// re-calculate the checksum, insure it matches the included 4-byte checksum
- uint256 hash = Hash(vchRet.begin(), vchRet.end()-4);
- if (memcmp(&hash, &vchRet.end()[-4], 4) != 0)
- {
+ uint256 hash = Hash(vchRet.begin(), vchRet.end() - 4);
+ if (memcmp(&hash, &vchRet.end()[-4], 4) != 0) {
vchRet.clear();
return false;
}
- vchRet.resize(vchRet.size()-4);
+ vchRet.resize(vchRet.size() - 4);
return true;
}
-bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet) {
+bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet)
+{
return DecodeBase58Check(str.c_str(), vchRet);
}
-CBase58Data::CBase58Data() {
+CBase58Data::CBase58Data()
+{
vchVersion.clear();
vchData.clear();
}
-void CBase58Data::SetData(const std::vector<unsigned char> &vchVersionIn, const void* pdata, size_t nSize) {
+void CBase58Data::SetData(const std::vector<unsigned char>& vchVersionIn, const void* pdata, size_t nSize)
+{
vchVersion = vchVersionIn;
vchData.resize(nSize);
if (!vchData.empty())
memcpy(&vchData[0], pdata, nSize);
}
-void CBase58Data::SetData(const std::vector<unsigned char> &vchVersionIn, const unsigned char *pbegin, const unsigned char *pend) {
+void CBase58Data::SetData(const std::vector<unsigned char>& vchVersionIn, const unsigned char* pbegin, const unsigned char* pend)
+{
SetData(vchVersionIn, (void*)pbegin, pend - pbegin);
}
-bool CBase58Data::SetString(const char* psz, unsigned int nVersionBytes) {
+bool CBase58Data::SetString(const char* psz, unsigned int nVersionBytes)
+{
std::vector<unsigned char> vchTemp;
bool rc58 = DecodeBase58Check(psz, vchTemp);
if ((!rc58) || (vchTemp.size() < nVersionBytes)) {
@@ -167,61 +176,80 @@ bool CBase58Data::SetString(const char* psz, unsigned int nVersionBytes) {
return true;
}
-bool CBase58Data::SetString(const std::string& str) {
+bool CBase58Data::SetString(const std::string& str)
+{
return SetString(str.c_str());
}
-std::string CBase58Data::ToString() const {
+std::string CBase58Data::ToString() const
+{
std::vector<unsigned char> vch = vchVersion;
vch.insert(vch.end(), vchData.begin(), vchData.end());
return EncodeBase58Check(vch);
}
-int CBase58Data::CompareTo(const CBase58Data& b58) const {
- if (vchVersion < b58.vchVersion) return -1;
- if (vchVersion > b58.vchVersion) return 1;
- if (vchData < b58.vchData) return -1;
- if (vchData > b58.vchData) return 1;
+int CBase58Data::CompareTo(const CBase58Data& b58) const
+{
+ if (vchVersion < b58.vchVersion)
+ return -1;
+ if (vchVersion > b58.vchVersion)
+ return 1;
+ if (vchData < b58.vchData)
+ return -1;
+ if (vchData > b58.vchData)
+ return 1;
return 0;
}
-namespace {
+namespace
+{
+class CBitcoinAddressVisitor : public boost::static_visitor<bool>
+{
+private:
+ CBitcoinAddress* addr;
- class CBitcoinAddressVisitor : public boost::static_visitor<bool> {
- private:
- CBitcoinAddress *addr;
- public:
- CBitcoinAddressVisitor(CBitcoinAddress *addrIn) : addr(addrIn) { }
+public:
+ CBitcoinAddressVisitor(CBitcoinAddress* addrIn) : addr(addrIn) {}
- bool operator()(const CKeyID &id) const { return addr->Set(id); }
- bool operator()(const CScriptID &id) const { return addr->Set(id); }
- bool operator()(const CNoDestination &no) const { return false; }
- };
+ bool operator()(const CKeyID& id) const { return addr->Set(id); }
+ bool operator()(const CScriptID& id) const { return addr->Set(id); }
+ bool operator()(const CNoDestination& no) const { return false; }
+};
} // anon namespace
-bool CBitcoinAddress::Set(const CKeyID &id) {
+bool CBitcoinAddress::Set(const CKeyID& id)
+{
SetData(Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS), &id, 20);
return true;
}
-bool CBitcoinAddress::Set(const CScriptID &id) {
+bool CBitcoinAddress::Set(const CScriptID& id)
+{
SetData(Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS), &id, 20);
return true;
}
-bool CBitcoinAddress::Set(const CTxDestination &dest) {
+bool CBitcoinAddress::Set(const CTxDestination& dest)
+{
return boost::apply_visitor(CBitcoinAddressVisitor(this), dest);
}
-bool CBitcoinAddress::IsValid() const {
+bool CBitcoinAddress::IsValid() const
+{
+ return IsValid(Params());
+}
+
+bool CBitcoinAddress::IsValid(const CChainParams& params) const
+{
bool fCorrectSize = vchData.size() == 20;
- bool fKnownVersion = vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS) ||
- vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS);
+ bool fKnownVersion = vchVersion == params.Base58Prefix(CChainParams::PUBKEY_ADDRESS) ||
+ vchVersion == params.Base58Prefix(CChainParams::SCRIPT_ADDRESS);
return fCorrectSize && fKnownVersion;
}
-CTxDestination CBitcoinAddress::Get() const {
+CTxDestination CBitcoinAddress::Get() const
+{
if (!IsValid())
return CNoDestination();
uint160 id;
@@ -234,7 +262,8 @@ CTxDestination CBitcoinAddress::Get() const {
return CNoDestination();
}
-bool CBitcoinAddress::GetKeyID(CKeyID &keyID) const {
+bool CBitcoinAddress::GetKeyID(CKeyID& keyID) const
+{
if (!IsValid() || vchVersion != Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
return false;
uint160 id;
@@ -243,33 +272,40 @@ bool CBitcoinAddress::GetKeyID(CKeyID &keyID) const {
return true;
}
-bool CBitcoinAddress::IsScript() const {
+bool CBitcoinAddress::IsScript() const
+{
return IsValid() && vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS);
}
-void CBitcoinSecret::SetKey(const CKey& vchSecret) {
+void CBitcoinSecret::SetKey(const CKey& vchSecret)
+{
assert(vchSecret.IsValid());
SetData(Params().Base58Prefix(CChainParams::SECRET_KEY), vchSecret.begin(), vchSecret.size());
if (vchSecret.IsCompressed())
vchData.push_back(1);
}
-CKey CBitcoinSecret::GetKey() {
+CKey CBitcoinSecret::GetKey()
+{
CKey ret;
- ret.Set(&vchData[0], &vchData[32], vchData.size() > 32 && vchData[32] == 1);
+ assert(vchData.size() >= 32);
+ ret.Set(vchData.begin(), vchData.begin() + 32, vchData.size() > 32 && vchData[32] == 1);
return ret;
}
-bool CBitcoinSecret::IsValid() const {
+bool CBitcoinSecret::IsValid() const
+{
bool fExpectedFormat = vchData.size() == 32 || (vchData.size() == 33 && vchData[32] == 1);
bool fCorrectVersion = vchVersion == Params().Base58Prefix(CChainParams::SECRET_KEY);
return fExpectedFormat && fCorrectVersion;
}
-bool CBitcoinSecret::SetString(const char* pszSecret) {
+bool CBitcoinSecret::SetString(const char* pszSecret)
+{
return CBase58Data::SetString(pszSecret) && IsValid();
}
-bool CBitcoinSecret::SetString(const std::string& strSecret) {
+bool CBitcoinSecret::SetString(const std::string& strSecret)
+{
return SetString(strSecret.c_str());
}
diff --git a/src/base58.h b/src/base58.h
index 216aca3648..c5e230c72e 100644
--- a/src/base58.h
+++ b/src/base58.h
@@ -17,6 +17,7 @@
#include "chainparams.h"
#include "key.h"
#include "script/script.h"
+#include "script/standard.h"
#include <string>
#include <vector>
@@ -104,6 +105,7 @@ public:
bool Set(const CScriptID &id);
bool Set(const CTxDestination &dest);
bool IsValid() const;
+ bool IsValid(const CChainParams &params) const;
CBitcoinAddress() {}
CBitcoinAddress(const CTxDestination &dest) { Set(dest); }
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index 871aaf93df..badb376cb3 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -3,11 +3,11 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include "util.h"
+#include "chainparamsbase.h"
#include "init.h"
#include "rpcclient.h"
#include "rpcprotocol.h"
-#include "chainparamsbase.h"
+#include "util.h"
#include "utilstrencodings.h"
#include "version.h"
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp
index c455351411..b6e7a6c540 100644
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -3,23 +3,24 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "base58.h"
-#include "util.h"
-#include "utilmoneystr.h"
#include "core.h"
-#include "main.h" // for MAX_BLOCK_SIZE
+#include "core_io.h"
#include "keystore.h"
+#include "main.h" // for MAX_BLOCK_SIZE
#include "script/script.h"
#include "script/sign.h"
#include "ui_interface.h" // for _(...)
#include "univalue/univalue.h"
-#include "core_io.h"
+#include "util.h"
+#include "utilmoneystr.h"
#include <stdio.h>
-#include <boost/assign/list_of.hpp>
+
#include <boost/algorithm/string.hpp>
+#include <boost/assign/list_of.hpp>
-using namespace std;
using namespace boost::assign;
+using namespace std;
static bool fCreateBlank;
static map<string,UniValue> registers;
@@ -223,9 +224,8 @@ static void MutateTxAddOutAddr(CMutableTransaction& tx, const string& strInput)
if (!addr.IsValid())
throw runtime_error("invalid TX output address");
- // build standard output script via SetDestination()
- CScript scriptPubKey;
- scriptPubKey.SetDestination(addr.Get());
+ // build standard output script via GetScriptForDestination()
+ CScript scriptPubKey = GetScriptForDestination(addr.Get());
// construct TxOut, append to transaction output list
CTxOut txout(value, scriptPubKey);
@@ -237,8 +237,7 @@ static void MutateTxAddOutScript(CMutableTransaction& tx, const string& strInput
// separate VALUE:SCRIPT in string
size_t pos = strInput.find(':');
if ((pos == string::npos) ||
- (pos == 0) ||
- (pos == (strInput.size() - 1)))
+ (pos == 0))
throw runtime_error("TX output missing separator");
// extract and validate VALUE
@@ -420,12 +419,12 @@ static void MutateTxSign(CMutableTransaction& tx, const string& flagStr)
// Sign what we can:
for (unsigned int i = 0; i < mergedTx.vin.size(); i++) {
CTxIn& txin = mergedTx.vin[i];
- CCoins coins;
- if (!view.GetCoins(txin.prevout.hash, coins) || !coins.IsAvailable(txin.prevout.n)) {
+ const CCoins* coins = view.AccessCoins(txin.prevout.hash);
+ if (!coins || !coins->IsAvailable(txin.prevout.n)) {
fComplete = false;
continue;
}
- const CScript& prevPubKey = coins.vout[txin.prevout.n].scriptPubKey;
+ const CScript& prevPubKey = coins->vout[txin.prevout.n].scriptPubKey;
txin.scriptSig.clear();
// Only sign SIGHASH_SINGLE if there's a corresponding output:
@@ -436,7 +435,7 @@ static void MutateTxSign(CMutableTransaction& tx, const string& flagStr)
BOOST_FOREACH(const CTransaction& txv, txVariants) {
txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig);
}
- if (!VerifyScript(txin.scriptSig, prevPubKey, mergedTx, i, STANDARD_SCRIPT_VERIFY_FLAGS, 0))
+ if (!VerifyScript(txin.scriptSig, prevPubKey, mergedTx, i, STANDARD_SCRIPT_VERIFY_FLAGS))
fComplete = false;
}
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index 5be8708979..0737b5a83d 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -129,7 +129,6 @@ bool AppInit(int argc, char* argv[])
}
if (pid > 0) // Parent process, pid is child process id
{
- CreatePidFile(GetPidFile(), pid);
return true;
}
// Child process falls through to rest of initialization
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 460fabc6e6..179db5a818 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -221,24 +221,25 @@ const CChainParams &Params() {
return *pCurrentParams;
}
-void SelectParams(CBaseChainParams::Network network) {
- SelectBaseParams(network);
+CChainParams &Params(CBaseChainParams::Network network) {
switch (network) {
case CBaseChainParams::MAIN:
- pCurrentParams = &mainParams;
- break;
+ return mainParams;
case CBaseChainParams::TESTNET:
- pCurrentParams = &testNetParams;
- break;
+ return testNetParams;
case CBaseChainParams::REGTEST:
- pCurrentParams = &regTestParams;
- break;
+ return regTestParams;
default:
assert(false && "Unimplemented network");
- return;
+ return mainParams;
}
}
+void SelectParams(CBaseChainParams::Network network) {
+ SelectBaseParams(network);
+ pCurrentParams = &Params(network);
+}
+
bool SelectParamsFromCommandLine() {
if (!SelectBaseParamsFromCommandLine())
return false;
diff --git a/src/chainparams.h b/src/chainparams.h
index 95b972bd7f..e5dfc87c6d 100644
--- a/src/chainparams.h
+++ b/src/chainparams.h
@@ -111,6 +111,9 @@ protected:
*/
const CChainParams &Params();
+/** Return parameters for the given network. */
+CChainParams &Params(CBaseChainParams::Network network);
+
/** Sets the params returned by Params() to those for the given network. */
void SelectParams(CBaseChainParams::Network network);
diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp
index d1e19871c3..98bb5b855f 100644
--- a/src/chainparamsbase.cpp
+++ b/src/chainparamsbase.cpp
@@ -17,9 +17,11 @@ using namespace boost::assign;
// Main network
//
-class CBaseMainParams : public CBaseChainParams {
+class CBaseMainParams : public CBaseChainParams
+{
public:
- CBaseMainParams() {
+ CBaseMainParams()
+ {
networkID = CBaseChainParams::MAIN;
nRPCPort = 8332;
}
@@ -29,9 +31,11 @@ static CBaseMainParams mainParams;
//
// Testnet (v3)
//
-class CBaseTestNetParams : public CBaseMainParams {
+class CBaseTestNetParams : public CBaseMainParams
+{
public:
- CBaseTestNetParams() {
+ CBaseTestNetParams()
+ {
networkID = CBaseChainParams::TESTNET;
nRPCPort = 18332;
strDataDir = "testnet3";
@@ -42,40 +46,45 @@ static CBaseTestNetParams testNetParams;
//
// Regression test
//
-class CBaseRegTestParams : public CBaseTestNetParams {
+class CBaseRegTestParams : public CBaseTestNetParams
+{
public:
- CBaseRegTestParams() {
+ CBaseRegTestParams()
+ {
networkID = CBaseChainParams::REGTEST;
strDataDir = "regtest";
}
};
static CBaseRegTestParams regTestParams;
-static CBaseChainParams *pCurrentBaseParams = 0;
+static CBaseChainParams* pCurrentBaseParams = 0;
-const CBaseChainParams &BaseParams() {
+const CBaseChainParams& BaseParams()
+{
assert(pCurrentBaseParams);
return *pCurrentBaseParams;
}
-void SelectBaseParams(CBaseChainParams::Network network) {
+void SelectBaseParams(CBaseChainParams::Network network)
+{
switch (network) {
- case CBaseChainParams::MAIN:
- pCurrentBaseParams = &mainParams;
- break;
- case CBaseChainParams::TESTNET:
- pCurrentBaseParams = &testNetParams;
- break;
- case CBaseChainParams::REGTEST:
- pCurrentBaseParams = &regTestParams;
- break;
- default:
- assert(false && "Unimplemented network");
- return;
+ case CBaseChainParams::MAIN:
+ pCurrentBaseParams = &mainParams;
+ break;
+ case CBaseChainParams::TESTNET:
+ pCurrentBaseParams = &testNetParams;
+ break;
+ case CBaseChainParams::REGTEST:
+ pCurrentBaseParams = &regTestParams;
+ break;
+ default:
+ assert(false && "Unimplemented network");
+ return;
}
}
-bool SelectBaseParamsFromCommandLine() {
+bool SelectBaseParamsFromCommandLine()
+{
bool fRegTest = GetBoolArg("-regtest", false);
bool fTestNet = GetBoolArg("-testnet", false);
@@ -93,6 +102,7 @@ bool SelectBaseParamsFromCommandLine() {
return true;
}
-bool AreBaseParamsConfigured() {
+bool AreBaseParamsConfigured()
+{
return pCurrentBaseParams != NULL;
}
diff --git a/src/chainparamsbase.h b/src/chainparamsbase.h
index 2d3a07b44a..c054f03f17 100644
--- a/src/chainparamsbase.h
+++ b/src/chainparamsbase.h
@@ -5,8 +5,8 @@
#ifndef BITCOIN_CHAIN_PARAMS_BASE_H
#define BITCOIN_CHAIN_PARAMS_BASE_H
-#include <vector>
#include <string>
+#include <vector>
/**
* CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind)
@@ -26,6 +26,7 @@ public:
const std::string& DataDir() const { return strDataDir; }
int RPCPort() const { return nRPCPort; }
Network NetworkID() const { return networkID; }
+
protected:
CBaseChainParams() {}
@@ -38,7 +39,7 @@ protected:
* Return the currently selected parameters. This won't change after app startup
* outside of the unit tests.
*/
-const CBaseChainParams &BaseParams();
+const CBaseChainParams& BaseParams();
/** Sets the params returned by Params() to those for the given network. */
void SelectBaseParams(CBaseChainParams::Network network);
diff --git a/src/checkpoints.h b/src/checkpoints.h
index 6d3f2d4935..fca046559a 100644
--- a/src/checkpoints.h
+++ b/src/checkpoints.h
@@ -13,20 +13,20 @@ class uint256;
/** Block-chain checkpoints are compiled-in sanity checks.
* They are updated every release or three.
*/
-namespace Checkpoints {
+namespace Checkpoints
+{
+// Returns true if block passes checkpoint checks
+bool CheckBlock(int nHeight, const uint256& hash);
- // Returns true if block passes checkpoint checks
- bool CheckBlock(int nHeight, const uint256& hash);
+// Return conservative estimate of total number of blocks, 0 if unknown
+int GetTotalBlocksEstimate();
- // Return conservative estimate of total number of blocks, 0 if unknown
- int GetTotalBlocksEstimate();
+// Returns last CBlockIndex* in mapBlockIndex that is a checkpoint
+CBlockIndex* GetLastCheckpoint();
- // Returns last CBlockIndex* in mapBlockIndex that is a checkpoint
- CBlockIndex* GetLastCheckpoint();
+double GuessVerificationProgress(CBlockIndex* pindex, bool fSigchecks = true);
- double GuessVerificationProgress(CBlockIndex *pindex, bool fSigchecks = true);
-
- extern bool fEnabled;
+extern bool fEnabled;
} //namespace Checkpoints
diff --git a/src/checkqueue.h b/src/checkqueue.h
index c2c7d8ca24..b2a713e646 100644
--- a/src/checkqueue.h
+++ b/src/checkqueue.h
@@ -13,7 +13,8 @@
#include <boost/thread/locks.hpp>
#include <boost/thread/mutex.hpp>
-template<typename T> class CCheckQueueControl;
+template <typename T>
+class CCheckQueueControl;
/** Queue for verifications that have to be performed.
* The verifications are represented by a type T, which must provide an
@@ -24,7 +25,9 @@ template<typename T> class CCheckQueueControl;
* the master is done adding work, it temporarily joins the worker pool
* as an N'th worker, until all jobs are done.
*/
-template<typename T> class CCheckQueue {
+template <typename T>
+class CCheckQueue
+{
private:
// Mutex to protect the inner state
boost::mutex mutex;
@@ -60,8 +63,9 @@ private:
unsigned int nBatchSize;
// Internal function that does bulk of the verification work.
- bool Loop(bool fMaster = false) {
- boost::condition_variable &cond = fMaster ? condMaster : condWorker;
+ bool Loop(bool fMaster = false)
+ {
+ boost::condition_variable& cond = fMaster ? condMaster : condWorker;
std::vector<T> vChecks;
vChecks.reserve(nBatchSize);
unsigned int nNow = 0;
@@ -103,41 +107,43 @@ private:
nNow = std::max(1U, std::min(nBatchSize, (unsigned int)queue.size() / (nTotal + nIdle + 1)));
vChecks.resize(nNow);
for (unsigned int i = 0; i < nNow; i++) {
- // We want the lock on the mutex to be as short as possible, so swap jobs from the global
- // queue to the local batch vector instead of copying.
- vChecks[i].swap(queue.back());
- queue.pop_back();
+ // We want the lock on the mutex to be as short as possible, so swap jobs from the global
+ // queue to the local batch vector instead of copying.
+ vChecks[i].swap(queue.back());
+ queue.pop_back();
}
// Check whether we need to do work at all
fOk = fAllOk;
}
// execute work
- BOOST_FOREACH(T &check, vChecks)
+ BOOST_FOREACH (T& check, vChecks)
if (fOk)
fOk = check();
vChecks.clear();
- } while(true);
+ } while (true);
}
public:
// Create a new check queue
- CCheckQueue(unsigned int nBatchSizeIn) :
- nIdle(0), nTotal(0), fAllOk(true), nTodo(0), fQuit(false), nBatchSize(nBatchSizeIn) {}
+ CCheckQueue(unsigned int nBatchSizeIn) : nIdle(0), nTotal(0), fAllOk(true), nTodo(0), fQuit(false), nBatchSize(nBatchSizeIn) {}
// Worker thread
- void Thread() {
+ void Thread()
+ {
Loop();
}
// Wait until execution finishes, and return whether all evaluations where succesful.
- bool Wait() {
+ bool Wait()
+ {
return Loop(true);
}
// Add a batch of checks to the queue
- void Add(std::vector<T> &vChecks) {
+ void Add(std::vector<T>& vChecks)
+ {
boost::unique_lock<boost::mutex> lock(mutex);
- BOOST_FOREACH(T &check, vChecks) {
+ BOOST_FOREACH (T& check, vChecks) {
queue.push_back(T());
check.swap(queue.back());
}
@@ -148,7 +154,8 @@ public:
condWorker.notify_all();
}
- ~CCheckQueue() {
+ ~CCheckQueue()
+ {
}
friend class CCheckQueueControl<T>;
@@ -157,13 +164,16 @@ public:
/** RAII-style controller object for a CCheckQueue that guarantees the passed
* queue is finished before continuing.
*/
-template<typename T> class CCheckQueueControl {
+template <typename T>
+class CCheckQueueControl
+{
private:
- CCheckQueue<T> *pqueue;
+ CCheckQueue<T>* pqueue;
bool fDone;
public:
- CCheckQueueControl(CCheckQueue<T> *pqueueIn) : pqueue(pqueueIn), fDone(false) {
+ CCheckQueueControl(CCheckQueue<T>* pqueueIn) : pqueue(pqueueIn), fDone(false)
+ {
// passed queue is supposed to be unused, or NULL
if (pqueue != NULL) {
assert(pqueue->nTotal == pqueue->nIdle);
@@ -172,7 +182,8 @@ public:
}
}
- bool Wait() {
+ bool Wait()
+ {
if (pqueue == NULL)
return true;
bool fRet = pqueue->Wait();
@@ -180,12 +191,14 @@ public:
return fRet;
}
- void Add(std::vector<T> &vChecks) {
+ void Add(std::vector<T>& vChecks)
+ {
if (pqueue != NULL)
pqueue->Add(vChecks);
}
- ~CCheckQueueControl() {
+ ~CCheckQueueControl()
+ {
if (!fDone)
Wait();
}
diff --git a/src/clientversion.h b/src/clientversion.h
index 5634516ca4..cd7ceb78f0 100644
--- a/src/clientversion.h
+++ b/src/clientversion.h
@@ -13,13 +13,13 @@
//
// These need to be macros, as version.cpp's and bitcoin*-res.rc's voodoo requires it
-#define CLIENT_VERSION_MAJOR 0
-#define CLIENT_VERSION_MINOR 9
-#define CLIENT_VERSION_REVISION 99
-#define CLIENT_VERSION_BUILD 0
+#define CLIENT_VERSION_MAJOR 0
+#define CLIENT_VERSION_MINOR 9
+#define CLIENT_VERSION_REVISION 99
+#define CLIENT_VERSION_BUILD 0
// Set to true for release, false for prerelease or test build
-#define CLIENT_VERSION_IS_RELEASE false
+#define CLIENT_VERSION_IS_RELEASE false
// Copyright year (2009-this)
// Todo: update this when changing our copyright comments in the source
@@ -33,6 +33,6 @@
#define DO_STRINGIZE(X) #X
// Copyright string used in Windows .rc files
-#define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin Core Developers"
+#define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin Core Developers"
#endif // CLIENTVERSION_H
diff --git a/src/coincontrol.h b/src/coincontrol.h
index 97c30c2713..033092c019 100644
--- a/src/coincontrol.h
+++ b/src/coincontrol.h
@@ -57,7 +57,6 @@ public:
private:
std::set<COutPoint> setSelected;
-
};
#endif // COINCONTROL_H
diff --git a/src/coins.cpp b/src/coins.cpp
index 7bfb84ef3e..34485db2bd 100644
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -110,9 +110,13 @@ CCoins &CCoinsViewCache::GetCoins(const uint256 &txid) {
return it->second;
}
-const CCoins &CCoinsViewCache::GetCoins(const uint256 &txid) const {
- /* Avoid redundant implementation with the const-cast. */
- return const_cast<CCoinsViewCache*>(this)->GetCoins(txid);
+const CCoins* CCoinsViewCache::AccessCoins(const uint256 &txid) const {
+ CCoinsMap::const_iterator it = FetchCoins(txid);
+ if (it == cacheCoins.end()) {
+ return NULL;
+ } else {
+ return &it->second;
+ }
}
bool CCoinsViewCache::SetCoins(const uint256 &txid, const CCoins &coins) {
@@ -162,9 +166,9 @@ unsigned int CCoinsViewCache::GetCacheSize() const {
const CTxOut &CCoinsViewCache::GetOutputFor(const CTxIn& input) const
{
- const CCoins &coins = GetCoins(input.prevout.hash);
- assert(coins.IsAvailable(input.prevout.n));
- return coins.vout[input.prevout.n];
+ const CCoins* coins = AccessCoins(input.prevout.hash);
+ assert(coins && coins->IsAvailable(input.prevout.n));
+ return coins->vout[input.prevout.n];
}
int64_t CCoinsViewCache::GetValueIn(const CTransaction& tx) const
@@ -182,19 +186,12 @@ int64_t CCoinsViewCache::GetValueIn(const CTransaction& tx) const
bool CCoinsViewCache::HaveInputs(const CTransaction& tx) const
{
if (!tx.IsCoinBase()) {
- // first check whether information about the prevout hash is available
for (unsigned int i = 0; i < tx.vin.size(); i++) {
const COutPoint &prevout = tx.vin[i].prevout;
- if (!HaveCoins(prevout.hash))
- return false;
- }
-
- // then check whether the actual outputs are available
- for (unsigned int i = 0; i < tx.vin.size(); i++) {
- const COutPoint &prevout = tx.vin[i].prevout;
- const CCoins &coins = GetCoins(prevout.hash);
- if (!coins.IsAvailable(prevout.n))
+ const CCoins* coins = AccessCoins(prevout.hash);
+ if (!coins || !coins->IsAvailable(prevout.n)) {
return false;
+ }
}
}
return true;
@@ -207,10 +204,11 @@ double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight) const
double dResult = 0.0;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
- const CCoins &coins = GetCoins(txin.prevout.hash);
- if (!coins.IsAvailable(txin.prevout.n)) continue;
- if (coins.nHeight < nHeight) {
- dResult += coins.vout[txin.prevout.n].nValue * (nHeight-coins.nHeight);
+ const CCoins* coins = AccessCoins(txin.prevout.hash);
+ assert(coins);
+ if (!coins->IsAvailable(txin.prevout.n)) continue;
+ if (coins->nHeight < nHeight) {
+ dResult += coins->vout[txin.prevout.n].nValue * (nHeight-coins->nHeight);
}
}
return tx.ComputePriority(dResult);
diff --git a/src/coins.h b/src/coins.h
index d338e3172e..bf61f55aac 100644
--- a/src/coins.h
+++ b/src/coins.h
@@ -195,8 +195,8 @@ public:
::Unserialize(s, VARINT(nCode), nType, nVersion);
fCoinBase = nCode & 1;
std::vector<bool> vAvail(2, false);
- vAvail[0] = nCode & 2;
- vAvail[1] = nCode & 4;
+ vAvail[0] = (nCode & 2) != 0;
+ vAvail[1] = (nCode & 4) != 0;
unsigned int nMaskCode = (nCode / 8) + ((nCode & 6) != 0 ? 0 : 1);
// spentness bitmask
while (nMaskCode > 0) {
@@ -344,11 +344,13 @@ public:
bool SetBestBlock(const uint256 &hashBlock);
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock);
+ // Return a pointer to CCoins in the cache, or NULL if not found. This is
+ // more efficient than GetCoins. Modifications to other cache entries are
+ // allowed while accessing the returned pointer.
+ const CCoins* AccessCoins(const uint256 &txid) const;
+
// Return a modifiable reference to a CCoins. Check HaveCoins first.
- // Many methods explicitly require a CCoinsViewCache because of this method, to reduce
- // copying.
CCoins &GetCoins(const uint256 &txid);
- const CCoins &GetCoins(const uint256 &txid) const;
// Push the modifications applied to this cache to its base.
// Failure to call this method before destruction will cause the changes to be forgotten.
diff --git a/src/compat/glibc_compat.cpp b/src/compat/glibc_compat.cpp
index 22f82e4259..94c79e4b97 100644
--- a/src/compat/glibc_compat.cpp
+++ b/src/compat/glibc_compat.cpp
@@ -18,11 +18,11 @@ extern "C" void* memcpy(void* a, const void* b, size_t c)
return memmove(a, b, c);
}
-extern "C" void __chk_fail (void) __attribute__((__noreturn__));
+extern "C" void __chk_fail(void) __attribute__((__noreturn__));
extern "C" FDELT_TYPE __fdelt_warn(FDELT_TYPE a)
{
if (a >= FD_SETSIZE)
- __chk_fail ();
+ __chk_fail();
return a / __NFDBITS;
}
extern "C" FDELT_TYPE __fdelt_chk(FDELT_TYPE) __attribute__((weak, alias("__fdelt_warn")));
diff --git a/src/compat/glibc_sanity.cpp b/src/compat/glibc_sanity.cpp
index d93602e0fe..acc7809d77 100644
--- a/src/compat/glibc_sanity.cpp
+++ b/src/compat/glibc_sanity.cpp
@@ -14,10 +14,11 @@
extern "C" void* memcpy(void* a, const void* b, size_t c);
void* memcpy_int(void* a, const void* b, size_t c)
{
- return memcpy(a,b,c);
+ return memcpy(a, b, c);
}
-namespace {
+namespace
+{
// trigger: Use the memcpy_int wrapper which calls our internal memcpy.
// A direct call to memcpy may be optimized away by the compiler.
// test: Fill an array with a sequence of integers. memcpy to a new empty array.
@@ -31,11 +32,10 @@ bool sanity_test_memcpy()
for (unsigned int i = 0; i != T; ++i)
memcpy_test[i] = i;
- memcpy_int(memcpy_verify,memcpy_test,sizeof(memcpy_test));
+ memcpy_int(memcpy_verify, memcpy_test, sizeof(memcpy_test));
- for (unsigned int i = 0; i != T; ++i)
- {
- if(memcpy_verify[i] != i)
+ for (unsigned int i = 0; i != T; ++i) {
+ if (memcpy_verify[i] != i)
return false;
}
return true;
@@ -51,7 +51,7 @@ bool sanity_test_fdelt()
fd_set fds;
FD_ZERO(&fds);
FD_SET(0, &fds);
- return FD_ISSET(0,&fds);
+ return FD_ISSET(0, &fds);
}
#endif
diff --git a/src/compat/glibcxx_compat.cpp b/src/compat/glibcxx_compat.cpp
index cbe059735b..41d8458cb2 100644
--- a/src/compat/glibcxx_compat.cpp
+++ b/src/compat/glibcxx_compat.cpp
@@ -11,8 +11,8 @@
#define _GLIBCXX_USE_NOEXCEPT throw()
#endif
-namespace std {
-
+namespace std
+{
const char* bad_exception::what() const throw()
{
return "std::bad_exception";
@@ -30,9 +30,8 @@ const char* bad_alloc::what() const throw()
namespace __detail
{
-struct _List_node_base
-{
- void _M_hook(std::__detail::_List_node_base* const __position) throw () __attribute__((used))
+struct _List_node_base {
+ void _M_hook(std::__detail::_List_node_base* const __position) throw() __attribute__((used))
{
_M_next = __position;
_M_prev = __position->_M_prev;
@@ -62,9 +61,9 @@ template ostream& __ostream_insert(ostream&, const char*, streamsize);
template istream& istream::_M_extract(long&);
template istream& istream::_M_extract(unsigned short&);
-out_of_range::~out_of_range() _GLIBCXX_USE_NOEXCEPT { }
+out_of_range::~out_of_range() _GLIBCXX_USE_NOEXCEPT {}
-length_error::~length_error() _GLIBCXX_USE_NOEXCEPT { }
+length_error::~length_error() _GLIBCXX_USE_NOEXCEPT {}
// Used with permission.
// See: https://github.com/madlib/madlib/commit/c3db418c0d34d6813608f2137fef1012ce03043d
@@ -85,11 +84,11 @@ void ctype<char>::_M_widen_init() const
}
}
-void __throw_out_of_range_fmt(const char*, ...) __attribute__((__noreturn__));
-void __throw_out_of_range_fmt(const char* err, ...)
+void __throw_out_of_range_fmt(const char*, ...) __attribute__((__noreturn__));
+void __throw_out_of_range_fmt(const char* err, ...)
{
// Safe and over-simplified version. Ignore the format and print it as-is.
__throw_out_of_range(err);
}
-}// namespace std
+} // namespace std
diff --git a/src/compat/glibcxx_sanity.cpp b/src/compat/glibcxx_sanity.cpp
index cd8da4fd67..9b1fefd448 100644
--- a/src/compat/glibcxx_sanity.cpp
+++ b/src/compat/glibcxx_sanity.cpp
@@ -6,15 +6,15 @@
#include <locale>
#include <stdexcept>
-namespace{
-
+namespace
+{
// trigger: use ctype<char>::widen to trigger ctype<char>::_M_widen_init().
// test: convert a char from narrow to wide and back. Verify that the result
// matches the original.
bool sanity_test_widen(char testchar)
{
- const std::ctype<char>& test(std::use_facet< std::ctype<char> >(std::locale()));
- return test.narrow(test.widen(testchar),'b') == testchar;
+ const std::ctype<char>& test(std::use_facet<std::ctype<char> >(std::locale()));
+ return test.narrow(test.widen(testchar), 'b') == testchar;
}
// trigger: use list::push_back and list::pop_back to trigger _M_hook and
@@ -25,14 +25,13 @@ bool sanity_test_list(unsigned int size)
{
std::list<unsigned int> test;
for (unsigned int i = 0; i != size; ++i)
- test.push_back(i+1);
+ test.push_back(i + 1);
if (test.size() != size)
return false;
- while (!test.empty())
- {
- if(test.back() != test.size())
+ while (!test.empty()) {
+ if (test.back() != test.size())
return false;
test.pop_back();
}
@@ -47,15 +46,12 @@ bool sanity_test_list(unsigned int size)
bool sanity_test_range_fmt()
{
std::string test;
- try
- {
+ try {
test.at(1);
- }
- catch (const std::out_of_range&)
- {
+ } catch (const std::out_of_range&) {
return true;
+ } catch (...) {
}
- catch (...){}
return false;
}
diff --git a/src/core.cpp b/src/core.cpp
index 8dcda0126a..e52327ba8e 100644
--- a/src/core.cpp
+++ b/src/core.cpp
@@ -124,6 +124,14 @@ int64_t CTransaction::GetValueOut() const
double CTransaction::ComputePriority(double dPriorityInputs, unsigned int nTxSize) const
{
+ nTxSize = CalculateModifiedSize(nTxSize);
+ if (nTxSize == 0) return 0.0;
+
+ return dPriorityInputs / nTxSize;
+}
+
+unsigned int CTransaction::CalculateModifiedSize(unsigned int nTxSize) const
+{
// In order to avoid disincentivizing cleaning up the UTXO set we don't count
// the constant overhead for each txin and up to 110 bytes of scriptSig (which
// is enough to cover a compressed pubkey p2sh redemption) for priority.
@@ -131,14 +139,14 @@ double CTransaction::ComputePriority(double dPriorityInputs, unsigned int nTxSiz
// risk encouraging people to create junk outputs to redeem later.
if (nTxSize == 0)
nTxSize = ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION);
+
BOOST_FOREACH(const CTxIn& txin, vin)
{
unsigned int offset = 41U + std::min(110U, (unsigned int)txin.scriptSig.size());
if (nTxSize > offset)
nTxSize -= offset;
}
- if (nTxSize == 0) return 0.0;
- return dPriorityInputs / nTxSize;
+ return nTxSize;
}
std::string CTransaction::ToString() const
@@ -218,6 +226,13 @@ uint256 CBlockHeader::GetHash() const
uint256 CBlock::BuildMerkleTree() const
{
+ // WARNING! If you're reading this because you're learning about crypto
+ // and/or designing a new system that will use merkle trees, keep in mind
+ // that the following merkle tree algorithm has a serious flaw related to
+ // duplicate txids, resulting in a vulnerability. (CVE-2012-2459) Bitcoin
+ // has since worked around the flaw, but for new applications you should
+ // use something different; don't just copy-and-paste this code without
+ // understanding the problem first.
vMerkleTree.clear();
BOOST_FOREACH(const CTransaction& tx, vtx)
vMerkleTree.push_back(tx.GetHash());
diff --git a/src/core.h b/src/core.h
index 030eb17734..9a2ac47487 100644
--- a/src/core.h
+++ b/src/core.h
@@ -283,6 +283,9 @@ public:
// Compute priority, given priority of inputs and (optionally) tx size
double ComputePriority(double dPriorityInputs, unsigned int nTxSize=0) const;
+ // Compute modified tx size for priority calculation (optionally given tx size)
+ unsigned int CalculateModifiedSize(unsigned int nTxSize=0) const;
+
bool IsCoinBase() const
{
return (vin.size() == 1 && vin[0].prevout.IsNull());
diff --git a/src/core_io.h b/src/core_io.h
index adf74cce32..6268a3bf58 100644
--- a/src/core_io.h
+++ b/src/core_io.h
@@ -8,9 +8,9 @@
#include <string>
#include <vector>
-class uint256;
class CScript;
class CTransaction;
+class uint256;
class UniValue;
// core_read.cpp
diff --git a/src/core_read.cpp b/src/core_read.cpp
index efcecb106f..6bd3d9a4fa 100644
--- a/src/core_read.cpp
+++ b/src/core_read.cpp
@@ -3,21 +3,22 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "core_io.h"
+
#include "core.h"
-#include "serialize.h"
#include "script/script.h"
+#include "serialize.h"
+#include "univalue/univalue.h"
#include "util.h"
-#include <boost/assign/list_of.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/predicate.hpp>
-#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/replace.hpp>
-#include "univalue/univalue.h"
+#include <boost/algorithm/string/split.hpp>
+#include <boost/assign/list_of.hpp>
-using namespace std;
using namespace boost;
using namespace boost::algorithm;
+using namespace std;
CScript ParseScript(std::string s)
{
@@ -97,7 +98,7 @@ bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx)
try {
ssData >> tx;
}
- catch (std::exception &e) {
+ catch (const std::exception &) {
return false;
}
diff --git a/src/core_write.cpp b/src/core_write.cpp
index 62712b1ba0..cd64aabf63 100644
--- a/src/core_write.cpp
+++ b/src/core_write.cpp
@@ -3,14 +3,15 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "core_io.h"
-#include "univalue/univalue.h"
+
+#include "base58.h"
+#include "core.h"
#include "script/script.h"
#include "script/standard.h"
-#include "core.h"
#include "serialize.h"
+#include "univalue/univalue.h"
#include "util.h"
#include "utilmoneystr.h"
-#include "base58.h"
#include <boost/foreach.hpp>
diff --git a/src/crypter.cpp b/src/crypter.cpp
index 3df13021df..a872df7024 100644
--- a/src/crypter.cpp
+++ b/src/crypter.cpp
@@ -62,9 +62,9 @@ bool CCrypter::Encrypt(const CKeyingMaterial& vchPlaintext, std::vector<unsigned
bool fOk = true;
EVP_CIPHER_CTX_init(&ctx);
- if (fOk) fOk = EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV);
- if (fOk) fOk = EVP_EncryptUpdate(&ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen);
- if (fOk) fOk = EVP_EncryptFinal_ex(&ctx, (&vchCiphertext[0])+nCLen, &nFLen);
+ if (fOk) fOk = EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV) != 0;
+ if (fOk) fOk = EVP_EncryptUpdate(&ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen) != 0;
+ if (fOk) fOk = EVP_EncryptFinal_ex(&ctx, (&vchCiphertext[0]) + nCLen, &nFLen) != 0;
EVP_CIPHER_CTX_cleanup(&ctx);
if (!fOk) return false;
@@ -89,9 +89,9 @@ bool CCrypter::Decrypt(const std::vector<unsigned char>& vchCiphertext, CKeyingM
bool fOk = true;
EVP_CIPHER_CTX_init(&ctx);
- if (fOk) fOk = EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV);
- if (fOk) fOk = EVP_DecryptUpdate(&ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen);
- if (fOk) fOk = EVP_DecryptFinal_ex(&ctx, (&vchPlaintext[0])+nPLen, &nFLen);
+ if (fOk) fOk = EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV) != 0;
+ if (fOk) fOk = EVP_DecryptUpdate(&ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen) != 0;
+ if (fOk) fOk = EVP_DecryptFinal_ex(&ctx, (&vchPlaintext[0]) + nPLen, &nFLen) != 0;
EVP_CIPHER_CTX_cleanup(&ctx);
if (!fOk) return false;
diff --git a/src/crypto/common.h b/src/crypto/common.h
index 8f675a16c5..7c3d0a135b 100644
--- a/src/crypto/common.h
+++ b/src/crypto/common.h
@@ -13,7 +13,8 @@
#include <endian.h>
#endif
-uint32_t static inline ReadLE32(const unsigned char *ptr) {
+uint32_t static inline ReadLE32(const unsigned char* ptr)
+{
#if HAVE_DECL_LE32TOH == 1
return le32toh(*((uint32_t*)ptr));
#elif !defined(WORDS_BIGENDIAN)
@@ -23,8 +24,8 @@ uint32_t static inline ReadLE32(const unsigned char *ptr) {
#endif
}
-uint64_t static inline ReadLE64(const unsigned char *ptr) {
-
+uint64_t static inline ReadLE64(const unsigned char* ptr)
+{
#if HAVE_DECL_LE64TOH == 1
return le64toh(*((uint64_t*)ptr));
#elif !defined(WORDS_BIGENDIAN)
@@ -35,28 +36,40 @@ uint64_t static inline ReadLE64(const unsigned char *ptr) {
#endif
}
-void static inline WriteLE32(unsigned char *ptr, uint32_t x) {
+void static inline WriteLE32(unsigned char* ptr, uint32_t x)
+{
#if HAVE_DECL_HTOLE32 == 1
*((uint32_t*)ptr) = htole32(x);
#elif !defined(WORDS_BIGENDIAN)
*((uint32_t*)ptr) = x;
#else
- ptr[3] = x >> 24; ptr[2] = x >> 16; ptr[1] = x >> 8; ptr[0] = x;
+ ptr[3] = x >> 24;
+ ptr[2] = x >> 16;
+ ptr[1] = x >> 8;
+ ptr[0] = x;
#endif
}
-void static inline WriteLE64(unsigned char *ptr, uint64_t x) {
+void static inline WriteLE64(unsigned char* ptr, uint64_t x)
+{
#if HAVE_DECL_HTOLE64 == 1
*((uint64_t*)ptr) = htole64(x);
#elif !defined(WORDS_BIGENDIAN)
*((uint64_t*)ptr) = x;
#else
- ptr[7] = x >> 56; ptr[6] = x >> 48; ptr[5] = x >> 40; ptr[4] = x >> 32;
- ptr[3] = x >> 24; ptr[2] = x >> 16; ptr[1] = x >> 8; ptr[0] = x;
+ ptr[7] = x >> 56;
+ ptr[6] = x >> 48;
+ ptr[5] = x >> 40;
+ ptr[4] = x >> 32;
+ ptr[3] = x >> 24;
+ ptr[2] = x >> 16;
+ ptr[1] = x >> 8;
+ ptr[0] = x;
#endif
}
-uint32_t static inline ReadBE32(const unsigned char *ptr) {
+uint32_t static inline ReadBE32(const unsigned char* ptr)
+{
#if HAVE_DECL_BE32TOH == 1
return be32toh(*((uint32_t*)ptr));
#else
@@ -64,7 +77,8 @@ uint32_t static inline ReadBE32(const unsigned char *ptr) {
#endif
}
-uint64_t static inline ReadBE64(const unsigned char *ptr) {
+uint64_t static inline ReadBE64(const unsigned char* ptr)
+{
#if HAVE_DECL_BE64TOH == 1
return be64toh(*((uint64_t*)ptr));
#else
@@ -73,20 +87,31 @@ uint64_t static inline ReadBE64(const unsigned char *ptr) {
#endif
}
-void static inline WriteBE32(unsigned char *ptr, uint32_t x) {
+void static inline WriteBE32(unsigned char* ptr, uint32_t x)
+{
#if HAVE_DECL_HTOBE32 == 1
*((uint32_t*)ptr) = htobe32(x);
#else
- ptr[0] = x >> 24; ptr[1] = x >> 16; ptr[2] = x >> 8; ptr[3] = x;
+ ptr[0] = x >> 24;
+ ptr[1] = x >> 16;
+ ptr[2] = x >> 8;
+ ptr[3] = x;
#endif
}
-void static inline WriteBE64(unsigned char *ptr, uint64_t x) {
+void static inline WriteBE64(unsigned char* ptr, uint64_t x)
+{
#if HAVE_DECL_HTOBE64 == 1
*((uint64_t*)ptr) = htobe64(x);
#else
- ptr[0] = x >> 56; ptr[1] = x >> 48; ptr[2] = x >> 40; ptr[3] = x >> 32;
- ptr[4] = x >> 24; ptr[5] = x >> 16; ptr[6] = x >> 8; ptr[7] = x;
+ ptr[0] = x >> 56;
+ ptr[1] = x >> 48;
+ ptr[2] = x >> 40;
+ ptr[3] = x >> 32;
+ ptr[4] = x >> 24;
+ ptr[5] = x >> 16;
+ ptr[6] = x >> 8;
+ ptr[7] = x;
#endif
}
diff --git a/src/crypto/ripemd160.cpp b/src/crypto/ripemd160.cpp
index 24bd318d43..90b196ba32 100644
--- a/src/crypto/ripemd160.cpp
+++ b/src/crypto/ripemd160.cpp
@@ -5,14 +5,15 @@
#include "crypto/ripemd160.h"
#include "crypto/common.h"
+
#include <string.h>
// Internal implementation code.
-namespace {
-
+namespace
+{
/// Internal RIPEMD-160 implementation.
-namespace ripemd160 {
-
+namespace ripemd160
+{
uint32_t inline f1(uint32_t x, uint32_t y, uint32_t z) { return x ^ y ^ z; }
uint32_t inline f2(uint32_t x, uint32_t y, uint32_t z) { return (x & y) | (~x & z); }
uint32_t inline f3(uint32_t x, uint32_t y, uint32_t z) { return (x | ~y) ^ z; }
@@ -20,7 +21,8 @@ uint32_t inline f4(uint32_t x, uint32_t y, uint32_t z) { return (x & z) | (y & ~
uint32_t inline f5(uint32_t x, uint32_t y, uint32_t z) { return x ^ (y | ~z); }
/** Initialize RIPEMD-160 state. */
-void inline Initialize(uint32_t *s) {
+void inline Initialize(uint32_t* s)
+{
s[0] = 0x67452301ul;
s[1] = 0xEFCDAB89ul;
s[2] = 0x98BADCFEul;
@@ -28,139 +30,223 @@ void inline Initialize(uint32_t *s) {
s[4] = 0xC3D2E1F0ul;
}
-uint32_t inline rol(uint32_t x, int i) { return (x << i) | (x >> (32-i)); }
+uint32_t inline rol(uint32_t x, int i) { return (x << i) | (x >> (32 - i)); }
-void inline Round(uint32_t &a, uint32_t b, uint32_t &c, uint32_t d, uint32_t e, uint32_t f, uint32_t x, uint32_t k, int r) {
+void inline Round(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t f, uint32_t x, uint32_t k, int r)
+{
a = rol(a + f + x + k, r) + e;
c = rol(c, 10);
}
-void inline R11(uint32_t &a, uint32_t b, uint32_t &c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f1(b, c, d), x, 0, r); }
-void inline R21(uint32_t &a, uint32_t b, uint32_t &c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f2(b, c, d), x, 0x5A827999ul, r); }
-void inline R31(uint32_t &a, uint32_t b, uint32_t &c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f3(b, c, d), x, 0x6ED9EBA1ul, r); }
-void inline R41(uint32_t &a, uint32_t b, uint32_t &c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f4(b, c, d), x, 0x8F1BBCDCul, r); }
-void inline R51(uint32_t &a, uint32_t b, uint32_t &c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f5(b, c, d), x, 0xA953FD4Eul, r); }
+void inline R11(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f1(b, c, d), x, 0, r); }
+void inline R21(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f2(b, c, d), x, 0x5A827999ul, r); }
+void inline R31(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f3(b, c, d), x, 0x6ED9EBA1ul, r); }
+void inline R41(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f4(b, c, d), x, 0x8F1BBCDCul, r); }
+void inline R51(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f5(b, c, d), x, 0xA953FD4Eul, r); }
-void inline R12(uint32_t &a, uint32_t b, uint32_t &c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f5(b, c, d), x, 0x50A28BE6ul, r); }
-void inline R22(uint32_t &a, uint32_t b, uint32_t &c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f4(b, c, d), x, 0x5C4DD124ul, r); }
-void inline R32(uint32_t &a, uint32_t b, uint32_t &c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f3(b, c, d), x, 0x6D703EF3ul, r); }
-void inline R42(uint32_t &a, uint32_t b, uint32_t &c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f2(b, c, d), x, 0x7A6D76E9ul, r); }
-void inline R52(uint32_t &a, uint32_t b, uint32_t &c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f1(b, c, d), x, 0, r); }
+void inline R12(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f5(b, c, d), x, 0x50A28BE6ul, r); }
+void inline R22(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f4(b, c, d), x, 0x5C4DD124ul, r); }
+void inline R32(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f3(b, c, d), x, 0x6D703EF3ul, r); }
+void inline R42(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f2(b, c, d), x, 0x7A6D76E9ul, r); }
+void inline R52(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x, int r) { Round(a, b, c, d, e, f1(b, c, d), x, 0, r); }
/** Perform a RIPEMD-160 transformation, processing a 64-byte chunk. */
-void Transform(uint32_t *s, const unsigned char *chunk) {
+void Transform(uint32_t* s, const unsigned char* chunk)
+{
uint32_t a1 = s[0], b1 = s[1], c1 = s[2], d1 = s[3], e1 = s[4];
- uint32_t a2 = a1 , b2 = b1 , c2 = c1 , d2 = d1 , e2 = e1 ;
- uint32_t w0 = ReadLE32(chunk + 0), w1 = ReadLE32(chunk + 4), w2 = ReadLE32(chunk + 8), w3 = ReadLE32(chunk + 12);
- uint32_t w4 = ReadLE32(chunk + 16), w5 = ReadLE32(chunk + 20), w6 = ReadLE32(chunk + 24), w7 = ReadLE32(chunk + 28);
- uint32_t w8 = ReadLE32(chunk + 32), w9 = ReadLE32(chunk + 36), w10 = ReadLE32(chunk + 40), w11 = ReadLE32(chunk + 44);
+ uint32_t a2 = a1, b2 = b1, c2 = c1, d2 = d1, e2 = e1;
+ uint32_t w0 = ReadLE32(chunk + 0), w1 = ReadLE32(chunk + 4), w2 = ReadLE32(chunk + 8), w3 = ReadLE32(chunk + 12);
+ uint32_t w4 = ReadLE32(chunk + 16), w5 = ReadLE32(chunk + 20), w6 = ReadLE32(chunk + 24), w7 = ReadLE32(chunk + 28);
+ uint32_t w8 = ReadLE32(chunk + 32), w9 = ReadLE32(chunk + 36), w10 = ReadLE32(chunk + 40), w11 = ReadLE32(chunk + 44);
uint32_t w12 = ReadLE32(chunk + 48), w13 = ReadLE32(chunk + 52), w14 = ReadLE32(chunk + 56), w15 = ReadLE32(chunk + 60);
- R11(a1, b1, c1, d1, e1, w0 , 11); R12(a2, b2, c2, d2, e2, w5 , 8);
- R11(e1, a1, b1, c1, d1, w1 , 14); R12(e2, a2, b2, c2, d2, w14, 9);
- R11(d1, e1, a1, b1, c1, w2 , 15); R12(d2, e2, a2, b2, c2, w7 , 9);
- R11(c1, d1, e1, a1, b1, w3 , 12); R12(c2, d2, e2, a2, b2, w0 , 11);
- R11(b1, c1, d1, e1, a1, w4 , 5); R12(b2, c2, d2, e2, a2, w9 , 13);
- R11(a1, b1, c1, d1, e1, w5 , 8); R12(a2, b2, c2, d2, e2, w2 , 15);
- R11(e1, a1, b1, c1, d1, w6 , 7); R12(e2, a2, b2, c2, d2, w11, 15);
- R11(d1, e1, a1, b1, c1, w7 , 9); R12(d2, e2, a2, b2, c2, w4 , 5);
- R11(c1, d1, e1, a1, b1, w8 , 11); R12(c2, d2, e2, a2, b2, w13, 7);
- R11(b1, c1, d1, e1, a1, w9 , 13); R12(b2, c2, d2, e2, a2, w6 , 7);
- R11(a1, b1, c1, d1, e1, w10, 14); R12(a2, b2, c2, d2, e2, w15, 8);
- R11(e1, a1, b1, c1, d1, w11, 15); R12(e2, a2, b2, c2, d2, w8 , 11);
- R11(d1, e1, a1, b1, c1, w12, 6); R12(d2, e2, a2, b2, c2, w1 , 14);
- R11(c1, d1, e1, a1, b1, w13, 7); R12(c2, d2, e2, a2, b2, w10, 14);
- R11(b1, c1, d1, e1, a1, w14, 9); R12(b2, c2, d2, e2, a2, w3 , 12);
- R11(a1, b1, c1, d1, e1, w15, 8); R12(a2, b2, c2, d2, e2, w12, 6);
-
- R21(e1, a1, b1, c1, d1, w7 , 7); R22(e2, a2, b2, c2, d2, w6 , 9);
- R21(d1, e1, a1, b1, c1, w4 , 6); R22(d2, e2, a2, b2, c2, w11, 13);
- R21(c1, d1, e1, a1, b1, w13, 8); R22(c2, d2, e2, a2, b2, w3 , 15);
- R21(b1, c1, d1, e1, a1, w1 , 13); R22(b2, c2, d2, e2, a2, w7 , 7);
- R21(a1, b1, c1, d1, e1, w10, 11); R22(a2, b2, c2, d2, e2, w0 , 12);
- R21(e1, a1, b1, c1, d1, w6 , 9); R22(e2, a2, b2, c2, d2, w13, 8);
- R21(d1, e1, a1, b1, c1, w15, 7); R22(d2, e2, a2, b2, c2, w5 , 9);
- R21(c1, d1, e1, a1, b1, w3 , 15); R22(c2, d2, e2, a2, b2, w10, 11);
- R21(b1, c1, d1, e1, a1, w12, 7); R22(b2, c2, d2, e2, a2, w14, 7);
- R21(a1, b1, c1, d1, e1, w0 , 12); R22(a2, b2, c2, d2, e2, w15, 7);
- R21(e1, a1, b1, c1, d1, w9 , 15); R22(e2, a2, b2, c2, d2, w8 , 12);
- R21(d1, e1, a1, b1, c1, w5 , 9); R22(d2, e2, a2, b2, c2, w12, 7);
- R21(c1, d1, e1, a1, b1, w2 , 11); R22(c2, d2, e2, a2, b2, w4 , 6);
- R21(b1, c1, d1, e1, a1, w14, 7); R22(b2, c2, d2, e2, a2, w9 , 15);
- R21(a1, b1, c1, d1, e1, w11, 13); R22(a2, b2, c2, d2, e2, w1 , 13);
- R21(e1, a1, b1, c1, d1, w8 , 12); R22(e2, a2, b2, c2, d2, w2 , 11);
-
- R31(d1, e1, a1, b1, c1, w3 , 11); R32(d2, e2, a2, b2, c2, w15, 9);
- R31(c1, d1, e1, a1, b1, w10, 13); R32(c2, d2, e2, a2, b2, w5 , 7);
- R31(b1, c1, d1, e1, a1, w14, 6); R32(b2, c2, d2, e2, a2, w1 , 15);
- R31(a1, b1, c1, d1, e1, w4 , 7); R32(a2, b2, c2, d2, e2, w3 , 11);
- R31(e1, a1, b1, c1, d1, w9 , 14); R32(e2, a2, b2, c2, d2, w7 , 8);
- R31(d1, e1, a1, b1, c1, w15, 9); R32(d2, e2, a2, b2, c2, w14, 6);
- R31(c1, d1, e1, a1, b1, w8 , 13); R32(c2, d2, e2, a2, b2, w6 , 6);
- R31(b1, c1, d1, e1, a1, w1 , 15); R32(b2, c2, d2, e2, a2, w9 , 14);
- R31(a1, b1, c1, d1, e1, w2 , 14); R32(a2, b2, c2, d2, e2, w11, 12);
- R31(e1, a1, b1, c1, d1, w7 , 8); R32(e2, a2, b2, c2, d2, w8 , 13);
- R31(d1, e1, a1, b1, c1, w0 , 13); R32(d2, e2, a2, b2, c2, w12, 5);
- R31(c1, d1, e1, a1, b1, w6 , 6); R32(c2, d2, e2, a2, b2, w2 , 14);
- R31(b1, c1, d1, e1, a1, w13, 5); R32(b2, c2, d2, e2, a2, w10, 13);
- R31(a1, b1, c1, d1, e1, w11, 12); R32(a2, b2, c2, d2, e2, w0 , 13);
- R31(e1, a1, b1, c1, d1, w5 , 7); R32(e2, a2, b2, c2, d2, w4 , 7);
- R31(d1, e1, a1, b1, c1, w12, 5); R32(d2, e2, a2, b2, c2, w13, 5);
-
- R41(c1, d1, e1, a1, b1, w1 , 11); R42(c2, d2, e2, a2, b2, w8 , 15);
- R41(b1, c1, d1, e1, a1, w9 , 12); R42(b2, c2, d2, e2, a2, w6 , 5);
- R41(a1, b1, c1, d1, e1, w11, 14); R42(a2, b2, c2, d2, e2, w4 , 8);
- R41(e1, a1, b1, c1, d1, w10, 15); R42(e2, a2, b2, c2, d2, w1 , 11);
- R41(d1, e1, a1, b1, c1, w0 , 14); R42(d2, e2, a2, b2, c2, w3 , 14);
- R41(c1, d1, e1, a1, b1, w8 , 15); R42(c2, d2, e2, a2, b2, w11, 14);
- R41(b1, c1, d1, e1, a1, w12, 9); R42(b2, c2, d2, e2, a2, w15, 6);
- R41(a1, b1, c1, d1, e1, w4 , 8); R42(a2, b2, c2, d2, e2, w0 , 14);
- R41(e1, a1, b1, c1, d1, w13, 9); R42(e2, a2, b2, c2, d2, w5 , 6);
- R41(d1, e1, a1, b1, c1, w3 , 14); R42(d2, e2, a2, b2, c2, w12, 9);
- R41(c1, d1, e1, a1, b1, w7 , 5); R42(c2, d2, e2, a2, b2, w2 , 12);
- R41(b1, c1, d1, e1, a1, w15, 6); R42(b2, c2, d2, e2, a2, w13, 9);
- R41(a1, b1, c1, d1, e1, w14, 8); R42(a2, b2, c2, d2, e2, w9 , 12);
- R41(e1, a1, b1, c1, d1, w5 , 6); R42(e2, a2, b2, c2, d2, w7 , 5);
- R41(d1, e1, a1, b1, c1, w6 , 5); R42(d2, e2, a2, b2, c2, w10, 15);
- R41(c1, d1, e1, a1, b1, w2 , 12); R42(c2, d2, e2, a2, b2, w14, 8);
-
- R51(b1, c1, d1, e1, a1, w4 , 9); R52(b2, c2, d2, e2, a2, w12, 8);
- R51(a1, b1, c1, d1, e1, w0 , 15); R52(a2, b2, c2, d2, e2, w15, 5);
- R51(e1, a1, b1, c1, d1, w5 , 5); R52(e2, a2, b2, c2, d2, w10, 12);
- R51(d1, e1, a1, b1, c1, w9 , 11); R52(d2, e2, a2, b2, c2, w4 , 9);
- R51(c1, d1, e1, a1, b1, w7 , 6); R52(c2, d2, e2, a2, b2, w1 , 12);
- R51(b1, c1, d1, e1, a1, w12, 8); R52(b2, c2, d2, e2, a2, w5 , 5);
- R51(a1, b1, c1, d1, e1, w2 , 13); R52(a2, b2, c2, d2, e2, w8 , 14);
- R51(e1, a1, b1, c1, d1, w10, 12); R52(e2, a2, b2, c2, d2, w7 , 6);
- R51(d1, e1, a1, b1, c1, w14, 5); R52(d2, e2, a2, b2, c2, w6 , 8);
- R51(c1, d1, e1, a1, b1, w1 , 12); R52(c2, d2, e2, a2, b2, w2 , 13);
- R51(b1, c1, d1, e1, a1, w3 , 13); R52(b2, c2, d2, e2, a2, w13, 6);
- R51(a1, b1, c1, d1, e1, w8 , 14); R52(a2, b2, c2, d2, e2, w14, 5);
- R51(e1, a1, b1, c1, d1, w11, 11); R52(e2, a2, b2, c2, d2, w0 , 15);
- R51(d1, e1, a1, b1, c1, w6 , 8); R52(d2, e2, a2, b2, c2, w3 , 13);
- R51(c1, d1, e1, a1, b1, w15, 5); R52(c2, d2, e2, a2, b2, w9 , 11);
- R51(b1, c1, d1, e1, a1, w13, 6); R52(b2, c2, d2, e2, a2, w11, 11);
+ R11(a1, b1, c1, d1, e1, w0, 11);
+ R12(a2, b2, c2, d2, e2, w5, 8);
+ R11(e1, a1, b1, c1, d1, w1, 14);
+ R12(e2, a2, b2, c2, d2, w14, 9);
+ R11(d1, e1, a1, b1, c1, w2, 15);
+ R12(d2, e2, a2, b2, c2, w7, 9);
+ R11(c1, d1, e1, a1, b1, w3, 12);
+ R12(c2, d2, e2, a2, b2, w0, 11);
+ R11(b1, c1, d1, e1, a1, w4, 5);
+ R12(b2, c2, d2, e2, a2, w9, 13);
+ R11(a1, b1, c1, d1, e1, w5, 8);
+ R12(a2, b2, c2, d2, e2, w2, 15);
+ R11(e1, a1, b1, c1, d1, w6, 7);
+ R12(e2, a2, b2, c2, d2, w11, 15);
+ R11(d1, e1, a1, b1, c1, w7, 9);
+ R12(d2, e2, a2, b2, c2, w4, 5);
+ R11(c1, d1, e1, a1, b1, w8, 11);
+ R12(c2, d2, e2, a2, b2, w13, 7);
+ R11(b1, c1, d1, e1, a1, w9, 13);
+ R12(b2, c2, d2, e2, a2, w6, 7);
+ R11(a1, b1, c1, d1, e1, w10, 14);
+ R12(a2, b2, c2, d2, e2, w15, 8);
+ R11(e1, a1, b1, c1, d1, w11, 15);
+ R12(e2, a2, b2, c2, d2, w8, 11);
+ R11(d1, e1, a1, b1, c1, w12, 6);
+ R12(d2, e2, a2, b2, c2, w1, 14);
+ R11(c1, d1, e1, a1, b1, w13, 7);
+ R12(c2, d2, e2, a2, b2, w10, 14);
+ R11(b1, c1, d1, e1, a1, w14, 9);
+ R12(b2, c2, d2, e2, a2, w3, 12);
+ R11(a1, b1, c1, d1, e1, w15, 8);
+ R12(a2, b2, c2, d2, e2, w12, 6);
+
+ R21(e1, a1, b1, c1, d1, w7, 7);
+ R22(e2, a2, b2, c2, d2, w6, 9);
+ R21(d1, e1, a1, b1, c1, w4, 6);
+ R22(d2, e2, a2, b2, c2, w11, 13);
+ R21(c1, d1, e1, a1, b1, w13, 8);
+ R22(c2, d2, e2, a2, b2, w3, 15);
+ R21(b1, c1, d1, e1, a1, w1, 13);
+ R22(b2, c2, d2, e2, a2, w7, 7);
+ R21(a1, b1, c1, d1, e1, w10, 11);
+ R22(a2, b2, c2, d2, e2, w0, 12);
+ R21(e1, a1, b1, c1, d1, w6, 9);
+ R22(e2, a2, b2, c2, d2, w13, 8);
+ R21(d1, e1, a1, b1, c1, w15, 7);
+ R22(d2, e2, a2, b2, c2, w5, 9);
+ R21(c1, d1, e1, a1, b1, w3, 15);
+ R22(c2, d2, e2, a2, b2, w10, 11);
+ R21(b1, c1, d1, e1, a1, w12, 7);
+ R22(b2, c2, d2, e2, a2, w14, 7);
+ R21(a1, b1, c1, d1, e1, w0, 12);
+ R22(a2, b2, c2, d2, e2, w15, 7);
+ R21(e1, a1, b1, c1, d1, w9, 15);
+ R22(e2, a2, b2, c2, d2, w8, 12);
+ R21(d1, e1, a1, b1, c1, w5, 9);
+ R22(d2, e2, a2, b2, c2, w12, 7);
+ R21(c1, d1, e1, a1, b1, w2, 11);
+ R22(c2, d2, e2, a2, b2, w4, 6);
+ R21(b1, c1, d1, e1, a1, w14, 7);
+ R22(b2, c2, d2, e2, a2, w9, 15);
+ R21(a1, b1, c1, d1, e1, w11, 13);
+ R22(a2, b2, c2, d2, e2, w1, 13);
+ R21(e1, a1, b1, c1, d1, w8, 12);
+ R22(e2, a2, b2, c2, d2, w2, 11);
+
+ R31(d1, e1, a1, b1, c1, w3, 11);
+ R32(d2, e2, a2, b2, c2, w15, 9);
+ R31(c1, d1, e1, a1, b1, w10, 13);
+ R32(c2, d2, e2, a2, b2, w5, 7);
+ R31(b1, c1, d1, e1, a1, w14, 6);
+ R32(b2, c2, d2, e2, a2, w1, 15);
+ R31(a1, b1, c1, d1, e1, w4, 7);
+ R32(a2, b2, c2, d2, e2, w3, 11);
+ R31(e1, a1, b1, c1, d1, w9, 14);
+ R32(e2, a2, b2, c2, d2, w7, 8);
+ R31(d1, e1, a1, b1, c1, w15, 9);
+ R32(d2, e2, a2, b2, c2, w14, 6);
+ R31(c1, d1, e1, a1, b1, w8, 13);
+ R32(c2, d2, e2, a2, b2, w6, 6);
+ R31(b1, c1, d1, e1, a1, w1, 15);
+ R32(b2, c2, d2, e2, a2, w9, 14);
+ R31(a1, b1, c1, d1, e1, w2, 14);
+ R32(a2, b2, c2, d2, e2, w11, 12);
+ R31(e1, a1, b1, c1, d1, w7, 8);
+ R32(e2, a2, b2, c2, d2, w8, 13);
+ R31(d1, e1, a1, b1, c1, w0, 13);
+ R32(d2, e2, a2, b2, c2, w12, 5);
+ R31(c1, d1, e1, a1, b1, w6, 6);
+ R32(c2, d2, e2, a2, b2, w2, 14);
+ R31(b1, c1, d1, e1, a1, w13, 5);
+ R32(b2, c2, d2, e2, a2, w10, 13);
+ R31(a1, b1, c1, d1, e1, w11, 12);
+ R32(a2, b2, c2, d2, e2, w0, 13);
+ R31(e1, a1, b1, c1, d1, w5, 7);
+ R32(e2, a2, b2, c2, d2, w4, 7);
+ R31(d1, e1, a1, b1, c1, w12, 5);
+ R32(d2, e2, a2, b2, c2, w13, 5);
+
+ R41(c1, d1, e1, a1, b1, w1, 11);
+ R42(c2, d2, e2, a2, b2, w8, 15);
+ R41(b1, c1, d1, e1, a1, w9, 12);
+ R42(b2, c2, d2, e2, a2, w6, 5);
+ R41(a1, b1, c1, d1, e1, w11, 14);
+ R42(a2, b2, c2, d2, e2, w4, 8);
+ R41(e1, a1, b1, c1, d1, w10, 15);
+ R42(e2, a2, b2, c2, d2, w1, 11);
+ R41(d1, e1, a1, b1, c1, w0, 14);
+ R42(d2, e2, a2, b2, c2, w3, 14);
+ R41(c1, d1, e1, a1, b1, w8, 15);
+ R42(c2, d2, e2, a2, b2, w11, 14);
+ R41(b1, c1, d1, e1, a1, w12, 9);
+ R42(b2, c2, d2, e2, a2, w15, 6);
+ R41(a1, b1, c1, d1, e1, w4, 8);
+ R42(a2, b2, c2, d2, e2, w0, 14);
+ R41(e1, a1, b1, c1, d1, w13, 9);
+ R42(e2, a2, b2, c2, d2, w5, 6);
+ R41(d1, e1, a1, b1, c1, w3, 14);
+ R42(d2, e2, a2, b2, c2, w12, 9);
+ R41(c1, d1, e1, a1, b1, w7, 5);
+ R42(c2, d2, e2, a2, b2, w2, 12);
+ R41(b1, c1, d1, e1, a1, w15, 6);
+ R42(b2, c2, d2, e2, a2, w13, 9);
+ R41(a1, b1, c1, d1, e1, w14, 8);
+ R42(a2, b2, c2, d2, e2, w9, 12);
+ R41(e1, a1, b1, c1, d1, w5, 6);
+ R42(e2, a2, b2, c2, d2, w7, 5);
+ R41(d1, e1, a1, b1, c1, w6, 5);
+ R42(d2, e2, a2, b2, c2, w10, 15);
+ R41(c1, d1, e1, a1, b1, w2, 12);
+ R42(c2, d2, e2, a2, b2, w14, 8);
+
+ R51(b1, c1, d1, e1, a1, w4, 9);
+ R52(b2, c2, d2, e2, a2, w12, 8);
+ R51(a1, b1, c1, d1, e1, w0, 15);
+ R52(a2, b2, c2, d2, e2, w15, 5);
+ R51(e1, a1, b1, c1, d1, w5, 5);
+ R52(e2, a2, b2, c2, d2, w10, 12);
+ R51(d1, e1, a1, b1, c1, w9, 11);
+ R52(d2, e2, a2, b2, c2, w4, 9);
+ R51(c1, d1, e1, a1, b1, w7, 6);
+ R52(c2, d2, e2, a2, b2, w1, 12);
+ R51(b1, c1, d1, e1, a1, w12, 8);
+ R52(b2, c2, d2, e2, a2, w5, 5);
+ R51(a1, b1, c1, d1, e1, w2, 13);
+ R52(a2, b2, c2, d2, e2, w8, 14);
+ R51(e1, a1, b1, c1, d1, w10, 12);
+ R52(e2, a2, b2, c2, d2, w7, 6);
+ R51(d1, e1, a1, b1, c1, w14, 5);
+ R52(d2, e2, a2, b2, c2, w6, 8);
+ R51(c1, d1, e1, a1, b1, w1, 12);
+ R52(c2, d2, e2, a2, b2, w2, 13);
+ R51(b1, c1, d1, e1, a1, w3, 13);
+ R52(b2, c2, d2, e2, a2, w13, 6);
+ R51(a1, b1, c1, d1, e1, w8, 14);
+ R52(a2, b2, c2, d2, e2, w14, 5);
+ R51(e1, a1, b1, c1, d1, w11, 11);
+ R52(e2, a2, b2, c2, d2, w0, 15);
+ R51(d1, e1, a1, b1, c1, w6, 8);
+ R52(d2, e2, a2, b2, c2, w3, 13);
+ R51(c1, d1, e1, a1, b1, w15, 5);
+ R52(c2, d2, e2, a2, b2, w9, 11);
+ R51(b1, c1, d1, e1, a1, w13, 6);
+ R52(b2, c2, d2, e2, a2, w11, 11);
uint32_t t = s[0];
s[0] = s[1] + c1 + d2;
s[1] = s[2] + d1 + e2;
s[2] = s[3] + e1 + a2;
s[3] = s[4] + a1 + b2;
- s[4] = t + b1 + c2;
+ s[4] = t + b1 + c2;
}
-} // namespace ripemd160
+} // namespace ripemd160
-} // namespace
+} // namespace
////// RIPEMD160
-CRIPEMD160::CRIPEMD160() : bytes(0) {
+CRIPEMD160::CRIPEMD160() : bytes(0)
+{
ripemd160::Initialize(s);
}
-CRIPEMD160& CRIPEMD160::Write(const unsigned char *data, size_t len) {
- const unsigned char *end = data + len;
+CRIPEMD160& CRIPEMD160::Write(const unsigned char* data, size_t len)
+{
+ const unsigned char* end = data + len;
size_t bufsize = bytes % 64;
if (bufsize && bufsize + len >= 64) {
// Fill the buffer, and process it.
@@ -184,20 +270,22 @@ CRIPEMD160& CRIPEMD160::Write(const unsigned char *data, size_t len) {
return *this;
}
-void CRIPEMD160::Finalize(unsigned char hash[OUTPUT_SIZE]) {
+void CRIPEMD160::Finalize(unsigned char hash[OUTPUT_SIZE])
+{
static const unsigned char pad[64] = {0x80};
unsigned char sizedesc[8];
WriteLE64(sizedesc, bytes << 3);
Write(pad, 1 + ((119 - (bytes % 64)) % 64));
Write(sizedesc, 8);
WriteLE32(hash, s[0]);
- WriteLE32(hash+4, s[1]);
- WriteLE32(hash+8, s[2]);
- WriteLE32(hash+12, s[3]);
- WriteLE32(hash+16, s[4]);
+ WriteLE32(hash + 4, s[1]);
+ WriteLE32(hash + 8, s[2]);
+ WriteLE32(hash + 12, s[3]);
+ WriteLE32(hash + 16, s[4]);
}
-CRIPEMD160& CRIPEMD160::Reset() {
+CRIPEMD160& CRIPEMD160::Reset()
+{
bytes = 0;
ripemd160::Initialize(s);
return *this;
diff --git a/src/crypto/ripemd160.h b/src/crypto/ripemd160.h
index 44bd4879a5..76197543be 100644
--- a/src/crypto/ripemd160.h
+++ b/src/crypto/ripemd160.h
@@ -9,7 +9,8 @@
#include <stdlib.h>
/** A hasher class for RIPEMD-160. */
-class CRIPEMD160 {
+class CRIPEMD160
+{
private:
uint32_t s[5];
unsigned char buf[64];
@@ -19,7 +20,7 @@ public:
static const size_t OUTPUT_SIZE = 20;
CRIPEMD160();
- CRIPEMD160& Write(const unsigned char *data, size_t len);
+ CRIPEMD160& Write(const unsigned char* data, size_t len);
void Finalize(unsigned char hash[OUTPUT_SIZE]);
CRIPEMD160& Reset();
};
diff --git a/src/crypto/sha1.cpp b/src/crypto/sha1.cpp
index 304401a50f..5fbea002d6 100644
--- a/src/crypto/sha1.cpp
+++ b/src/crypto/sha1.cpp
@@ -5,17 +5,18 @@
#include "crypto/sha1.h"
#include "crypto/common.h"
+
#include <string.h>
// Internal implementation code.
-namespace {
-
+namespace
+{
/// Internal SHA-1 implementation.
-namespace sha1 {
-
+namespace sha1
+{
/** One round of SHA-1. */
-void inline Round(uint32_t a, uint32_t &b, uint32_t c, uint32_t d, uint32_t &e,
- uint32_t f, uint32_t k, uint32_t w) {
+void inline Round(uint32_t a, uint32_t& b, uint32_t c, uint32_t d, uint32_t& e, uint32_t f, uint32_t k, uint32_t w)
+{
e += ((a << 5) | (a >> 27)) + f + k + w;
b = (b << 30) | (b >> 2);
}
@@ -27,7 +28,8 @@ uint32_t inline f3(uint32_t b, uint32_t c, uint32_t d) { return (b & c) | (d & (
uint32_t inline left(uint32_t x) { return (x << 1) | (x >> 31); }
/** Initialize SHA-1 state. */
-void inline Initialize(uint32_t *s) {
+void inline Initialize(uint32_t* s)
+{
s[0] = 0x67452301ul;
s[1] = 0xEFCDAB89ul;
s[2] = 0x98BADCFEul;
@@ -41,20 +43,21 @@ const uint32_t k3 = 0x8F1BBCDCul;
const uint32_t k4 = 0xCA62C1D6ul;
/** Perform a SHA-1 transformation, processing a 64-byte chunk. */
-void Transform(uint32_t *s, const unsigned char *chunk) {
+void Transform(uint32_t* s, const unsigned char* chunk)
+{
uint32_t a = s[0], b = s[1], c = s[2], d = s[3], e = s[4];
uint32_t w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15;
- Round(a, b, c, d, e, f1(b, c, d), k1, w0 = ReadBE32(chunk + 0));
- Round(e, a, b, c, d, f1(a, b, c), k1, w1 = ReadBE32(chunk + 4));
- Round(d, e, a, b, c, f1(e, a, b), k1, w2 = ReadBE32(chunk + 8));
- Round(c, d, e, a, b, f1(d, e, a), k1, w3 = ReadBE32(chunk + 12));
- Round(b, c, d, e, a, f1(c, d, e), k1, w4 = ReadBE32(chunk + 16));
- Round(a, b, c, d, e, f1(b, c, d), k1, w5 = ReadBE32(chunk + 20));
- Round(e, a, b, c, d, f1(a, b, c), k1, w6 = ReadBE32(chunk + 24));
- Round(d, e, a, b, c, f1(e, a, b), k1, w7 = ReadBE32(chunk + 28));
- Round(c, d, e, a, b, f1(d, e, a), k1, w8 = ReadBE32(chunk + 32));
- Round(b, c, d, e, a, f1(c, d, e), k1, w9 = ReadBE32(chunk + 36));
+ Round(a, b, c, d, e, f1(b, c, d), k1, w0 = ReadBE32(chunk + 0));
+ Round(e, a, b, c, d, f1(a, b, c), k1, w1 = ReadBE32(chunk + 4));
+ Round(d, e, a, b, c, f1(e, a, b), k1, w2 = ReadBE32(chunk + 8));
+ Round(c, d, e, a, b, f1(d, e, a), k1, w3 = ReadBE32(chunk + 12));
+ Round(b, c, d, e, a, f1(c, d, e), k1, w4 = ReadBE32(chunk + 16));
+ Round(a, b, c, d, e, f1(b, c, d), k1, w5 = ReadBE32(chunk + 20));
+ Round(e, a, b, c, d, f1(a, b, c), k1, w6 = ReadBE32(chunk + 24));
+ Round(d, e, a, b, c, f1(e, a, b), k1, w7 = ReadBE32(chunk + 28));
+ Round(c, d, e, a, b, f1(d, e, a), k1, w8 = ReadBE32(chunk + 32));
+ Round(b, c, d, e, a, f1(c, d, e), k1, w9 = ReadBE32(chunk + 36));
Round(a, b, c, d, e, f1(b, c, d), k1, w10 = ReadBE32(chunk + 40));
Round(e, a, b, c, d, f1(a, b, c), k1, w11 = ReadBE32(chunk + 44));
Round(d, e, a, b, c, f1(e, a, b), k1, w12 = ReadBE32(chunk + 48));
@@ -62,73 +65,73 @@ void Transform(uint32_t *s, const unsigned char *chunk) {
Round(b, c, d, e, a, f1(c, d, e), k1, w14 = ReadBE32(chunk + 56));
Round(a, b, c, d, e, f1(b, c, d), k1, w15 = ReadBE32(chunk + 60));
- Round(e, a, b, c, d, f1(a, b, c), k1, w0 = left(w0 ^ w13 ^ w8 ^ w2 ));
- Round(d, e, a, b, c, f1(e, a, b), k1, w1 = left(w1 ^ w14 ^ w9 ^ w3 ));
- Round(c, d, e, a, b, f1(d, e, a), k1, w2 = left(w2 ^ w15 ^ w10 ^ w4 ));
- Round(b, c, d, e, a, f1(c, d, e), k1, w3 = left(w3 ^ w0 ^ w11 ^ w5 ));
- Round(a, b, c, d, e, f2(b, c, d), k2, w4 = left(w4 ^ w1 ^ w12 ^ w6 ));
- Round(e, a, b, c, d, f2(a, b, c), k2, w5 = left(w5 ^ w2 ^ w13 ^ w7 ));
- Round(d, e, a, b, c, f2(e, a, b), k2, w6 = left(w6 ^ w3 ^ w14 ^ w8 ));
- Round(c, d, e, a, b, f2(d, e, a), k2, w7 = left(w7 ^ w4 ^ w15 ^ w9 ));
- Round(b, c, d, e, a, f2(c, d, e), k2, w8 = left(w8 ^ w5 ^ w0 ^ w10));
- Round(a, b, c, d, e, f2(b, c, d), k2, w9 = left(w9 ^ w6 ^ w1 ^ w11));
- Round(e, a, b, c, d, f2(a, b, c), k2, w10 = left(w10 ^ w7 ^ w2 ^ w12));
- Round(d, e, a, b, c, f2(e, a, b), k2, w11 = left(w11 ^ w8 ^ w3 ^ w13));
- Round(c, d, e, a, b, f2(d, e, a), k2, w12 = left(w12 ^ w9 ^ w4 ^ w14));
- Round(b, c, d, e, a, f2(c, d, e), k2, w13 = left(w13 ^ w10 ^ w5 ^ w15));
- Round(a, b, c, d, e, f2(b, c, d), k2, w14 = left(w14 ^ w11 ^ w6 ^ w0 ));
- Round(e, a, b, c, d, f2(a, b, c), k2, w15 = left(w15 ^ w12 ^ w7 ^ w1 ));
-
- Round(d, e, a, b, c, f2(e, a, b), k2, w0 = left(w0 ^ w13 ^ w8 ^ w2 ));
- Round(c, d, e, a, b, f2(d, e, a), k2, w1 = left(w1 ^ w14 ^ w9 ^ w3 ));
- Round(b, c, d, e, a, f2(c, d, e), k2, w2 = left(w2 ^ w15 ^ w10 ^ w4 ));
- Round(a, b, c, d, e, f2(b, c, d), k2, w3 = left(w3 ^ w0 ^ w11 ^ w5 ));
- Round(e, a, b, c, d, f2(a, b, c), k2, w4 = left(w4 ^ w1 ^ w12 ^ w6 ));
- Round(d, e, a, b, c, f2(e, a, b), k2, w5 = left(w5 ^ w2 ^ w13 ^ w7 ));
- Round(c, d, e, a, b, f2(d, e, a), k2, w6 = left(w6 ^ w3 ^ w14 ^ w8 ));
- Round(b, c, d, e, a, f2(c, d, e), k2, w7 = left(w7 ^ w4 ^ w15 ^ w9 ));
- Round(a, b, c, d, e, f3(b, c, d), k3, w8 = left(w8 ^ w5 ^ w0 ^ w10));
- Round(e, a, b, c, d, f3(a, b, c), k3, w9 = left(w9 ^ w6 ^ w1 ^ w11));
- Round(d, e, a, b, c, f3(e, a, b), k3, w10 = left(w10 ^ w7 ^ w2 ^ w12));
- Round(c, d, e, a, b, f3(d, e, a), k3, w11 = left(w11 ^ w8 ^ w3 ^ w13));
- Round(b, c, d, e, a, f3(c, d, e), k3, w12 = left(w12 ^ w9 ^ w4 ^ w14));
- Round(a, b, c, d, e, f3(b, c, d), k3, w13 = left(w13 ^ w10 ^ w5 ^ w15));
- Round(e, a, b, c, d, f3(a, b, c), k3, w14 = left(w14 ^ w11 ^ w6 ^ w0 ));
- Round(d, e, a, b, c, f3(e, a, b), k3, w15 = left(w15 ^ w12 ^ w7 ^ w1 ));
-
- Round(c, d, e, a, b, f3(d, e, a), k3, w0 = left(w0 ^ w13 ^ w8 ^ w2 ));
- Round(b, c, d, e, a, f3(c, d, e), k3, w1 = left(w1 ^ w14 ^ w9 ^ w3 ));
- Round(a, b, c, d, e, f3(b, c, d), k3, w2 = left(w2 ^ w15 ^ w10 ^ w4 ));
- Round(e, a, b, c, d, f3(a, b, c), k3, w3 = left(w3 ^ w0 ^ w11 ^ w5 ));
- Round(d, e, a, b, c, f3(e, a, b), k3, w4 = left(w4 ^ w1 ^ w12 ^ w6 ));
- Round(c, d, e, a, b, f3(d, e, a), k3, w5 = left(w5 ^ w2 ^ w13 ^ w7 ));
- Round(b, c, d, e, a, f3(c, d, e), k3, w6 = left(w6 ^ w3 ^ w14 ^ w8 ));
- Round(a, b, c, d, e, f3(b, c, d), k3, w7 = left(w7 ^ w4 ^ w15 ^ w9 ));
- Round(e, a, b, c, d, f3(a, b, c), k3, w8 = left(w8 ^ w5 ^ w0 ^ w10));
- Round(d, e, a, b, c, f3(e, a, b), k3, w9 = left(w9 ^ w6 ^ w1 ^ w11));
- Round(c, d, e, a, b, f3(d, e, a), k3, w10 = left(w10 ^ w7 ^ w2 ^ w12));
- Round(b, c, d, e, a, f3(c, d, e), k3, w11 = left(w11 ^ w8 ^ w3 ^ w13));
- Round(a, b, c, d, e, f2(b, c, d), k4, w12 = left(w12 ^ w9 ^ w4 ^ w14));
- Round(e, a, b, c, d, f2(a, b, c), k4, w13 = left(w13 ^ w10 ^ w5 ^ w15));
- Round(d, e, a, b, c, f2(e, a, b), k4, w14 = left(w14 ^ w11 ^ w6 ^ w0 ));
- Round(c, d, e, a, b, f2(d, e, a), k4, w15 = left(w15 ^ w12 ^ w7 ^ w1 ));
-
- Round(b, c, d, e, a, f2(c, d, e), k4, w0 = left(w0 ^ w13 ^ w8 ^ w2 ));
- Round(a, b, c, d, e, f2(b, c, d), k4, w1 = left(w1 ^ w14 ^ w9 ^ w3 ));
- Round(e, a, b, c, d, f2(a, b, c), k4, w2 = left(w2 ^ w15 ^ w10 ^ w4 ));
- Round(d, e, a, b, c, f2(e, a, b), k4, w3 = left(w3 ^ w0 ^ w11 ^ w5 ));
- Round(c, d, e, a, b, f2(d, e, a), k4, w4 = left(w4 ^ w1 ^ w12 ^ w6 ));
- Round(b, c, d, e, a, f2(c, d, e), k4, w5 = left(w5 ^ w2 ^ w13 ^ w7 ));
- Round(a, b, c, d, e, f2(b, c, d), k4, w6 = left(w6 ^ w3 ^ w14 ^ w8 ));
- Round(e, a, b, c, d, f2(a, b, c), k4, w7 = left(w7 ^ w4 ^ w15 ^ w9 ));
- Round(d, e, a, b, c, f2(e, a, b), k4, w8 = left(w8 ^ w5 ^ w0 ^ w10));
- Round(c, d, e, a, b, f2(d, e, a), k4, w9 = left(w9 ^ w6 ^ w1 ^ w11));
- Round(b, c, d, e, a, f2(c, d, e), k4, w10 = left(w10 ^ w7 ^ w2 ^ w12));
- Round(a, b, c, d, e, f2(b, c, d), k4, w11 = left(w11 ^ w8 ^ w3 ^ w13));
- Round(e, a, b, c, d, f2(a, b, c), k4, w12 = left(w12 ^ w9 ^ w4 ^ w14));
- Round(d, e, a, b, c, f2(e, a, b), k4, left(w13 ^ w10 ^ w5 ^ w15));
- Round(c, d, e, a, b, f2(d, e, a), k4, left(w14 ^ w11 ^ w6 ^ w0 ));
- Round(b, c, d, e, a, f2(c, d, e), k4, left(w15 ^ w12 ^ w7 ^ w1 ));
+ Round(e, a, b, c, d, f1(a, b, c), k1, w0 = left(w0 ^ w13 ^ w8 ^ w2));
+ Round(d, e, a, b, c, f1(e, a, b), k1, w1 = left(w1 ^ w14 ^ w9 ^ w3));
+ Round(c, d, e, a, b, f1(d, e, a), k1, w2 = left(w2 ^ w15 ^ w10 ^ w4));
+ Round(b, c, d, e, a, f1(c, d, e), k1, w3 = left(w3 ^ w0 ^ w11 ^ w5));
+ Round(a, b, c, d, e, f2(b, c, d), k2, w4 = left(w4 ^ w1 ^ w12 ^ w6));
+ Round(e, a, b, c, d, f2(a, b, c), k2, w5 = left(w5 ^ w2 ^ w13 ^ w7));
+ Round(d, e, a, b, c, f2(e, a, b), k2, w6 = left(w6 ^ w3 ^ w14 ^ w8));
+ Round(c, d, e, a, b, f2(d, e, a), k2, w7 = left(w7 ^ w4 ^ w15 ^ w9));
+ Round(b, c, d, e, a, f2(c, d, e), k2, w8 = left(w8 ^ w5 ^ w0 ^ w10));
+ Round(a, b, c, d, e, f2(b, c, d), k2, w9 = left(w9 ^ w6 ^ w1 ^ w11));
+ Round(e, a, b, c, d, f2(a, b, c), k2, w10 = left(w10 ^ w7 ^ w2 ^ w12));
+ Round(d, e, a, b, c, f2(e, a, b), k2, w11 = left(w11 ^ w8 ^ w3 ^ w13));
+ Round(c, d, e, a, b, f2(d, e, a), k2, w12 = left(w12 ^ w9 ^ w4 ^ w14));
+ Round(b, c, d, e, a, f2(c, d, e), k2, w13 = left(w13 ^ w10 ^ w5 ^ w15));
+ Round(a, b, c, d, e, f2(b, c, d), k2, w14 = left(w14 ^ w11 ^ w6 ^ w0));
+ Round(e, a, b, c, d, f2(a, b, c), k2, w15 = left(w15 ^ w12 ^ w7 ^ w1));
+
+ Round(d, e, a, b, c, f2(e, a, b), k2, w0 = left(w0 ^ w13 ^ w8 ^ w2));
+ Round(c, d, e, a, b, f2(d, e, a), k2, w1 = left(w1 ^ w14 ^ w9 ^ w3));
+ Round(b, c, d, e, a, f2(c, d, e), k2, w2 = left(w2 ^ w15 ^ w10 ^ w4));
+ Round(a, b, c, d, e, f2(b, c, d), k2, w3 = left(w3 ^ w0 ^ w11 ^ w5));
+ Round(e, a, b, c, d, f2(a, b, c), k2, w4 = left(w4 ^ w1 ^ w12 ^ w6));
+ Round(d, e, a, b, c, f2(e, a, b), k2, w5 = left(w5 ^ w2 ^ w13 ^ w7));
+ Round(c, d, e, a, b, f2(d, e, a), k2, w6 = left(w6 ^ w3 ^ w14 ^ w8));
+ Round(b, c, d, e, a, f2(c, d, e), k2, w7 = left(w7 ^ w4 ^ w15 ^ w9));
+ Round(a, b, c, d, e, f3(b, c, d), k3, w8 = left(w8 ^ w5 ^ w0 ^ w10));
+ Round(e, a, b, c, d, f3(a, b, c), k3, w9 = left(w9 ^ w6 ^ w1 ^ w11));
+ Round(d, e, a, b, c, f3(e, a, b), k3, w10 = left(w10 ^ w7 ^ w2 ^ w12));
+ Round(c, d, e, a, b, f3(d, e, a), k3, w11 = left(w11 ^ w8 ^ w3 ^ w13));
+ Round(b, c, d, e, a, f3(c, d, e), k3, w12 = left(w12 ^ w9 ^ w4 ^ w14));
+ Round(a, b, c, d, e, f3(b, c, d), k3, w13 = left(w13 ^ w10 ^ w5 ^ w15));
+ Round(e, a, b, c, d, f3(a, b, c), k3, w14 = left(w14 ^ w11 ^ w6 ^ w0));
+ Round(d, e, a, b, c, f3(e, a, b), k3, w15 = left(w15 ^ w12 ^ w7 ^ w1));
+
+ Round(c, d, e, a, b, f3(d, e, a), k3, w0 = left(w0 ^ w13 ^ w8 ^ w2));
+ Round(b, c, d, e, a, f3(c, d, e), k3, w1 = left(w1 ^ w14 ^ w9 ^ w3));
+ Round(a, b, c, d, e, f3(b, c, d), k3, w2 = left(w2 ^ w15 ^ w10 ^ w4));
+ Round(e, a, b, c, d, f3(a, b, c), k3, w3 = left(w3 ^ w0 ^ w11 ^ w5));
+ Round(d, e, a, b, c, f3(e, a, b), k3, w4 = left(w4 ^ w1 ^ w12 ^ w6));
+ Round(c, d, e, a, b, f3(d, e, a), k3, w5 = left(w5 ^ w2 ^ w13 ^ w7));
+ Round(b, c, d, e, a, f3(c, d, e), k3, w6 = left(w6 ^ w3 ^ w14 ^ w8));
+ Round(a, b, c, d, e, f3(b, c, d), k3, w7 = left(w7 ^ w4 ^ w15 ^ w9));
+ Round(e, a, b, c, d, f3(a, b, c), k3, w8 = left(w8 ^ w5 ^ w0 ^ w10));
+ Round(d, e, a, b, c, f3(e, a, b), k3, w9 = left(w9 ^ w6 ^ w1 ^ w11));
+ Round(c, d, e, a, b, f3(d, e, a), k3, w10 = left(w10 ^ w7 ^ w2 ^ w12));
+ Round(b, c, d, e, a, f3(c, d, e), k3, w11 = left(w11 ^ w8 ^ w3 ^ w13));
+ Round(a, b, c, d, e, f2(b, c, d), k4, w12 = left(w12 ^ w9 ^ w4 ^ w14));
+ Round(e, a, b, c, d, f2(a, b, c), k4, w13 = left(w13 ^ w10 ^ w5 ^ w15));
+ Round(d, e, a, b, c, f2(e, a, b), k4, w14 = left(w14 ^ w11 ^ w6 ^ w0));
+ Round(c, d, e, a, b, f2(d, e, a), k4, w15 = left(w15 ^ w12 ^ w7 ^ w1));
+
+ Round(b, c, d, e, a, f2(c, d, e), k4, w0 = left(w0 ^ w13 ^ w8 ^ w2));
+ Round(a, b, c, d, e, f2(b, c, d), k4, w1 = left(w1 ^ w14 ^ w9 ^ w3));
+ Round(e, a, b, c, d, f2(a, b, c), k4, w2 = left(w2 ^ w15 ^ w10 ^ w4));
+ Round(d, e, a, b, c, f2(e, a, b), k4, w3 = left(w3 ^ w0 ^ w11 ^ w5));
+ Round(c, d, e, a, b, f2(d, e, a), k4, w4 = left(w4 ^ w1 ^ w12 ^ w6));
+ Round(b, c, d, e, a, f2(c, d, e), k4, w5 = left(w5 ^ w2 ^ w13 ^ w7));
+ Round(a, b, c, d, e, f2(b, c, d), k4, w6 = left(w6 ^ w3 ^ w14 ^ w8));
+ Round(e, a, b, c, d, f2(a, b, c), k4, w7 = left(w7 ^ w4 ^ w15 ^ w9));
+ Round(d, e, a, b, c, f2(e, a, b), k4, w8 = left(w8 ^ w5 ^ w0 ^ w10));
+ Round(c, d, e, a, b, f2(d, e, a), k4, w9 = left(w9 ^ w6 ^ w1 ^ w11));
+ Round(b, c, d, e, a, f2(c, d, e), k4, w10 = left(w10 ^ w7 ^ w2 ^ w12));
+ Round(a, b, c, d, e, f2(b, c, d), k4, w11 = left(w11 ^ w8 ^ w3 ^ w13));
+ Round(e, a, b, c, d, f2(a, b, c), k4, w12 = left(w12 ^ w9 ^ w4 ^ w14));
+ Round(d, e, a, b, c, f2(e, a, b), k4, left(w13 ^ w10 ^ w5 ^ w15));
+ Round(c, d, e, a, b, f2(d, e, a), k4, left(w14 ^ w11 ^ w6 ^ w0));
+ Round(b, c, d, e, a, f2(c, d, e), k4, left(w15 ^ w12 ^ w7 ^ w1));
s[0] += a;
s[1] += b;
@@ -137,18 +140,20 @@ void Transform(uint32_t *s, const unsigned char *chunk) {
s[4] += e;
}
-} // namespace sha1
+} // namespace sha1
-} // namespace
+} // namespace
////// SHA1
-CSHA1::CSHA1() : bytes(0) {
+CSHA1::CSHA1() : bytes(0)
+{
sha1::Initialize(s);
}
-CSHA1& CSHA1::Write(const unsigned char *data, size_t len) {
- const unsigned char *end = data + len;
+CSHA1& CSHA1::Write(const unsigned char* data, size_t len)
+{
+ const unsigned char* end = data + len;
size_t bufsize = bytes % 64;
if (bufsize && bufsize + len >= 64) {
// Fill the buffer, and process it.
@@ -172,20 +177,22 @@ CSHA1& CSHA1::Write(const unsigned char *data, size_t len) {
return *this;
}
-void CSHA1::Finalize(unsigned char hash[OUTPUT_SIZE]) {
+void CSHA1::Finalize(unsigned char hash[OUTPUT_SIZE])
+{
static const unsigned char pad[64] = {0x80};
unsigned char sizedesc[8];
WriteBE64(sizedesc, bytes << 3);
Write(pad, 1 + ((119 - (bytes % 64)) % 64));
Write(sizedesc, 8);
WriteBE32(hash, s[0]);
- WriteBE32(hash+4, s[1]);
- WriteBE32(hash+8, s[2]);
- WriteBE32(hash+12, s[3]);
- WriteBE32(hash+16, s[4]);
+ WriteBE32(hash + 4, s[1]);
+ WriteBE32(hash + 8, s[2]);
+ WriteBE32(hash + 12, s[3]);
+ WriteBE32(hash + 16, s[4]);
}
-CSHA1& CSHA1::Reset() {
+CSHA1& CSHA1::Reset()
+{
bytes = 0;
sha1::Initialize(s);
return *this;
diff --git a/src/crypto/sha1.h b/src/crypto/sha1.h
index b16f2c88ce..4fa2b333ba 100644
--- a/src/crypto/sha1.h
+++ b/src/crypto/sha1.h
@@ -9,7 +9,8 @@
#include <stdlib.h>
/** A hasher class for SHA1. */
-class CSHA1 {
+class CSHA1
+{
private:
uint32_t s[5];
unsigned char buf[64];
@@ -19,7 +20,7 @@ public:
static const size_t OUTPUT_SIZE = 20;
CSHA1();
- CSHA1& Write(const unsigned char *data, size_t len);
+ CSHA1& Write(const unsigned char* data, size_t len);
void Finalize(unsigned char hash[OUTPUT_SIZE]);
CSHA1& Reset();
};
diff --git a/src/crypto/sha2.cpp b/src/crypto/sha2.cpp
index 99a251cb12..9a96c5125a 100644
--- a/src/crypto/sha2.cpp
+++ b/src/crypto/sha2.cpp
@@ -5,14 +5,15 @@
#include "crypto/sha2.h"
#include "crypto/common.h"
+
#include <string.h>
// Internal implementation code.
-namespace {
-
+namespace
+{
/// Internal SHA-256 implementation.
-namespace sha256 {
-
+namespace sha256
+{
uint32_t inline Ch(uint32_t x, uint32_t y, uint32_t z) { return z ^ (x & (y ^ z)); }
uint32_t inline Maj(uint32_t x, uint32_t y, uint32_t z) { return (x & y) | (z & (x | y)); }
uint32_t inline Sigma0(uint32_t x) { return (x >> 2 | x << 30) ^ (x >> 13 | x << 19) ^ (x >> 22 | x << 10); }
@@ -21,9 +22,8 @@ uint32_t inline sigma0(uint32_t x) { return (x >> 7 | x << 25) ^ (x >> 18 | x <<
uint32_t inline sigma1(uint32_t x) { return (x >> 17 | x << 15) ^ (x >> 19 | x << 13) ^ (x >> 10); }
/** One round of SHA-256. */
-void inline Round(uint32_t a, uint32_t b, uint32_t c, uint32_t &d,
- uint32_t e, uint32_t f, uint32_t g, uint32_t &h,
- uint32_t k, uint32_t w) {
+void inline Round(uint32_t a, uint32_t b, uint32_t c, uint32_t& d, uint32_t e, uint32_t f, uint32_t g, uint32_t& h, uint32_t k, uint32_t w)
+{
uint32_t t1 = h + Sigma1(e) + Ch(e, f, g) + k + w;
uint32_t t2 = Sigma0(a) + Maj(a, b, c);
d += t1;
@@ -31,7 +31,8 @@ void inline Round(uint32_t a, uint32_t b, uint32_t c, uint32_t &d,
}
/** Initialize SHA-256 state. */
-void inline Initialize(uint32_t *s) {
+void inline Initialize(uint32_t* s)
+{
s[0] = 0x6a09e667ul;
s[1] = 0xbb67ae85ul;
s[2] = 0x3c6ef372ul;
@@ -43,20 +44,21 @@ void inline Initialize(uint32_t *s) {
}
/** Perform one SHA-256 transformation, processing a 64-byte chunk. */
-void Transform(uint32_t *s, const unsigned char *chunk) {
+void Transform(uint32_t* s, const unsigned char* chunk)
+{
uint32_t a = s[0], b = s[1], c = s[2], d = s[3], e = s[4], f = s[5], g = s[6], h = s[7];
uint32_t w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15;
- Round(a, b, c, d, e, f, g, h, 0x428a2f98, w0 = ReadBE32(chunk + 0));
- Round(h, a, b, c, d, e, f, g, 0x71374491, w1 = ReadBE32(chunk + 4));
- Round(g, h, a, b, c, d, e, f, 0xb5c0fbcf, w2 = ReadBE32(chunk + 8));
- Round(f, g, h, a, b, c, d, e, 0xe9b5dba5, w3 = ReadBE32(chunk + 12));
- Round(e, f, g, h, a, b, c, d, 0x3956c25b, w4 = ReadBE32(chunk + 16));
- Round(d, e, f, g, h, a, b, c, 0x59f111f1, w5 = ReadBE32(chunk + 20));
- Round(c, d, e, f, g, h, a, b, 0x923f82a4, w6 = ReadBE32(chunk + 24));
- Round(b, c, d, e, f, g, h, a, 0xab1c5ed5, w7 = ReadBE32(chunk + 28));
- Round(a, b, c, d, e, f, g, h, 0xd807aa98, w8 = ReadBE32(chunk + 32));
- Round(h, a, b, c, d, e, f, g, 0x12835b01, w9 = ReadBE32(chunk + 36));
+ Round(a, b, c, d, e, f, g, h, 0x428a2f98, w0 = ReadBE32(chunk + 0));
+ Round(h, a, b, c, d, e, f, g, 0x71374491, w1 = ReadBE32(chunk + 4));
+ Round(g, h, a, b, c, d, e, f, 0xb5c0fbcf, w2 = ReadBE32(chunk + 8));
+ Round(f, g, h, a, b, c, d, e, 0xe9b5dba5, w3 = ReadBE32(chunk + 12));
+ Round(e, f, g, h, a, b, c, d, 0x3956c25b, w4 = ReadBE32(chunk + 16));
+ Round(d, e, f, g, h, a, b, c, 0x59f111f1, w5 = ReadBE32(chunk + 20));
+ Round(c, d, e, f, g, h, a, b, 0x923f82a4, w6 = ReadBE32(chunk + 24));
+ Round(b, c, d, e, f, g, h, a, 0xab1c5ed5, w7 = ReadBE32(chunk + 28));
+ Round(a, b, c, d, e, f, g, h, 0xd807aa98, w8 = ReadBE32(chunk + 32));
+ Round(h, a, b, c, d, e, f, g, 0x12835b01, w9 = ReadBE32(chunk + 36));
Round(g, h, a, b, c, d, e, f, 0x243185be, w10 = ReadBE32(chunk + 40));
Round(f, g, h, a, b, c, d, e, 0x550c7dc3, w11 = ReadBE32(chunk + 44));
Round(e, f, g, h, a, b, c, d, 0x72be5d74, w12 = ReadBE32(chunk + 48));
@@ -64,56 +66,56 @@ void Transform(uint32_t *s, const unsigned char *chunk) {
Round(c, d, e, f, g, h, a, b, 0x9bdc06a7, w14 = ReadBE32(chunk + 56));
Round(b, c, d, e, f, g, h, a, 0xc19bf174, w15 = ReadBE32(chunk + 60));
- Round(a, b, c, d, e, f, g, h, 0xe49b69c1, w0 += sigma1(w14) + w9 + sigma0( w1));
- Round(h, a, b, c, d, e, f, g, 0xefbe4786, w1 += sigma1(w15) + w10 + sigma0( w2));
- Round(g, h, a, b, c, d, e, f, 0x0fc19dc6, w2 += sigma1( w0) + w11 + sigma0( w3));
- Round(f, g, h, a, b, c, d, e, 0x240ca1cc, w3 += sigma1( w1) + w12 + sigma0( w4));
- Round(e, f, g, h, a, b, c, d, 0x2de92c6f, w4 += sigma1( w2) + w13 + sigma0( w5));
- Round(d, e, f, g, h, a, b, c, 0x4a7484aa, w5 += sigma1( w3) + w14 + sigma0( w6));
- Round(c, d, e, f, g, h, a, b, 0x5cb0a9dc, w6 += sigma1( w4) + w15 + sigma0( w7));
- Round(b, c, d, e, f, g, h, a, 0x76f988da, w7 += sigma1( w5) + w0 + sigma0( w8));
- Round(a, b, c, d, e, f, g, h, 0x983e5152, w8 += sigma1( w6) + w1 + sigma0( w9));
- Round(h, a, b, c, d, e, f, g, 0xa831c66d, w9 += sigma1( w7) + w2 + sigma0(w10));
- Round(g, h, a, b, c, d, e, f, 0xb00327c8, w10 += sigma1( w8) + w3 + sigma0(w11));
- Round(f, g, h, a, b, c, d, e, 0xbf597fc7, w11 += sigma1( w9) + w4 + sigma0(w12));
- Round(e, f, g, h, a, b, c, d, 0xc6e00bf3, w12 += sigma1(w10) + w5 + sigma0(w13));
- Round(d, e, f, g, h, a, b, c, 0xd5a79147, w13 += sigma1(w11) + w6 + sigma0(w14));
- Round(c, d, e, f, g, h, a, b, 0x06ca6351, w14 += sigma1(w12) + w7 + sigma0(w15));
- Round(b, c, d, e, f, g, h, a, 0x14292967, w15 += sigma1(w13) + w8 + sigma0( w0));
-
- Round(a, b, c, d, e, f, g, h, 0x27b70a85, w0 += sigma1(w14) + w9 + sigma0( w1));
- Round(h, a, b, c, d, e, f, g, 0x2e1b2138, w1 += sigma1(w15) + w10 + sigma0( w2));
- Round(g, h, a, b, c, d, e, f, 0x4d2c6dfc, w2 += sigma1( w0) + w11 + sigma0( w3));
- Round(f, g, h, a, b, c, d, e, 0x53380d13, w3 += sigma1( w1) + w12 + sigma0( w4));
- Round(e, f, g, h, a, b, c, d, 0x650a7354, w4 += sigma1( w2) + w13 + sigma0( w5));
- Round(d, e, f, g, h, a, b, c, 0x766a0abb, w5 += sigma1( w3) + w14 + sigma0( w6));
- Round(c, d, e, f, g, h, a, b, 0x81c2c92e, w6 += sigma1( w4) + w15 + sigma0( w7));
- Round(b, c, d, e, f, g, h, a, 0x92722c85, w7 += sigma1( w5) + w0 + sigma0( w8));
- Round(a, b, c, d, e, f, g, h, 0xa2bfe8a1, w8 += sigma1( w6) + w1 + sigma0( w9));
- Round(h, a, b, c, d, e, f, g, 0xa81a664b, w9 += sigma1( w7) + w2 + sigma0(w10));
- Round(g, h, a, b, c, d, e, f, 0xc24b8b70, w10 += sigma1( w8) + w3 + sigma0(w11));
- Round(f, g, h, a, b, c, d, e, 0xc76c51a3, w11 += sigma1( w9) + w4 + sigma0(w12));
- Round(e, f, g, h, a, b, c, d, 0xd192e819, w12 += sigma1(w10) + w5 + sigma0(w13));
- Round(d, e, f, g, h, a, b, c, 0xd6990624, w13 += sigma1(w11) + w6 + sigma0(w14));
- Round(c, d, e, f, g, h, a, b, 0xf40e3585, w14 += sigma1(w12) + w7 + sigma0(w15));
- Round(b, c, d, e, f, g, h, a, 0x106aa070, w15 += sigma1(w13) + w8 + sigma0( w0));
-
- Round(a, b, c, d, e, f, g, h, 0x19a4c116, w0 += sigma1(w14) + w9 + sigma0( w1));
- Round(h, a, b, c, d, e, f, g, 0x1e376c08, w1 += sigma1(w15) + w10 + sigma0( w2));
- Round(g, h, a, b, c, d, e, f, 0x2748774c, w2 += sigma1( w0) + w11 + sigma0( w3));
- Round(f, g, h, a, b, c, d, e, 0x34b0bcb5, w3 += sigma1( w1) + w12 + sigma0( w4));
- Round(e, f, g, h, a, b, c, d, 0x391c0cb3, w4 += sigma1( w2) + w13 + sigma0( w5));
- Round(d, e, f, g, h, a, b, c, 0x4ed8aa4a, w5 += sigma1( w3) + w14 + sigma0( w6));
- Round(c, d, e, f, g, h, a, b, 0x5b9cca4f, w6 += sigma1( w4) + w15 + sigma0( w7));
- Round(b, c, d, e, f, g, h, a, 0x682e6ff3, w7 += sigma1( w5) + w0 + sigma0( w8));
- Round(a, b, c, d, e, f, g, h, 0x748f82ee, w8 += sigma1( w6) + w1 + sigma0( w9));
- Round(h, a, b, c, d, e, f, g, 0x78a5636f, w9 += sigma1( w7) + w2 + sigma0(w10));
- Round(g, h, a, b, c, d, e, f, 0x84c87814, w10 += sigma1( w8) + w3 + sigma0(w11));
- Round(f, g, h, a, b, c, d, e, 0x8cc70208, w11 += sigma1( w9) + w4 + sigma0(w12));
- Round(e, f, g, h, a, b, c, d, 0x90befffa, w12 += sigma1(w10) + w5 + sigma0(w13));
- Round(d, e, f, g, h, a, b, c, 0xa4506ceb, w13 += sigma1(w11) + w6 + sigma0(w14));
- Round(c, d, e, f, g, h, a, b, 0xbef9a3f7, w14 + sigma1(w12) + w7 + sigma0(w15));
- Round(b, c, d, e, f, g, h, a, 0xc67178f2, w15 + sigma1(w13) + w8 + sigma0( w0));
+ Round(a, b, c, d, e, f, g, h, 0xe49b69c1, w0 += sigma1(w14) + w9 + sigma0(w1));
+ Round(h, a, b, c, d, e, f, g, 0xefbe4786, w1 += sigma1(w15) + w10 + sigma0(w2));
+ Round(g, h, a, b, c, d, e, f, 0x0fc19dc6, w2 += sigma1(w0) + w11 + sigma0(w3));
+ Round(f, g, h, a, b, c, d, e, 0x240ca1cc, w3 += sigma1(w1) + w12 + sigma0(w4));
+ Round(e, f, g, h, a, b, c, d, 0x2de92c6f, w4 += sigma1(w2) + w13 + sigma0(w5));
+ Round(d, e, f, g, h, a, b, c, 0x4a7484aa, w5 += sigma1(w3) + w14 + sigma0(w6));
+ Round(c, d, e, f, g, h, a, b, 0x5cb0a9dc, w6 += sigma1(w4) + w15 + sigma0(w7));
+ Round(b, c, d, e, f, g, h, a, 0x76f988da, w7 += sigma1(w5) + w0 + sigma0(w8));
+ Round(a, b, c, d, e, f, g, h, 0x983e5152, w8 += sigma1(w6) + w1 + sigma0(w9));
+ Round(h, a, b, c, d, e, f, g, 0xa831c66d, w9 += sigma1(w7) + w2 + sigma0(w10));
+ Round(g, h, a, b, c, d, e, f, 0xb00327c8, w10 += sigma1(w8) + w3 + sigma0(w11));
+ Round(f, g, h, a, b, c, d, e, 0xbf597fc7, w11 += sigma1(w9) + w4 + sigma0(w12));
+ Round(e, f, g, h, a, b, c, d, 0xc6e00bf3, w12 += sigma1(w10) + w5 + sigma0(w13));
+ Round(d, e, f, g, h, a, b, c, 0xd5a79147, w13 += sigma1(w11) + w6 + sigma0(w14));
+ Round(c, d, e, f, g, h, a, b, 0x06ca6351, w14 += sigma1(w12) + w7 + sigma0(w15));
+ Round(b, c, d, e, f, g, h, a, 0x14292967, w15 += sigma1(w13) + w8 + sigma0(w0));
+
+ Round(a, b, c, d, e, f, g, h, 0x27b70a85, w0 += sigma1(w14) + w9 + sigma0(w1));
+ Round(h, a, b, c, d, e, f, g, 0x2e1b2138, w1 += sigma1(w15) + w10 + sigma0(w2));
+ Round(g, h, a, b, c, d, e, f, 0x4d2c6dfc, w2 += sigma1(w0) + w11 + sigma0(w3));
+ Round(f, g, h, a, b, c, d, e, 0x53380d13, w3 += sigma1(w1) + w12 + sigma0(w4));
+ Round(e, f, g, h, a, b, c, d, 0x650a7354, w4 += sigma1(w2) + w13 + sigma0(w5));
+ Round(d, e, f, g, h, a, b, c, 0x766a0abb, w5 += sigma1(w3) + w14 + sigma0(w6));
+ Round(c, d, e, f, g, h, a, b, 0x81c2c92e, w6 += sigma1(w4) + w15 + sigma0(w7));
+ Round(b, c, d, e, f, g, h, a, 0x92722c85, w7 += sigma1(w5) + w0 + sigma0(w8));
+ Round(a, b, c, d, e, f, g, h, 0xa2bfe8a1, w8 += sigma1(w6) + w1 + sigma0(w9));
+ Round(h, a, b, c, d, e, f, g, 0xa81a664b, w9 += sigma1(w7) + w2 + sigma0(w10));
+ Round(g, h, a, b, c, d, e, f, 0xc24b8b70, w10 += sigma1(w8) + w3 + sigma0(w11));
+ Round(f, g, h, a, b, c, d, e, 0xc76c51a3, w11 += sigma1(w9) + w4 + sigma0(w12));
+ Round(e, f, g, h, a, b, c, d, 0xd192e819, w12 += sigma1(w10) + w5 + sigma0(w13));
+ Round(d, e, f, g, h, a, b, c, 0xd6990624, w13 += sigma1(w11) + w6 + sigma0(w14));
+ Round(c, d, e, f, g, h, a, b, 0xf40e3585, w14 += sigma1(w12) + w7 + sigma0(w15));
+ Round(b, c, d, e, f, g, h, a, 0x106aa070, w15 += sigma1(w13) + w8 + sigma0(w0));
+
+ Round(a, b, c, d, e, f, g, h, 0x19a4c116, w0 += sigma1(w14) + w9 + sigma0(w1));
+ Round(h, a, b, c, d, e, f, g, 0x1e376c08, w1 += sigma1(w15) + w10 + sigma0(w2));
+ Round(g, h, a, b, c, d, e, f, 0x2748774c, w2 += sigma1(w0) + w11 + sigma0(w3));
+ Round(f, g, h, a, b, c, d, e, 0x34b0bcb5, w3 += sigma1(w1) + w12 + sigma0(w4));
+ Round(e, f, g, h, a, b, c, d, 0x391c0cb3, w4 += sigma1(w2) + w13 + sigma0(w5));
+ Round(d, e, f, g, h, a, b, c, 0x4ed8aa4a, w5 += sigma1(w3) + w14 + sigma0(w6));
+ Round(c, d, e, f, g, h, a, b, 0x5b9cca4f, w6 += sigma1(w4) + w15 + sigma0(w7));
+ Round(b, c, d, e, f, g, h, a, 0x682e6ff3, w7 += sigma1(w5) + w0 + sigma0(w8));
+ Round(a, b, c, d, e, f, g, h, 0x748f82ee, w8 += sigma1(w6) + w1 + sigma0(w9));
+ Round(h, a, b, c, d, e, f, g, 0x78a5636f, w9 += sigma1(w7) + w2 + sigma0(w10));
+ Round(g, h, a, b, c, d, e, f, 0x84c87814, w10 += sigma1(w8) + w3 + sigma0(w11));
+ Round(f, g, h, a, b, c, d, e, 0x8cc70208, w11 += sigma1(w9) + w4 + sigma0(w12));
+ Round(e, f, g, h, a, b, c, d, 0x90befffa, w12 += sigma1(w10) + w5 + sigma0(w13));
+ Round(d, e, f, g, h, a, b, c, 0xa4506ceb, w13 += sigma1(w11) + w6 + sigma0(w14));
+ Round(c, d, e, f, g, h, a, b, 0xbef9a3f7, w14 + sigma1(w12) + w7 + sigma0(w15));
+ Round(b, c, d, e, f, g, h, a, 0xc67178f2, w15 + sigma1(w13) + w8 + sigma0(w0));
s[0] += a;
s[1] += b;
@@ -125,11 +127,11 @@ void Transform(uint32_t *s, const unsigned char *chunk) {
s[7] += h;
}
-} // namespace sha256
+} // namespace sha256
/// Internal SHA-512 implementation.
-namespace sha512 {
-
+namespace sha512
+{
uint64_t inline Ch(uint64_t x, uint64_t y, uint64_t z) { return z ^ (x & (y ^ z)); }
uint64_t inline Maj(uint64_t x, uint64_t y, uint64_t z) { return (x & y) | (z & (x | y)); }
uint64_t inline Sigma0(uint64_t x) { return (x >> 28 | x << 36) ^ (x >> 34 | x << 30) ^ (x >> 39 | x << 25); }
@@ -138,9 +140,8 @@ uint64_t inline sigma0(uint64_t x) { return (x >> 1 | x << 63) ^ (x >> 8 | x <<
uint64_t inline sigma1(uint64_t x) { return (x >> 19 | x << 45) ^ (x >> 61 | x << 3) ^ (x >> 6); }
/** One round of SHA-512. */
-void inline Round(uint64_t a, uint64_t b, uint64_t c, uint64_t &d,
- uint64_t e, uint64_t f, uint64_t g, uint64_t &h,
- uint64_t k, uint64_t w) {
+void inline Round(uint64_t a, uint64_t b, uint64_t c, uint64_t& d, uint64_t e, uint64_t f, uint64_t g, uint64_t& h, uint64_t k, uint64_t w)
+{
uint64_t t1 = h + Sigma1(e) + Ch(e, f, g) + k + w;
uint64_t t2 = Sigma0(a) + Maj(a, b, c);
d += t1;
@@ -148,7 +149,8 @@ void inline Round(uint64_t a, uint64_t b, uint64_t c, uint64_t &d,
}
/** Initialize SHA-256 state. */
-void inline Initialize(uint64_t *s) {
+void inline Initialize(uint64_t* s)
+{
s[0] = 0x6a09e667f3bcc908ull;
s[1] = 0xbb67ae8584caa73bull;
s[2] = 0x3c6ef372fe94f82bull;
@@ -160,20 +162,21 @@ void inline Initialize(uint64_t *s) {
}
/** Perform one SHA-512 transformation, processing a 128-byte chunk. */
-void Transform(uint64_t *s, const unsigned char *chunk) {
+void Transform(uint64_t* s, const unsigned char* chunk)
+{
uint64_t a = s[0], b = s[1], c = s[2], d = s[3], e = s[4], f = s[5], g = s[6], h = s[7];
uint64_t w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15;
- Round(a, b, c, d, e, f, g, h, 0x428a2f98d728ae22ull, w0 = ReadBE64(chunk + 0));
- Round(h, a, b, c, d, e, f, g, 0x7137449123ef65cdull, w1 = ReadBE64(chunk + 8));
- Round(g, h, a, b, c, d, e, f, 0xb5c0fbcfec4d3b2full, w2 = ReadBE64(chunk + 16));
- Round(f, g, h, a, b, c, d, e, 0xe9b5dba58189dbbcull, w3 = ReadBE64(chunk + 24));
- Round(e, f, g, h, a, b, c, d, 0x3956c25bf348b538ull, w4 = ReadBE64(chunk + 32));
- Round(d, e, f, g, h, a, b, c, 0x59f111f1b605d019ull, w5 = ReadBE64(chunk + 40));
- Round(c, d, e, f, g, h, a, b, 0x923f82a4af194f9bull, w6 = ReadBE64(chunk + 48));
- Round(b, c, d, e, f, g, h, a, 0xab1c5ed5da6d8118ull, w7 = ReadBE64(chunk + 56));
- Round(a, b, c, d, e, f, g, h, 0xd807aa98a3030242ull, w8 = ReadBE64(chunk + 64));
- Round(h, a, b, c, d, e, f, g, 0x12835b0145706fbeull, w9 = ReadBE64(chunk + 72));
+ Round(a, b, c, d, e, f, g, h, 0x428a2f98d728ae22ull, w0 = ReadBE64(chunk + 0));
+ Round(h, a, b, c, d, e, f, g, 0x7137449123ef65cdull, w1 = ReadBE64(chunk + 8));
+ Round(g, h, a, b, c, d, e, f, 0xb5c0fbcfec4d3b2full, w2 = ReadBE64(chunk + 16));
+ Round(f, g, h, a, b, c, d, e, 0xe9b5dba58189dbbcull, w3 = ReadBE64(chunk + 24));
+ Round(e, f, g, h, a, b, c, d, 0x3956c25bf348b538ull, w4 = ReadBE64(chunk + 32));
+ Round(d, e, f, g, h, a, b, c, 0x59f111f1b605d019ull, w5 = ReadBE64(chunk + 40));
+ Round(c, d, e, f, g, h, a, b, 0x923f82a4af194f9bull, w6 = ReadBE64(chunk + 48));
+ Round(b, c, d, e, f, g, h, a, 0xab1c5ed5da6d8118ull, w7 = ReadBE64(chunk + 56));
+ Round(a, b, c, d, e, f, g, h, 0xd807aa98a3030242ull, w8 = ReadBE64(chunk + 64));
+ Round(h, a, b, c, d, e, f, g, 0x12835b0145706fbeull, w9 = ReadBE64(chunk + 72));
Round(g, h, a, b, c, d, e, f, 0x243185be4ee4b28cull, w10 = ReadBE64(chunk + 80));
Round(f, g, h, a, b, c, d, e, 0x550c7dc3d5ffb4e2ull, w11 = ReadBE64(chunk + 88));
Round(e, f, g, h, a, b, c, d, 0x72be5d74f27b896full, w12 = ReadBE64(chunk + 96));
@@ -181,73 +184,73 @@ void Transform(uint64_t *s, const unsigned char *chunk) {
Round(c, d, e, f, g, h, a, b, 0x9bdc06a725c71235ull, w14 = ReadBE64(chunk + 112));
Round(b, c, d, e, f, g, h, a, 0xc19bf174cf692694ull, w15 = ReadBE64(chunk + 120));
- Round(a, b, c, d, e, f, g, h, 0xe49b69c19ef14ad2ull, w0 += sigma1(w14) + w9 + sigma0( w1));
- Round(h, a, b, c, d, e, f, g, 0xefbe4786384f25e3ull, w1 += sigma1(w15) + w10 + sigma0( w2));
- Round(g, h, a, b, c, d, e, f, 0x0fc19dc68b8cd5b5ull, w2 += sigma1( w0) + w11 + sigma0( w3));
- Round(f, g, h, a, b, c, d, e, 0x240ca1cc77ac9c65ull, w3 += sigma1( w1) + w12 + sigma0( w4));
- Round(e, f, g, h, a, b, c, d, 0x2de92c6f592b0275ull, w4 += sigma1( w2) + w13 + sigma0( w5));
- Round(d, e, f, g, h, a, b, c, 0x4a7484aa6ea6e483ull, w5 += sigma1( w3) + w14 + sigma0( w6));
- Round(c, d, e, f, g, h, a, b, 0x5cb0a9dcbd41fbd4ull, w6 += sigma1( w4) + w15 + sigma0( w7));
- Round(b, c, d, e, f, g, h, a, 0x76f988da831153b5ull, w7 += sigma1( w5) + w0 + sigma0( w8));
- Round(a, b, c, d, e, f, g, h, 0x983e5152ee66dfabull, w8 += sigma1( w6) + w1 + sigma0( w9));
- Round(h, a, b, c, d, e, f, g, 0xa831c66d2db43210ull, w9 += sigma1( w7) + w2 + sigma0(w10));
- Round(g, h, a, b, c, d, e, f, 0xb00327c898fb213full, w10 += sigma1( w8) + w3 + sigma0(w11));
- Round(f, g, h, a, b, c, d, e, 0xbf597fc7beef0ee4ull, w11 += sigma1( w9) + w4 + sigma0(w12));
- Round(e, f, g, h, a, b, c, d, 0xc6e00bf33da88fc2ull, w12 += sigma1(w10) + w5 + sigma0(w13));
- Round(d, e, f, g, h, a, b, c, 0xd5a79147930aa725ull, w13 += sigma1(w11) + w6 + sigma0(w14));
- Round(c, d, e, f, g, h, a, b, 0x06ca6351e003826full, w14 += sigma1(w12) + w7 + sigma0(w15));
- Round(b, c, d, e, f, g, h, a, 0x142929670a0e6e70ull, w15 += sigma1(w13) + w8 + sigma0( w0));
-
- Round(a, b, c, d, e, f, g, h, 0x27b70a8546d22ffcull, w0 += sigma1(w14) + w9 + sigma0( w1));
- Round(h, a, b, c, d, e, f, g, 0x2e1b21385c26c926ull, w1 += sigma1(w15) + w10 + sigma0( w2));
- Round(g, h, a, b, c, d, e, f, 0x4d2c6dfc5ac42aedull, w2 += sigma1( w0) + w11 + sigma0( w3));
- Round(f, g, h, a, b, c, d, e, 0x53380d139d95b3dfull, w3 += sigma1( w1) + w12 + sigma0( w4));
- Round(e, f, g, h, a, b, c, d, 0x650a73548baf63deull, w4 += sigma1( w2) + w13 + sigma0( w5));
- Round(d, e, f, g, h, a, b, c, 0x766a0abb3c77b2a8ull, w5 += sigma1( w3) + w14 + sigma0( w6));
- Round(c, d, e, f, g, h, a, b, 0x81c2c92e47edaee6ull, w6 += sigma1( w4) + w15 + sigma0( w7));
- Round(b, c, d, e, f, g, h, a, 0x92722c851482353bull, w7 += sigma1( w5) + w0 + sigma0( w8));
- Round(a, b, c, d, e, f, g, h, 0xa2bfe8a14cf10364ull, w8 += sigma1( w6) + w1 + sigma0( w9));
- Round(h, a, b, c, d, e, f, g, 0xa81a664bbc423001ull, w9 += sigma1( w7) + w2 + sigma0(w10));
- Round(g, h, a, b, c, d, e, f, 0xc24b8b70d0f89791ull, w10 += sigma1( w8) + w3 + sigma0(w11));
- Round(f, g, h, a, b, c, d, e, 0xc76c51a30654be30ull, w11 += sigma1( w9) + w4 + sigma0(w12));
- Round(e, f, g, h, a, b, c, d, 0xd192e819d6ef5218ull, w12 += sigma1(w10) + w5 + sigma0(w13));
- Round(d, e, f, g, h, a, b, c, 0xd69906245565a910ull, w13 += sigma1(w11) + w6 + sigma0(w14));
- Round(c, d, e, f, g, h, a, b, 0xf40e35855771202aull, w14 += sigma1(w12) + w7 + sigma0(w15));
- Round(b, c, d, e, f, g, h, a, 0x106aa07032bbd1b8ull, w15 += sigma1(w13) + w8 + sigma0( w0));
-
- Round(a, b, c, d, e, f, g, h, 0x19a4c116b8d2d0c8ull, w0 += sigma1(w14) + w9 + sigma0( w1));
- Round(h, a, b, c, d, e, f, g, 0x1e376c085141ab53ull, w1 += sigma1(w15) + w10 + sigma0( w2));
- Round(g, h, a, b, c, d, e, f, 0x2748774cdf8eeb99ull, w2 += sigma1( w0) + w11 + sigma0( w3));
- Round(f, g, h, a, b, c, d, e, 0x34b0bcb5e19b48a8ull, w3 += sigma1( w1) + w12 + sigma0( w4));
- Round(e, f, g, h, a, b, c, d, 0x391c0cb3c5c95a63ull, w4 += sigma1( w2) + w13 + sigma0( w5));
- Round(d, e, f, g, h, a, b, c, 0x4ed8aa4ae3418acbull, w5 += sigma1( w3) + w14 + sigma0( w6));
- Round(c, d, e, f, g, h, a, b, 0x5b9cca4f7763e373ull, w6 += sigma1( w4) + w15 + sigma0( w7));
- Round(b, c, d, e, f, g, h, a, 0x682e6ff3d6b2b8a3ull, w7 += sigma1( w5) + w0 + sigma0( w8));
- Round(a, b, c, d, e, f, g, h, 0x748f82ee5defb2fcull, w8 += sigma1( w6) + w1 + sigma0( w9));
- Round(h, a, b, c, d, e, f, g, 0x78a5636f43172f60ull, w9 += sigma1( w7) + w2 + sigma0(w10));
- Round(g, h, a, b, c, d, e, f, 0x84c87814a1f0ab72ull, w10 += sigma1( w8) + w3 + sigma0(w11));
- Round(f, g, h, a, b, c, d, e, 0x8cc702081a6439ecull, w11 += sigma1( w9) + w4 + sigma0(w12));
- Round(e, f, g, h, a, b, c, d, 0x90befffa23631e28ull, w12 += sigma1(w10) + w5 + sigma0(w13));
- Round(d, e, f, g, h, a, b, c, 0xa4506cebde82bde9ull, w13 += sigma1(w11) + w6 + sigma0(w14));
- Round(c, d, e, f, g, h, a, b, 0xbef9a3f7b2c67915ull, w14 += sigma1(w12) + w7 + sigma0(w15));
- Round(b, c, d, e, f, g, h, a, 0xc67178f2e372532bull, w15 += sigma1(w13) + w8 + sigma0( w0));
-
- Round(a, b, c, d, e, f, g, h, 0xca273eceea26619cull, w0 += sigma1(w14) + w9 + sigma0( w1));
- Round(h, a, b, c, d, e, f, g, 0xd186b8c721c0c207ull, w1 += sigma1(w15) + w10 + sigma0( w2));
- Round(g, h, a, b, c, d, e, f, 0xeada7dd6cde0eb1eull, w2 += sigma1( w0) + w11 + sigma0( w3));
- Round(f, g, h, a, b, c, d, e, 0xf57d4f7fee6ed178ull, w3 += sigma1( w1) + w12 + sigma0( w4));
- Round(e, f, g, h, a, b, c, d, 0x06f067aa72176fbaull, w4 += sigma1( w2) + w13 + sigma0( w5));
- Round(d, e, f, g, h, a, b, c, 0x0a637dc5a2c898a6ull, w5 += sigma1( w3) + w14 + sigma0( w6));
- Round(c, d, e, f, g, h, a, b, 0x113f9804bef90daeull, w6 += sigma1( w4) + w15 + sigma0( w7));
- Round(b, c, d, e, f, g, h, a, 0x1b710b35131c471bull, w7 += sigma1( w5) + w0 + sigma0( w8));
- Round(a, b, c, d, e, f, g, h, 0x28db77f523047d84ull, w8 += sigma1( w6) + w1 + sigma0( w9));
- Round(h, a, b, c, d, e, f, g, 0x32caab7b40c72493ull, w9 += sigma1( w7) + w2 + sigma0(w10));
- Round(g, h, a, b, c, d, e, f, 0x3c9ebe0a15c9bebcull, w10 += sigma1( w8) + w3 + sigma0(w11));
- Round(f, g, h, a, b, c, d, e, 0x431d67c49c100d4cull, w11 += sigma1( w9) + w4 + sigma0(w12));
- Round(e, f, g, h, a, b, c, d, 0x4cc5d4becb3e42b6ull, w12 += sigma1(w10) + w5 + sigma0(w13));
- Round(d, e, f, g, h, a, b, c, 0x597f299cfc657e2aull, w13 += sigma1(w11) + w6 + sigma0(w14));
- Round(c, d, e, f, g, h, a, b, 0x5fcb6fab3ad6faecull, w14 += sigma1(w12) + w7 + sigma0(w15));
- Round(b, c, d, e, f, g, h, a, 0x6c44198c4a475817ull, w15 += sigma1(w13) + w8 + sigma0( w0));
+ Round(a, b, c, d, e, f, g, h, 0xe49b69c19ef14ad2ull, w0 += sigma1(w14) + w9 + sigma0(w1));
+ Round(h, a, b, c, d, e, f, g, 0xefbe4786384f25e3ull, w1 += sigma1(w15) + w10 + sigma0(w2));
+ Round(g, h, a, b, c, d, e, f, 0x0fc19dc68b8cd5b5ull, w2 += sigma1(w0) + w11 + sigma0(w3));
+ Round(f, g, h, a, b, c, d, e, 0x240ca1cc77ac9c65ull, w3 += sigma1(w1) + w12 + sigma0(w4));
+ Round(e, f, g, h, a, b, c, d, 0x2de92c6f592b0275ull, w4 += sigma1(w2) + w13 + sigma0(w5));
+ Round(d, e, f, g, h, a, b, c, 0x4a7484aa6ea6e483ull, w5 += sigma1(w3) + w14 + sigma0(w6));
+ Round(c, d, e, f, g, h, a, b, 0x5cb0a9dcbd41fbd4ull, w6 += sigma1(w4) + w15 + sigma0(w7));
+ Round(b, c, d, e, f, g, h, a, 0x76f988da831153b5ull, w7 += sigma1(w5) + w0 + sigma0(w8));
+ Round(a, b, c, d, e, f, g, h, 0x983e5152ee66dfabull, w8 += sigma1(w6) + w1 + sigma0(w9));
+ Round(h, a, b, c, d, e, f, g, 0xa831c66d2db43210ull, w9 += sigma1(w7) + w2 + sigma0(w10));
+ Round(g, h, a, b, c, d, e, f, 0xb00327c898fb213full, w10 += sigma1(w8) + w3 + sigma0(w11));
+ Round(f, g, h, a, b, c, d, e, 0xbf597fc7beef0ee4ull, w11 += sigma1(w9) + w4 + sigma0(w12));
+ Round(e, f, g, h, a, b, c, d, 0xc6e00bf33da88fc2ull, w12 += sigma1(w10) + w5 + sigma0(w13));
+ Round(d, e, f, g, h, a, b, c, 0xd5a79147930aa725ull, w13 += sigma1(w11) + w6 + sigma0(w14));
+ Round(c, d, e, f, g, h, a, b, 0x06ca6351e003826full, w14 += sigma1(w12) + w7 + sigma0(w15));
+ Round(b, c, d, e, f, g, h, a, 0x142929670a0e6e70ull, w15 += sigma1(w13) + w8 + sigma0(w0));
+
+ Round(a, b, c, d, e, f, g, h, 0x27b70a8546d22ffcull, w0 += sigma1(w14) + w9 + sigma0(w1));
+ Round(h, a, b, c, d, e, f, g, 0x2e1b21385c26c926ull, w1 += sigma1(w15) + w10 + sigma0(w2));
+ Round(g, h, a, b, c, d, e, f, 0x4d2c6dfc5ac42aedull, w2 += sigma1(w0) + w11 + sigma0(w3));
+ Round(f, g, h, a, b, c, d, e, 0x53380d139d95b3dfull, w3 += sigma1(w1) + w12 + sigma0(w4));
+ Round(e, f, g, h, a, b, c, d, 0x650a73548baf63deull, w4 += sigma1(w2) + w13 + sigma0(w5));
+ Round(d, e, f, g, h, a, b, c, 0x766a0abb3c77b2a8ull, w5 += sigma1(w3) + w14 + sigma0(w6));
+ Round(c, d, e, f, g, h, a, b, 0x81c2c92e47edaee6ull, w6 += sigma1(w4) + w15 + sigma0(w7));
+ Round(b, c, d, e, f, g, h, a, 0x92722c851482353bull, w7 += sigma1(w5) + w0 + sigma0(w8));
+ Round(a, b, c, d, e, f, g, h, 0xa2bfe8a14cf10364ull, w8 += sigma1(w6) + w1 + sigma0(w9));
+ Round(h, a, b, c, d, e, f, g, 0xa81a664bbc423001ull, w9 += sigma1(w7) + w2 + sigma0(w10));
+ Round(g, h, a, b, c, d, e, f, 0xc24b8b70d0f89791ull, w10 += sigma1(w8) + w3 + sigma0(w11));
+ Round(f, g, h, a, b, c, d, e, 0xc76c51a30654be30ull, w11 += sigma1(w9) + w4 + sigma0(w12));
+ Round(e, f, g, h, a, b, c, d, 0xd192e819d6ef5218ull, w12 += sigma1(w10) + w5 + sigma0(w13));
+ Round(d, e, f, g, h, a, b, c, 0xd69906245565a910ull, w13 += sigma1(w11) + w6 + sigma0(w14));
+ Round(c, d, e, f, g, h, a, b, 0xf40e35855771202aull, w14 += sigma1(w12) + w7 + sigma0(w15));
+ Round(b, c, d, e, f, g, h, a, 0x106aa07032bbd1b8ull, w15 += sigma1(w13) + w8 + sigma0(w0));
+
+ Round(a, b, c, d, e, f, g, h, 0x19a4c116b8d2d0c8ull, w0 += sigma1(w14) + w9 + sigma0(w1));
+ Round(h, a, b, c, d, e, f, g, 0x1e376c085141ab53ull, w1 += sigma1(w15) + w10 + sigma0(w2));
+ Round(g, h, a, b, c, d, e, f, 0x2748774cdf8eeb99ull, w2 += sigma1(w0) + w11 + sigma0(w3));
+ Round(f, g, h, a, b, c, d, e, 0x34b0bcb5e19b48a8ull, w3 += sigma1(w1) + w12 + sigma0(w4));
+ Round(e, f, g, h, a, b, c, d, 0x391c0cb3c5c95a63ull, w4 += sigma1(w2) + w13 + sigma0(w5));
+ Round(d, e, f, g, h, a, b, c, 0x4ed8aa4ae3418acbull, w5 += sigma1(w3) + w14 + sigma0(w6));
+ Round(c, d, e, f, g, h, a, b, 0x5b9cca4f7763e373ull, w6 += sigma1(w4) + w15 + sigma0(w7));
+ Round(b, c, d, e, f, g, h, a, 0x682e6ff3d6b2b8a3ull, w7 += sigma1(w5) + w0 + sigma0(w8));
+ Round(a, b, c, d, e, f, g, h, 0x748f82ee5defb2fcull, w8 += sigma1(w6) + w1 + sigma0(w9));
+ Round(h, a, b, c, d, e, f, g, 0x78a5636f43172f60ull, w9 += sigma1(w7) + w2 + sigma0(w10));
+ Round(g, h, a, b, c, d, e, f, 0x84c87814a1f0ab72ull, w10 += sigma1(w8) + w3 + sigma0(w11));
+ Round(f, g, h, a, b, c, d, e, 0x8cc702081a6439ecull, w11 += sigma1(w9) + w4 + sigma0(w12));
+ Round(e, f, g, h, a, b, c, d, 0x90befffa23631e28ull, w12 += sigma1(w10) + w5 + sigma0(w13));
+ Round(d, e, f, g, h, a, b, c, 0xa4506cebde82bde9ull, w13 += sigma1(w11) + w6 + sigma0(w14));
+ Round(c, d, e, f, g, h, a, b, 0xbef9a3f7b2c67915ull, w14 += sigma1(w12) + w7 + sigma0(w15));
+ Round(b, c, d, e, f, g, h, a, 0xc67178f2e372532bull, w15 += sigma1(w13) + w8 + sigma0(w0));
+
+ Round(a, b, c, d, e, f, g, h, 0xca273eceea26619cull, w0 += sigma1(w14) + w9 + sigma0(w1));
+ Round(h, a, b, c, d, e, f, g, 0xd186b8c721c0c207ull, w1 += sigma1(w15) + w10 + sigma0(w2));
+ Round(g, h, a, b, c, d, e, f, 0xeada7dd6cde0eb1eull, w2 += sigma1(w0) + w11 + sigma0(w3));
+ Round(f, g, h, a, b, c, d, e, 0xf57d4f7fee6ed178ull, w3 += sigma1(w1) + w12 + sigma0(w4));
+ Round(e, f, g, h, a, b, c, d, 0x06f067aa72176fbaull, w4 += sigma1(w2) + w13 + sigma0(w5));
+ Round(d, e, f, g, h, a, b, c, 0x0a637dc5a2c898a6ull, w5 += sigma1(w3) + w14 + sigma0(w6));
+ Round(c, d, e, f, g, h, a, b, 0x113f9804bef90daeull, w6 += sigma1(w4) + w15 + sigma0(w7));
+ Round(b, c, d, e, f, g, h, a, 0x1b710b35131c471bull, w7 += sigma1(w5) + w0 + sigma0(w8));
+ Round(a, b, c, d, e, f, g, h, 0x28db77f523047d84ull, w8 += sigma1(w6) + w1 + sigma0(w9));
+ Round(h, a, b, c, d, e, f, g, 0x32caab7b40c72493ull, w9 += sigma1(w7) + w2 + sigma0(w10));
+ Round(g, h, a, b, c, d, e, f, 0x3c9ebe0a15c9bebcull, w10 += sigma1(w8) + w3 + sigma0(w11));
+ Round(f, g, h, a, b, c, d, e, 0x431d67c49c100d4cull, w11 += sigma1(w9) + w4 + sigma0(w12));
+ Round(e, f, g, h, a, b, c, d, 0x4cc5d4becb3e42b6ull, w12 += sigma1(w10) + w5 + sigma0(w13));
+ Round(d, e, f, g, h, a, b, c, 0x597f299cfc657e2aull, w13 += sigma1(w11) + w6 + sigma0(w14));
+ Round(c, d, e, f, g, h, a, b, 0x5fcb6fab3ad6faecull, w14 += sigma1(w12) + w7 + sigma0(w15));
+ Round(b, c, d, e, f, g, h, a, 0x6c44198c4a475817ull, w15 += sigma1(w13) + w8 + sigma0(w0));
s[0] += a;
s[1] += b;
@@ -259,19 +262,21 @@ void Transform(uint64_t *s, const unsigned char *chunk) {
s[7] += h;
}
-} // namespace sha512
+} // namespace sha512
-} // namespace
+} // namespace
////// SHA-256
-CSHA256::CSHA256() : bytes(0) {
+CSHA256::CSHA256() : bytes(0)
+{
sha256::Initialize(s);
}
-CSHA256& CSHA256::Write(const unsigned char *data, size_t len) {
- const unsigned char *end = data + len;
+CSHA256& CSHA256::Write(const unsigned char* data, size_t len)
+{
+ const unsigned char* end = data + len;
size_t bufsize = bytes % 64;
if (bufsize && bufsize + len >= 64) {
// Fill the buffer, and process it.
@@ -295,23 +300,25 @@ CSHA256& CSHA256::Write(const unsigned char *data, size_t len) {
return *this;
}
-void CSHA256::Finalize(unsigned char hash[OUTPUT_SIZE]) {
+void CSHA256::Finalize(unsigned char hash[OUTPUT_SIZE])
+{
static const unsigned char pad[64] = {0x80};
unsigned char sizedesc[8];
WriteBE64(sizedesc, bytes << 3);
Write(pad, 1 + ((119 - (bytes % 64)) % 64));
Write(sizedesc, 8);
WriteBE32(hash, s[0]);
- WriteBE32(hash+4, s[1]);
- WriteBE32(hash+8, s[2]);
- WriteBE32(hash+12, s[3]);
- WriteBE32(hash+16, s[4]);
- WriteBE32(hash+20, s[5]);
- WriteBE32(hash+24, s[6]);
- WriteBE32(hash+28, s[7]);
+ WriteBE32(hash + 4, s[1]);
+ WriteBE32(hash + 8, s[2]);
+ WriteBE32(hash + 12, s[3]);
+ WriteBE32(hash + 16, s[4]);
+ WriteBE32(hash + 20, s[5]);
+ WriteBE32(hash + 24, s[6]);
+ WriteBE32(hash + 28, s[7]);
}
-CSHA256& CSHA256::Reset() {
+CSHA256& CSHA256::Reset()
+{
bytes = 0;
sha256::Initialize(s);
return *this;
@@ -319,12 +326,14 @@ CSHA256& CSHA256::Reset() {
////// SHA-512
-CSHA512::CSHA512() : bytes(0) {
+CSHA512::CSHA512() : bytes(0)
+{
sha512::Initialize(s);
}
-CSHA512& CSHA512::Write(const unsigned char *data, size_t len) {
- const unsigned char *end = data + len;
+CSHA512& CSHA512::Write(const unsigned char* data, size_t len)
+{
+ const unsigned char* end = data + len;
size_t bufsize = bytes % 128;
if (bufsize && bufsize + len >= 128) {
// Fill the buffer, and process it.
@@ -348,23 +357,25 @@ CSHA512& CSHA512::Write(const unsigned char *data, size_t len) {
return *this;
}
-void CSHA512::Finalize(unsigned char hash[OUTPUT_SIZE]) {
+void CSHA512::Finalize(unsigned char hash[OUTPUT_SIZE])
+{
static const unsigned char pad[128] = {0x80};
unsigned char sizedesc[16] = {0x00};
- WriteBE64(sizedesc+8, bytes << 3);
+ WriteBE64(sizedesc + 8, bytes << 3);
Write(pad, 1 + ((239 - (bytes % 128)) % 128));
Write(sizedesc, 16);
WriteBE64(hash, s[0]);
- WriteBE64(hash+8, s[1]);
- WriteBE64(hash+16, s[2]);
- WriteBE64(hash+24, s[3]);
- WriteBE64(hash+32, s[4]);
- WriteBE64(hash+40, s[5]);
- WriteBE64(hash+48, s[6]);
- WriteBE64(hash+56, s[7]);
+ WriteBE64(hash + 8, s[1]);
+ WriteBE64(hash + 16, s[2]);
+ WriteBE64(hash + 24, s[3]);
+ WriteBE64(hash + 32, s[4]);
+ WriteBE64(hash + 40, s[5]);
+ WriteBE64(hash + 48, s[6]);
+ WriteBE64(hash + 56, s[7]);
}
-CSHA512& CSHA512::Reset() {
+CSHA512& CSHA512::Reset()
+{
bytes = 0;
sha512::Initialize(s);
return *this;
@@ -372,7 +383,8 @@ CSHA512& CSHA512::Reset() {
////// HMAC-SHA-512
-CHMAC_SHA512::CHMAC_SHA512(const unsigned char *key, size_t keylen) {
+CHMAC_SHA512::CHMAC_SHA512(const unsigned char* key, size_t keylen)
+{
unsigned char rkey[128];
if (keylen <= 128) {
memcpy(rkey, key, keylen);
@@ -382,16 +394,17 @@ CHMAC_SHA512::CHMAC_SHA512(const unsigned char *key, size_t keylen) {
memset(rkey + 64, 0, 64);
}
- for (int n=0; n<128; n++)
+ for (int n = 0; n < 128; n++)
rkey[n] ^= 0x5c;
outer.Write(rkey, 128);
- for (int n=0; n<128; n++)
+ for (int n = 0; n < 128; n++)
rkey[n] ^= 0x5c ^ 0x36;
inner.Write(rkey, 128);
}
-void CHMAC_SHA512::Finalize(unsigned char hash[OUTPUT_SIZE]) {
+void CHMAC_SHA512::Finalize(unsigned char hash[OUTPUT_SIZE])
+{
unsigned char temp[64];
inner.Finalize(temp);
outer.Write(temp, 64).Finalize(hash);
diff --git a/src/crypto/sha2.h b/src/crypto/sha2.h
index 088d5e194c..15ad5ac383 100644
--- a/src/crypto/sha2.h
+++ b/src/crypto/sha2.h
@@ -9,7 +9,8 @@
#include <stdlib.h>
/** A hasher class for SHA-256. */
-class CSHA256 {
+class CSHA256
+{
private:
uint32_t s[8];
unsigned char buf[64];
@@ -19,13 +20,14 @@ public:
static const size_t OUTPUT_SIZE = 32;
CSHA256();
- CSHA256& Write(const unsigned char *data, size_t len);
+ CSHA256& Write(const unsigned char* data, size_t len);
void Finalize(unsigned char hash[OUTPUT_SIZE]);
CSHA256& Reset();
};
/** A hasher class for SHA-512. */
-class CSHA512 {
+class CSHA512
+{
private:
uint64_t s[8];
unsigned char buf[128];
@@ -35,13 +37,14 @@ public:
static const size_t OUTPUT_SIZE = 64;
CSHA512();
- CSHA512& Write(const unsigned char *data, size_t len);
+ CSHA512& Write(const unsigned char* data, size_t len);
void Finalize(unsigned char hash[OUTPUT_SIZE]);
CSHA512& Reset();
};
/** A hasher class for HMAC-SHA-512. */
-class CHMAC_SHA512 {
+class CHMAC_SHA512
+{
private:
CSHA512 outer;
CSHA512 inner;
@@ -49,8 +52,9 @@ private:
public:
static const size_t OUTPUT_SIZE = 64;
- CHMAC_SHA512(const unsigned char *key, size_t keylen);
- CHMAC_SHA512& Write(const unsigned char *data, size_t len) {
+ CHMAC_SHA512(const unsigned char* key, size_t keylen);
+ CHMAC_SHA512& Write(const unsigned char* data, size_t len)
+ {
inner.Write(data, len);
return *this;
}
diff --git a/src/db.cpp b/src/db.cpp
index 23d2cc988d..12650e459f 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -20,6 +20,7 @@
#include <boost/filesystem.hpp>
#include <boost/thread.hpp>
#include <boost/version.hpp>
+
#include <openssl/rand.h>
using namespace std;
@@ -29,7 +30,6 @@ using namespace boost;
unsigned int nWalletDBUpdated;
-
//
// CDB
//
@@ -93,15 +93,15 @@ bool CDBEnv::Open(const boost::filesystem::path& pathIn)
dbenv.set_flags(DB_TXN_WRITE_NOSYNC, 1);
dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1);
int ret = dbenv.open(path.string().c_str(),
- DB_CREATE |
- DB_INIT_LOCK |
- DB_INIT_LOG |
- DB_INIT_MPOOL |
- DB_INIT_TXN |
- DB_THREAD |
- DB_RECOVER |
- nEnvFlags,
- S_IRUSR | S_IWUSR);
+ DB_CREATE |
+ DB_INIT_LOCK |
+ DB_INIT_LOG |
+ DB_INIT_MPOOL |
+ DB_INIT_TXN |
+ DB_THREAD |
+ DB_RECOVER |
+ nEnvFlags,
+ S_IRUSR | S_IWUSR);
if (ret != 0)
return error("CDBEnv::Open : Error %d opening database environment: %s\n", ret, DbEnv::strerror(ret));
@@ -120,21 +120,21 @@ void CDBEnv::MakeMock()
LogPrint("db", "CDBEnv::MakeMock\n");
dbenv.set_cachesize(1, 0, 1);
- dbenv.set_lg_bsize(10485760*4);
+ dbenv.set_lg_bsize(10485760 * 4);
dbenv.set_lg_max(10485760);
dbenv.set_lk_max_locks(10000);
dbenv.set_lk_max_objects(10000);
dbenv.set_flags(DB_AUTO_COMMIT, 1);
dbenv.log_set_config(DB_LOG_IN_MEMORY, 1);
int ret = dbenv.open(NULL,
- DB_CREATE |
- DB_INIT_LOCK |
- DB_INIT_LOG |
- DB_INIT_MPOOL |
- DB_INIT_TXN |
- DB_THREAD |
- DB_PRIVATE,
- S_IRUSR | S_IWUSR);
+ DB_CREATE |
+ DB_INIT_LOCK |
+ DB_INIT_LOG |
+ DB_INIT_MPOOL |
+ DB_INIT_TXN |
+ DB_THREAD |
+ DB_PRIVATE,
+ S_IRUSR | S_IWUSR);
if (ret > 0)
throw runtime_error(strprintf("CDBEnv::MakeMock : Error %d opening database environment.", ret));
@@ -159,30 +159,27 @@ CDBEnv::VerifyResult CDBEnv::Verify(std::string strFile, bool (*recoverFunc)(CDB
return (fRecovered ? RECOVER_OK : RECOVER_FAIL);
}
-bool CDBEnv::Salvage(std::string strFile, bool fAggressive,
- std::vector<CDBEnv::KeyValPair >& vResult)
+bool CDBEnv::Salvage(std::string strFile, bool fAggressive, std::vector<CDBEnv::KeyValPair>& vResult)
{
LOCK(cs_db);
assert(mapFileUseCount.count(strFile) == 0);
u_int32_t flags = DB_SALVAGE;
- if (fAggressive) flags |= DB_AGGRESSIVE;
+ if (fAggressive)
+ flags |= DB_AGGRESSIVE;
stringstream strDump;
Db db(&dbenv, 0);
int result = db.verify(strFile.c_str(), NULL, &strDump, flags);
- if (result == DB_VERIFY_BAD)
- {
+ if (result == DB_VERIFY_BAD) {
LogPrintf("CDBEnv::Salvage : Database salvage found errors, all data may not be recoverable.\n");
- if (!fAggressive)
- {
+ if (!fAggressive) {
LogPrintf("CDBEnv::Salvage : Rerun with aggressive mode to ignore errors and continue.\n");
return false;
}
}
- if (result != 0 && result != DB_VERIFY_BAD)
- {
+ if (result != 0 && result != DB_VERIFY_BAD) {
LogPrintf("CDBEnv::Salvage : Database salvage failed with result %d.\n", result);
return false;
}
@@ -200,13 +197,11 @@ bool CDBEnv::Salvage(std::string strFile, bool fAggressive,
getline(strDump, strLine); // Skip past header
std::string keyHex, valueHex;
- while (!strDump.eof() && keyHex != "DATA=END")
- {
+ while (!strDump.eof() && keyHex != "DATA=END") {
getline(strDump, keyHex);
- if (keyHex != "DATA_END")
- {
+ if (keyHex != "DATA_END") {
getline(strDump, valueHex);
- vResult.push_back(make_pair(ParseHex(keyHex),ParseHex(valueHex)));
+ vResult.push_back(make_pair(ParseHex(keyHex), ParseHex(valueHex)));
}
}
@@ -214,7 +209,7 @@ bool CDBEnv::Salvage(std::string strFile, bool fAggressive,
}
-void CDBEnv::CheckpointLSN(std::string strFile)
+void CDBEnv::CheckpointLSN(const std::string& strFile)
{
dbenv.txn_checkpoint(0, 0, 0);
if (fMockDb)
@@ -223,15 +218,14 @@ void CDBEnv::CheckpointLSN(std::string strFile)
}
-CDB::CDB(const char *pszFile, const char* pszMode) :
- pdb(NULL), activeTxn(NULL)
+CDB::CDB(const std::string& strFilename, const char* pszMode) : pdb(NULL), activeTxn(NULL)
{
int ret;
fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w'));
- if (pszFile == NULL)
+ if (strFilename.empty())
return;
- bool fCreate = strchr(pszMode, 'c');
+ bool fCreate = strchr(pszMode, 'c') != NULL;
unsigned int nFlags = DB_THREAD;
if (fCreate)
nFlags |= DB_CREATE;
@@ -241,40 +235,36 @@ CDB::CDB(const char *pszFile, const char* pszMode) :
if (!bitdb.Open(GetDataDir()))
throw runtime_error("CDB : Failed to open database environment.");
- strFile = pszFile;
+ strFile = strFilename;
++bitdb.mapFileUseCount[strFile];
pdb = bitdb.mapDb[strFile];
- if (pdb == NULL)
- {
+ if (pdb == NULL) {
pdb = new Db(&bitdb.dbenv, 0);
bool fMockDb = bitdb.IsMock();
- if (fMockDb)
- {
- DbMpoolFile*mpf = pdb->get_mpf();
+ if (fMockDb) {
+ DbMpoolFile* mpf = pdb->get_mpf();
ret = mpf->set_flags(DB_MPOOL_NOFILE, 1);
if (ret != 0)
- throw runtime_error(strprintf("CDB : Failed to configure for no temp file backing for database %s", pszFile));
+ throw runtime_error(strprintf("CDB : Failed to configure for no temp file backing for database %s", strFile));
}
- ret = pdb->open(NULL, // Txn pointer
- fMockDb ? NULL : pszFile, // Filename
- fMockDb ? pszFile : "main", // Logical db name
- DB_BTREE, // Database type
- nFlags, // Flags
+ ret = pdb->open(NULL, // Txn pointer
+ fMockDb ? NULL : strFile.c_str(), // Filename
+ fMockDb ? strFile.c_str() : "main", // Logical db name
+ DB_BTREE, // Database type
+ nFlags, // Flags
0);
- if (ret != 0)
- {
+ if (ret != 0) {
delete pdb;
pdb = NULL;
--bitdb.mapFileUseCount[strFile];
strFile = "";
- throw runtime_error(strprintf("CDB : Error %d, can't open database %s", ret, pszFile));
+ throw runtime_error(strprintf("CDB : Error %d, can't open database %s", ret, strFile));
}
- if (fCreate && !Exists(string("version")))
- {
+ if (fCreate && !Exists(string("version"))) {
bool fTmp = fReadOnly;
fReadOnly = false;
WriteVersion(CLIENT_VERSION);
@@ -296,7 +286,7 @@ void CDB::Flush()
if (fReadOnly)
nMinutes = 1;
- bitdb.dbenv.txn_checkpoint(nMinutes ? GetArg("-dblogsize", 100)*1024 : 0, nMinutes, 0);
+ bitdb.dbenv.txn_checkpoint(nMinutes ? GetArg("-dblogsize", 100) * 1024 : 0, nMinutes, 0);
}
void CDB::Close()
@@ -320,8 +310,7 @@ void CDBEnv::CloseDb(const string& strFile)
{
{
LOCK(cs_db);
- if (mapDb[strFile] != NULL)
- {
+ if (mapDb[strFile] != NULL) {
// Close the database handle
Db* pdb = mapDb[strFile];
pdb->close(0);
@@ -342,12 +331,10 @@ bool CDBEnv::RemoveDb(const string& strFile)
bool CDB::Rewrite(const string& strFile, const char* pszSkip)
{
- while (true)
- {
+ while (true) {
{
LOCK(bitdb.cs_db);
- if (!bitdb.mapFileUseCount.count(strFile) || bitdb.mapFileUseCount[strFile] == 0)
- {
+ if (!bitdb.mapFileUseCount.count(strFile) || bitdb.mapFileUseCount[strFile] == 0) {
// Flush log data to the dat file
bitdb.CloseDb(strFile);
bitdb.CheckpointLSN(strFile);
@@ -360,32 +347,27 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
CDB db(strFile.c_str(), "r");
Db* pdbCopy = new Db(&bitdb.dbenv, 0);
- int ret = pdbCopy->open(NULL, // Txn pointer
- strFileRes.c_str(), // Filename
- "main", // Logical db name
- DB_BTREE, // Database type
- DB_CREATE, // Flags
+ int ret = pdbCopy->open(NULL, // Txn pointer
+ strFileRes.c_str(), // Filename
+ "main", // Logical db name
+ DB_BTREE, // Database type
+ DB_CREATE, // Flags
0);
- if (ret > 0)
- {
+ if (ret > 0) {
LogPrintf("CDB::Rewrite : Can't create database file %s\n", strFileRes);
fSuccess = false;
}
Dbc* pcursor = db.GetCursor();
if (pcursor)
- while (fSuccess)
- {
+ while (fSuccess) {
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT);
- if (ret == DB_NOTFOUND)
- {
+ if (ret == DB_NOTFOUND) {
pcursor->close();
break;
- }
- else if (ret != 0)
- {
+ } else if (ret != 0) {
pcursor->close();
fSuccess = false;
break;
@@ -393,8 +375,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
if (pszSkip &&
strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0)
continue;
- if (strncmp(&ssKey[0], "\x07version", 8) == 0)
- {
+ if (strncmp(&ssKey[0], "\x07version", 8) == 0) {
// Update version:
ssValue.clear();
ssValue << CLIENT_VERSION;
@@ -405,8 +386,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
if (ret2 > 0)
fSuccess = false;
}
- if (fSuccess)
- {
+ if (fSuccess) {
db.Close();
bitdb.CloseDb(strFile);
if (pdbCopy->close(0))
@@ -414,8 +394,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
delete pdbCopy;
}
}
- if (fSuccess)
- {
+ if (fSuccess) {
Db dbA(&bitdb.dbenv, 0);
if (dbA.remove(strFile.c_str(), NULL, 0))
fSuccess = false;
@@ -444,13 +423,11 @@ void CDBEnv::Flush(bool fShutdown)
{
LOCK(cs_db);
map<string, int>::iterator mi = mapFileUseCount.begin();
- while (mi != mapFileUseCount.end())
- {
+ while (mi != mapFileUseCount.end()) {
string strFile = (*mi).first;
int nRefCount = (*mi).second;
LogPrint("db", "CDBEnv::Flush : Flushing %s (refcount = %d)...\n", strFile, nRefCount);
- if (nRefCount == 0)
- {
+ if (nRefCount == 0) {
// Move log data to the dat file
CloseDb(strFile);
LogPrint("db", "CDBEnv::Flush : %s checkpoint\n", strFile);
@@ -460,16 +437,13 @@ void CDBEnv::Flush(bool fShutdown)
dbenv.lsn_reset(strFile.c_str(), 0);
LogPrint("db", "CDBEnv::Flush : %s closed\n", strFile);
mapFileUseCount.erase(mi++);
- }
- else
+ } else
mi++;
}
LogPrint("db", "CDBEnv::Flush : Flush(%s)%s took %15dms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " database not started", GetTimeMillis() - nStart);
- if (fShutdown)
- {
+ if (fShutdown) {
char** listp;
- if (mapFileUseCount.empty())
- {
+ if (mapFileUseCount.empty()) {
dbenv.log_archive(&listp, DB_ARCH_REMOVE);
Close();
if (!fMockDb)
@@ -478,4 +452,3 @@ void CDBEnv::Flush(bool fShutdown)
}
}
}
-
diff --git a/src/db.h b/src/db.h
index bba267b84f..d202399383 100644
--- a/src/db.h
+++ b/src/db.h
@@ -15,12 +15,14 @@
#include <vector>
#include <boost/filesystem/path.hpp>
+
#include <db_cxx.h>
-struct CBlockLocator;
class CDiskBlockIndex;
class COutPoint;
+struct CBlockLocator;
+
extern unsigned int nWalletDBUpdated;
void ThreadFlushWalletDB(const std::string& strWalletFile);
@@ -52,7 +54,9 @@ public:
* This must be called BEFORE strFile is opened.
* Returns true if strFile is OK.
*/
- enum VerifyResult { VERIFY_OK, RECOVER_OK, RECOVER_FAIL };
+ enum VerifyResult { VERIFY_OK,
+ RECOVER_OK,
+ RECOVER_FAIL };
VerifyResult Verify(std::string strFile, bool (*recoverFunc)(CDBEnv& dbenv, std::string strFile));
/*
* Salvage data from a file that Verify says is bad.
@@ -64,15 +68,15 @@ public:
typedef std::pair<std::vector<unsigned char>, std::vector<unsigned char> > KeyValPair;
bool Salvage(std::string strFile, bool fAggressive, std::vector<KeyValPair>& vResult);
- bool Open(const boost::filesystem::path &path);
+ bool Open(const boost::filesystem::path& path);
void Close();
void Flush(bool fShutdown);
- void CheckpointLSN(std::string strFile);
+ void CheckpointLSN(const std::string& strFile);
void CloseDb(const std::string& strFile);
bool RemoveDb(const std::string& strFile);
- DbTxn *TxnBegin(int flags=DB_TXN_WRITE_NOSYNC)
+ DbTxn* TxnBegin(int flags = DB_TXN_WRITE_NOSYNC)
{
DbTxn* ptxn = NULL;
int ret = dbenv.txn_begin(NULL, &ptxn, flags);
@@ -91,20 +95,22 @@ class CDB
protected:
Db* pdb;
std::string strFile;
- DbTxn *activeTxn;
+ DbTxn* activeTxn;
bool fReadOnly;
- explicit CDB(const char* pszFile, const char* pszMode="r+");
+ explicit CDB(const std::string& strFilename, const char* pszMode = "r+");
~CDB() { Close(); }
+
public:
void Flush();
void Close();
+
private:
CDB(const CDB&);
void operator=(const CDB&);
protected:
- template<typename K, typename T>
+ template <typename K, typename T>
bool Read(const K& key, T& value)
{
if (!pdb)
@@ -128,8 +134,7 @@ protected:
try {
CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK, CLIENT_VERSION);
ssValue >> value;
- }
- catch (std::exception &e) {
+ } catch (const std::exception&) {
return false;
}
@@ -139,8 +144,8 @@ protected:
return (ret == 0);
}
- template<typename K, typename T>
- bool Write(const K& key, const T& value, bool fOverwrite=true)
+ template <typename K, typename T>
+ bool Write(const K& key, const T& value, bool fOverwrite = true)
{
if (!pdb)
return false;
@@ -168,7 +173,7 @@ protected:
return (ret == 0);
}
- template<typename K>
+ template <typename K>
bool Erase(const K& key)
{
if (!pdb)
@@ -190,7 +195,7 @@ protected:
return (ret == 0 || ret == DB_NOTFOUND);
}
- template<typename K>
+ template <typename K>
bool Exists(const K& key)
{
if (!pdb)
@@ -221,18 +226,16 @@ protected:
return pcursor;
}
- int ReadAtCursor(Dbc* pcursor, CDataStream& ssKey, CDataStream& ssValue, unsigned int fFlags=DB_NEXT)
+ int ReadAtCursor(Dbc* pcursor, CDataStream& ssKey, CDataStream& ssValue, unsigned int fFlags = DB_NEXT)
{
// Read at cursor
Dbt datKey;
- if (fFlags == DB_SET || fFlags == DB_SET_RANGE || fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE)
- {
+ if (fFlags == DB_SET || fFlags == DB_SET_RANGE || fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) {
datKey.set_data(&ssKey[0]);
datKey.set_size(ssKey.size());
}
Dbt datValue;
- if (fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE)
- {
+ if (fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) {
datValue.set_data(&ssValue[0]);
datValue.set_size(ssValue.size());
}
diff --git a/src/hash.cpp b/src/hash.cpp
index bddd8abf38..218607a6fd 100644
--- a/src/hash.cpp
+++ b/src/hash.cpp
@@ -1,6 +1,6 @@
#include "hash.h"
-inline uint32_t ROTL32 ( uint32_t x, int8_t r )
+inline uint32_t ROTL32(uint32_t x, int8_t r)
{
return (x << r) | (x >> (32 - r));
}
@@ -9,41 +9,48 @@ unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector<unsigned char
{
// The following is MurmurHash3 (x86_32), see http://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp
uint32_t h1 = nHashSeed;
- const uint32_t c1 = 0xcc9e2d51;
- const uint32_t c2 = 0x1b873593;
+ if (vDataToHash.size() > 0)
+ {
+ const uint32_t c1 = 0xcc9e2d51;
+ const uint32_t c2 = 0x1b873593;
- const int nblocks = vDataToHash.size() / 4;
+ const int nblocks = vDataToHash.size() / 4;
- //----------
- // body
- const uint32_t * blocks = (const uint32_t *)(&vDataToHash[0] + nblocks*4);
+ //----------
+ // body
+ const uint32_t* blocks = (const uint32_t*)(&vDataToHash[0] + nblocks * 4);
- for(int i = -nblocks; i; i++)
- {
- uint32_t k1 = blocks[i];
+ for (int i = -nblocks; i; i++) {
+ uint32_t k1 = blocks[i];
- k1 *= c1;
- k1 = ROTL32(k1,15);
- k1 *= c2;
+ k1 *= c1;
+ k1 = ROTL32(k1, 15);
+ k1 *= c2;
- h1 ^= k1;
- h1 = ROTL32(h1,13);
- h1 = h1*5+0xe6546b64;
- }
+ h1 ^= k1;
+ h1 = ROTL32(h1, 13);
+ h1 = h1 * 5 + 0xe6546b64;
+ }
- //----------
- // tail
- const uint8_t * tail = (const uint8_t*)(&vDataToHash[0] + nblocks*4);
+ //----------
+ // tail
+ const uint8_t* tail = (const uint8_t*)(&vDataToHash[0] + nblocks * 4);
- uint32_t k1 = 0;
+ uint32_t k1 = 0;
- switch(vDataToHash.size() & 3)
- {
- case 3: k1 ^= tail[2] << 16;
- case 2: k1 ^= tail[1] << 8;
- case 1: k1 ^= tail[0];
- k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
- };
+ switch (vDataToHash.size() & 3) {
+ case 3:
+ k1 ^= tail[2] << 16;
+ case 2:
+ k1 ^= tail[1] << 8;
+ case 1:
+ k1 ^= tail[0];
+ k1 *= c1;
+ k1 = ROTL32(k1, 15);
+ k1 *= c2;
+ h1 ^= k1;
+ };
+ }
//----------
// finalization
diff --git a/src/hash.h b/src/hash.h
index 98a2d1fb11..bdcd4afb47 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -6,8 +6,8 @@
#ifndef BITCOIN_HASH_H
#define BITCOIN_HASH_H
-#include "crypto/sha2.h"
#include "crypto/ripemd160.h"
+#include "crypto/sha2.h"
#include "serialize.h"
#include "uint256.h"
#include "version.h"
diff --git a/src/init.cpp b/src/init.cpp
index f83dfe2f99..85f4d360d2 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -11,6 +11,7 @@
#include "addrman.h"
#include "checkpoints.h"
+#include "compat/sanity.h"
#include "key.h"
#include "main.h"
#include "miner.h"
@@ -32,7 +33,6 @@
#ifndef WIN32
#include <signal.h>
#endif
-#include "compat/sanity.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
@@ -160,7 +160,9 @@ void Shutdown()
if (pwalletMain)
bitdb.Flush(true);
#endif
+#ifndef WIN32
boost::filesystem::remove(GetPidFile());
+#endif
UnregisterAllWallets();
#ifdef ENABLE_WALLET
if (pwalletMain)
@@ -198,7 +200,7 @@ bool static Bind(const CService &addr, unsigned int flags) {
if (!(flags & BF_EXPLICIT) && IsLimited(addr))
return false;
std::string strError;
- if (!BindListenPort(addr, strError, flags & BF_WHITELIST)) {
+ if (!BindListenPort(addr, strError, (flags & BF_WHITELIST) != 0)) {
if (flags & BF_REPORT_ERROR)
return InitError(strError);
return false;
@@ -226,8 +228,11 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += " -dbcache=<n> " + strprintf(_("Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache) + "\n";
strUsage += " -loadblock=<file> " + _("Imports blocks from external blk000??.dat file") + " " + _("on startup") + "\n";
strUsage += " -maxorphanblocks=<n> " + strprintf(_("Keep at most <n> unconnectable blocks in memory (default: %u)"), DEFAULT_MAX_ORPHAN_BLOCKS) + "\n";
+ strUsage += " -maxorphantx=<n> " + strprintf(_("Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS) + "\n";
strUsage += " -par=<n> " + strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"), -(int)boost::thread::hardware_concurrency(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS) + "\n";
+#ifndef WIN32
strUsage += " -pid=<file> " + _("Specify pid file (default: bitcoind.pid)") + "\n";
+#endif
strUsage += " -reindex " + _("Rebuild block chain index from current blk000??.dat files") + " " + _("on startup") + "\n";
#if !defined(WIN32)
strUsage += " -sysperms " + _("Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)") + "\n";
@@ -401,9 +406,11 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
int nFile = 0;
while (true) {
CDiskBlockPos pos(nFile, 0);
+ if (!boost::filesystem::exists(GetBlockPosFilename(pos, "blk")))
+ break; // No block files left to reindex
FILE *file = OpenBlockFile(pos, true);
if (!file)
- break;
+ break; // This error is logged in OpenBlockFile
LogPrintf("Reindexing block file blk%05u.dat...\n", (unsigned int)nFile);
LoadExternalBlockFile(file, &pos);
nFile++;
@@ -630,7 +637,6 @@ bool AppInit2(boost::thread_group& threadGroup)
fPrintToConsole = GetBoolArg("-printtoconsole", false);
fLogTimestamps = GetBoolArg("-logtimestamps", true);
fLogIPs = GetBoolArg("-logips", false);
- setvbuf(stdout, NULL, _IOLBF, 0);
#ifdef ENABLE_WALLET
bool fDisableWallet = GetBoolArg("-disablewallet", false);
#endif
@@ -692,7 +698,7 @@ bool AppInit2(boost::thread_group& threadGroup)
std::string strWalletFile = GetArg("-wallet", "wallet.dat");
#endif // ENABLE_WALLET
- fIsBareMultisigStd = GetArg("-permitbaremultisig", true);
+ fIsBareMultisigStd = GetArg("-permitbaremultisig", true) != 0;
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
// Sanity check
@@ -712,7 +718,9 @@ bool AppInit2(boost::thread_group& threadGroup)
static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
if (!lock.try_lock())
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin Core is probably already running."), strDataDir));
-
+#ifndef WIN32
+ CreatePidFile(GetPidFile(), getpid());
+#endif
if (GetBoolArg("-shrinkdebugfile", !fDebug))
ShrinkDebugFile();
LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
@@ -1050,7 +1058,7 @@ bool AppInit2(boost::thread_group& threadGroup)
}
boost::filesystem::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME;
- CAutoFile est_filein = CAutoFile(fopen(est_path.string().c_str(), "rb"), SER_DISK, CLIENT_VERSION);
+ CAutoFile est_filein(fopen(est_path.string().c_str(), "rb"), SER_DISK, CLIENT_VERSION);
// Allowed to fail as this file IS missing on first startup.
if (est_filein)
mempool.ReadFeeEstimates(est_filein);
diff --git a/src/init.h b/src/init.h
index cf1d1e7e39..aaf8c07e6e 100644
--- a/src/init.h
+++ b/src/init.h
@@ -10,8 +10,9 @@
class CWallet;
-namespace boost {
- class thread_group;
+namespace boost
+{
+class thread_group;
} // namespace boost
extern CWallet* pwalletMain;
@@ -22,8 +23,7 @@ void Shutdown();
bool AppInit2(boost::thread_group& threadGroup);
/* The help message mode determines what help message to show */
-enum HelpMessageMode
-{
+enum HelpMessageMode {
HMM_BITCOIND,
HMM_BITCOIN_QT
};
diff --git a/src/key.cpp b/src/key.cpp
index a058ef05e5..8ed787654a 100644
--- a/src/key.cpp
+++ b/src/key.cpp
@@ -172,9 +172,9 @@ public:
bool ret;
BIGNUM bn;
BN_init(&bn);
- ret = BN_bin2bn(vch, 32, &bn);
+ ret = BN_bin2bn(vch, 32, &bn) != NULL;
assert(ret);
- ret = EC_KEY_regenerate_key(pkey, &bn);
+ ret = EC_KEY_regenerate_key(pkey, &bn) != 0;
assert(ret);
BN_clear_free(&bn);
}
@@ -217,7 +217,7 @@ public:
bool SetPubKey(const CPubKey &pubkey) {
const unsigned char* pbegin = pubkey.begin();
- return o2i_ECPublicKey(&pkey, &pbegin, pubkey.size());
+ return o2i_ECPublicKey(&pkey, &pbegin, pubkey.size()) != NULL;
}
bool Sign(const uint256 &hash, std::vector<unsigned char>& vchSig) {
@@ -553,7 +553,7 @@ bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector<unsigned cha
if (vchSig.size() != 65)
return false;
int recid = (vchSig[0] - 27) & 3;
- bool fComp = (vchSig[0] - 27) & 4;
+ bool fComp = ((vchSig[0] - 27) & 4) != 0;
#ifdef USE_SECP256K1
int pubkeylen = 65;
if (!secp256k1_ecdsa_recover_compact((const unsigned char*)&hash, 32, &vchSig[1], (unsigned char*)begin(), &pubkeylen, fComp, recid))
diff --git a/src/key.h b/src/key.h
index 2a1837a23a..3863e95cff 100644
--- a/src/key.h
+++ b/src/key.h
@@ -26,27 +26,29 @@
class CKeyID : public uint160
{
public:
- CKeyID() : uint160(0) { }
- CKeyID(const uint160 &in) : uint160(in) { }
+ CKeyID() : uint160(0) {}
+ CKeyID(const uint160& in) : uint160(in) {}
};
/** A reference to a CScript: the Hash160 of its serialization (see script.h) */
class CScriptID : public uint160
{
public:
- CScriptID() : uint160(0) { }
- CScriptID(const uint160 &in) : uint160(in) { }
+ CScriptID() : uint160(0) {}
+ CScriptID(const uint160& in) : uint160(in) {}
};
/** An encapsulated public key. */
-class CPubKey {
+class CPubKey
+{
private:
// Just store the serialized data.
// Its length can very cheaply be computed from the first byte.
unsigned char vch[65];
// Compute the length of a pubkey with a given first byte.
- unsigned int static GetLen(unsigned char chHeader) {
+ unsigned int static GetLen(unsigned char chHeader)
+ {
if (chHeader == 2 || chHeader == 3)
return 33;
if (chHeader == 4 || chHeader == 6 || chHeader == 7)
@@ -55,66 +57,79 @@ private:
}
// Set this key data to be invalid
- void Invalidate() {
+ void Invalidate()
+ {
vch[0] = 0xFF;
}
public:
// Construct an invalid public key.
- CPubKey() {
+ CPubKey()
+ {
Invalidate();
}
// Initialize a public key using begin/end iterators to byte data.
- template<typename T>
- void Set(const T pbegin, const T pend) {
+ template <typename T>
+ void Set(const T pbegin, const T pend)
+ {
int len = pend == pbegin ? 0 : GetLen(pbegin[0]);
- if (len && len == (pend-pbegin))
+ if (len && len == (pend - pbegin))
memcpy(vch, (unsigned char*)&pbegin[0], len);
else
Invalidate();
}
// Construct a public key using begin/end iterators to byte data.
- template<typename T>
- CPubKey(const T pbegin, const T pend) {
+ template <typename T>
+ CPubKey(const T pbegin, const T pend)
+ {
Set(pbegin, pend);
}
// Construct a public key from a byte vector.
- CPubKey(const std::vector<unsigned char> &vch) {
+ CPubKey(const std::vector<unsigned char>& vch)
+ {
Set(vch.begin(), vch.end());
}
// Simple read-only vector-like interface to the pubkey data.
unsigned int size() const { return GetLen(vch[0]); }
- const unsigned char *begin() const { return vch; }
- const unsigned char *end() const { return vch+size(); }
- const unsigned char &operator[](unsigned int pos) const { return vch[pos]; }
+ const unsigned char* begin() const { return vch; }
+ const unsigned char* end() const { return vch + size(); }
+ const unsigned char& operator[](unsigned int pos) const { return vch[pos]; }
// Comparator implementation.
- friend bool operator==(const CPubKey &a, const CPubKey &b) {
+ friend bool operator==(const CPubKey& a, const CPubKey& b)
+ {
return a.vch[0] == b.vch[0] &&
memcmp(a.vch, b.vch, a.size()) == 0;
}
- friend bool operator!=(const CPubKey &a, const CPubKey &b) {
+ friend bool operator!=(const CPubKey& a, const CPubKey& b)
+ {
return !(a == b);
}
- friend bool operator<(const CPubKey &a, const CPubKey &b) {
+ friend bool operator<(const CPubKey& a, const CPubKey& b)
+ {
return a.vch[0] < b.vch[0] ||
(a.vch[0] == b.vch[0] && memcmp(a.vch, b.vch, a.size()) < 0);
}
// Implement serialization, as if this was a byte vector.
- unsigned int GetSerializeSize(int nType, int nVersion) const {
+ unsigned int GetSerializeSize(int nType, int nVersion) const
+ {
return size() + 1;
}
- template<typename Stream> void Serialize(Stream &s, int nType, int nVersion) const {
+ template <typename Stream>
+ void Serialize(Stream& s, int nType, int nVersion) const
+ {
unsigned int len = size();
::WriteCompactSize(s, len);
s.write((char*)vch, len);
}
- template<typename Stream> void Unserialize(Stream &s, int nType, int nVersion) {
+ template <typename Stream>
+ void Unserialize(Stream& s, int nType, int nVersion)
+ {
unsigned int len = ::ReadCompactSize(s);
if (len <= 65) {
s.read((char*)vch, len);
@@ -128,19 +143,22 @@ public:
}
// Get the KeyID of this public key (hash of its serialization)
- CKeyID GetID() const {
- return CKeyID(Hash160(vch, vch+size()));
+ CKeyID GetID() const
+ {
+ return CKeyID(Hash160(vch, vch + size()));
}
// Get the 256-bit hash of this public key.
- uint256 GetHash() const {
- return Hash(vch, vch+size());
+ uint256 GetHash() const
+ {
+ return Hash(vch, vch + size());
}
// Check syntactic correctness.
//
// Note that this is consensus critical as CheckSig() calls it!
- bool IsValid() const {
+ bool IsValid() const
+ {
return size() > 0;
}
@@ -148,16 +166,17 @@ public:
bool IsFullyValid() const;
// Check whether this is a compressed public key.
- bool IsCompressed() const {
+ bool IsCompressed() const
+ {
return size() == 33;
}
// Verify a DER signature (~72 bytes).
// If this public key is not fully valid, the return value will be false.
- bool Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig) const;
+ bool Verify(const uint256& hash, const std::vector<unsigned char>& vchSig) const;
// Recover a public key from a compact signature.
- bool RecoverCompact(const uint256 &hash, const std::vector<unsigned char>& vchSig);
+ bool RecoverCompact(const uint256& hash, const std::vector<unsigned char>& vchSig);
// Turn this public key into an uncompressed public key.
bool Decompress();
@@ -172,7 +191,8 @@ public:
typedef std::vector<unsigned char, secure_allocator<unsigned char> > CPrivKey;
/** An encapsulated private key. */
-class CKey {
+class CKey
+{
private:
// Whether this private key is valid. We check for correctness when modifying the key
// data, so fValid should always correspond to the actual state.
@@ -185,33 +205,38 @@ private:
unsigned char vch[32];
// Check whether the 32-byte array pointed to be vch is valid keydata.
- bool static Check(const unsigned char *vch);
-public:
+ bool static Check(const unsigned char* vch);
+public:
// Construct an invalid private key.
- CKey() : fValid(false), fCompressed(false) {
+ CKey() : fValid(false), fCompressed(false)
+ {
LockObject(vch);
}
// Copy constructor. This is necessary because of memlocking.
- CKey(const CKey &secret) : fValid(secret.fValid), fCompressed(secret.fCompressed) {
+ CKey(const CKey& secret) : fValid(secret.fValid), fCompressed(secret.fCompressed)
+ {
LockObject(vch);
memcpy(vch, secret.vch, sizeof(vch));
}
// Destructor (again necessary because of memlocking).
- ~CKey() {
+ ~CKey()
+ {
UnlockObject(vch);
}
- friend bool operator==(const CKey &a, const CKey &b) {
+ friend bool operator==(const CKey& a, const CKey& b)
+ {
return a.fCompressed == b.fCompressed && a.size() == b.size() &&
memcmp(&a.vch[0], &b.vch[0], a.size()) == 0;
}
// Initialize using begin and end iterators to byte data.
- template<typename T>
- void Set(const T pbegin, const T pend, bool fCompressedIn) {
+ template <typename T>
+ void Set(const T pbegin, const T pend, bool fCompressedIn)
+ {
if (pend - pbegin != 32) {
fValid = false;
return;
@@ -227,8 +252,8 @@ public:
// Simple read-only vector-like interface.
unsigned int size() const { return (fValid ? 32 : 0); }
- const unsigned char *begin() const { return vch; }
- const unsigned char *end() const { return vch + size(); }
+ const unsigned char* begin() const { return vch; }
+ const unsigned char* end() const { return vch + size(); }
// Check whether this private key is valid.
bool IsValid() const { return fValid; }
@@ -237,7 +262,7 @@ public:
bool IsCompressed() const { return fCompressed; }
// Initialize from a CPrivKey (serialized OpenSSL private key data).
- bool SetPrivKey(const CPrivKey &vchPrivKey, bool fCompressed);
+ bool SetPrivKey(const CPrivKey& vchPrivKey, bool fCompressed);
// Generate a new private key using a cryptographic PRNG.
void MakeNewKey(bool fCompressed);
@@ -251,23 +276,23 @@ public:
CPubKey GetPubKey() const;
// Create a DER-serialized signature.
- bool Sign(const uint256 &hash, std::vector<unsigned char>& vchSig) const;
+ bool Sign(const uint256& hash, std::vector<unsigned char>& vchSig) const;
// Create a compact signature (65 bytes), which allows reconstructing the used public key.
// The format is one header byte, followed by two times 32 bytes for the serialized r and s values.
// The header byte: 0x1B = first key with even y, 0x1C = first key with odd y,
// 0x1D = second key with even y, 0x1E = second key with odd y,
// add 0x04 for compressed keys.
- bool SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig) const;
+ bool SignCompact(const uint256& hash, std::vector<unsigned char>& vchSig) const;
// Derive BIP32 child key.
bool Derive(CKey& keyChild, unsigned char ccChild[32], unsigned int nChild, const unsigned char cc[32]) const;
// Load private key and check that public key matches.
- bool Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck);
+ bool Load(CPrivKey& privkey, CPubKey& vchPubKey, bool fSkipCheck);
// Check whether an element of a signature (r or s) is valid.
- static bool CheckSignatureElement(const unsigned char *vch, int len, bool half);
+ static bool CheckSignatureElement(const unsigned char* vch, int len, bool half);
};
struct CExtPubKey {
@@ -277,14 +302,15 @@ struct CExtPubKey {
unsigned char vchChainCode[32];
CPubKey pubkey;
- friend bool operator==(const CExtPubKey &a, const CExtPubKey &b) {
+ friend bool operator==(const CExtPubKey& a, const CExtPubKey& b)
+ {
return a.nDepth == b.nDepth && memcmp(&a.vchFingerprint[0], &b.vchFingerprint[0], 4) == 0 && a.nChild == b.nChild &&
memcmp(&a.vchChainCode[0], &b.vchChainCode[0], 32) == 0 && a.pubkey == b.pubkey;
}
void Encode(unsigned char code[74]) const;
void Decode(const unsigned char code[74]);
- bool Derive(CExtPubKey &out, unsigned int nChild) const;
+ bool Derive(CExtPubKey& out, unsigned int nChild) const;
};
struct CExtKey {
@@ -294,16 +320,17 @@ struct CExtKey {
unsigned char vchChainCode[32];
CKey key;
- friend bool operator==(const CExtKey &a, const CExtKey &b) {
+ friend bool operator==(const CExtKey& a, const CExtKey& b)
+ {
return a.nDepth == b.nDepth && memcmp(&a.vchFingerprint[0], &b.vchFingerprint[0], 4) == 0 && a.nChild == b.nChild &&
memcmp(&a.vchChainCode[0], &b.vchChainCode[0], 32) == 0 && a.key == b.key;
}
void Encode(unsigned char code[74]) const;
void Decode(const unsigned char code[74]);
- bool Derive(CExtKey &out, unsigned int nChild) const;
+ bool Derive(CExtKey& out, unsigned int nChild) const;
CExtPubKey Neuter() const;
- void SetMaster(const unsigned char *seed, unsigned int nSeedLen);
+ void SetMaster(const unsigned char* seed, unsigned int nSeedLen);
};
/** Check that required EC support is available at runtime */
diff --git a/src/leveldbwrapper.cpp b/src/leveldbwrapper.cpp
index 9e849696a8..8ce3e7b470 100644
--- a/src/leveldbwrapper.cpp
+++ b/src/leveldbwrapper.cpp
@@ -12,7 +12,8 @@
#include <leveldb/filter_policy.h>
#include <memenv.h>
-void HandleError(const leveldb::Status &status) throw(leveldb_error) {
+void HandleError(const leveldb::Status& status) throw(leveldb_error)
+{
if (status.ok())
return;
LogPrintf("%s\n", status.ToString());
@@ -25,7 +26,8 @@ void HandleError(const leveldb::Status &status) throw(leveldb_error) {
throw leveldb_error("Unknown database error");
}
-static leveldb::Options GetOptions(size_t nCacheSize) {
+static leveldb::Options GetOptions(size_t nCacheSize)
+{
leveldb::Options options;
options.block_cache = leveldb::NewLRUCache(nCacheSize / 2);
options.write_buffer_size = nCacheSize / 4; // up to two write buffers may be held in memory simultaneously
@@ -40,7 +42,8 @@ static leveldb::Options GetOptions(size_t nCacheSize) {
return options;
}
-CLevelDBWrapper::CLevelDBWrapper(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory, bool fWipe) {
+CLevelDBWrapper::CLevelDBWrapper(const boost::filesystem::path& path, size_t nCacheSize, bool fMemory, bool fWipe)
+{
penv = NULL;
readoptions.verify_checksums = true;
iteroptions.verify_checksums = true;
@@ -64,7 +67,8 @@ CLevelDBWrapper::CLevelDBWrapper(const boost::filesystem::path &path, size_t nCa
LogPrintf("Opened LevelDB successfully\n");
}
-CLevelDBWrapper::~CLevelDBWrapper() {
+CLevelDBWrapper::~CLevelDBWrapper()
+{
delete pdb;
pdb = NULL;
delete options.filter_policy;
@@ -75,7 +79,8 @@ CLevelDBWrapper::~CLevelDBWrapper() {
options.env = NULL;
}
-bool CLevelDBWrapper::WriteBatch(CLevelDBBatch &batch, bool fSync) throw(leveldb_error) {
+bool CLevelDBWrapper::WriteBatch(CLevelDBBatch& batch, bool fSync) throw(leveldb_error)
+{
leveldb::Status status = pdb->Write(fSync ? syncoptions : writeoptions, &batch.batch);
HandleError(status);
return true;
diff --git a/src/leveldbwrapper.h b/src/leveldbwrapper.h
index 452df92839..da5ba61c7b 100644
--- a/src/leveldbwrapper.h
+++ b/src/leveldbwrapper.h
@@ -10,16 +10,17 @@
#include "version.h"
#include <boost/filesystem/path.hpp>
+
#include <leveldb/db.h>
#include <leveldb/write_batch.h>
class leveldb_error : public std::runtime_error
{
public:
- leveldb_error(const std::string &msg) : std::runtime_error(msg) {}
+ leveldb_error(const std::string& msg) : std::runtime_error(msg) {}
};
-void HandleError(const leveldb::Status &status) throw(leveldb_error);
+void HandleError(const leveldb::Status& status) throw(leveldb_error);
// Batch of changes queued to be written to a CLevelDBWrapper
class CLevelDBBatch
@@ -30,7 +31,9 @@ private:
leveldb::WriteBatch batch;
public:
- template<typename K, typename V> void Write(const K& key, const V& value) {
+ template <typename K, typename V>
+ void Write(const K& key, const V& value)
+ {
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
ssKey.reserve(ssKey.GetSerializeSize(key));
ssKey << key;
@@ -44,7 +47,9 @@ public:
batch.Put(slKey, slValue);
}
- template<typename K> void Erase(const K& key) {
+ template <typename K>
+ void Erase(const K& key)
+ {
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
ssKey.reserve(ssKey.GetSerializeSize(key));
ssKey << key;
@@ -58,7 +63,7 @@ class CLevelDBWrapper
{
private:
// custom environment this database is using (may be NULL in case of default environment)
- leveldb::Env *penv;
+ leveldb::Env* penv;
// database options used
leveldb::Options options;
@@ -76,13 +81,15 @@ private:
leveldb::WriteOptions syncoptions;
// the database itself
- leveldb::DB *pdb;
+ leveldb::DB* pdb;
public:
- CLevelDBWrapper(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory = false, bool fWipe = false);
+ CLevelDBWrapper(const boost::filesystem::path& path, size_t nCacheSize, bool fMemory = false, bool fWipe = false);
~CLevelDBWrapper();
- template<typename K, typename V> bool Read(const K& key, V& value) const throw(leveldb_error) {
+ template <typename K, typename V>
+ bool Read(const K& key, V& value) const throw(leveldb_error)
+ {
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
ssKey.reserve(ssKey.GetSerializeSize(key));
ssKey << key;
@@ -99,19 +106,23 @@ public:
try {
CDataStream ssValue(strValue.data(), strValue.data() + strValue.size(), SER_DISK, CLIENT_VERSION);
ssValue >> value;
- } catch(std::exception &e) {
+ } catch (const std::exception&) {
return false;
}
return true;
}
- template<typename K, typename V> bool Write(const K& key, const V& value, bool fSync = false) throw(leveldb_error) {
+ template <typename K, typename V>
+ bool Write(const K& key, const V& value, bool fSync = false) throw(leveldb_error)
+ {
CLevelDBBatch batch;
batch.Write(key, value);
return WriteBatch(batch, fSync);
}
- template<typename K> bool Exists(const K& key) const throw(leveldb_error) {
+ template <typename K>
+ bool Exists(const K& key) const throw(leveldb_error)
+ {
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
ssKey.reserve(ssKey.GetSerializeSize(key));
ssKey << key;
@@ -128,26 +139,31 @@ public:
return true;
}
- template<typename K> bool Erase(const K& key, bool fSync = false) throw(leveldb_error) {
+ template <typename K>
+ bool Erase(const K& key, bool fSync = false) throw(leveldb_error)
+ {
CLevelDBBatch batch;
batch.Erase(key);
return WriteBatch(batch, fSync);
}
- bool WriteBatch(CLevelDBBatch &batch, bool fSync = false) throw(leveldb_error);
+ bool WriteBatch(CLevelDBBatch& batch, bool fSync = false) throw(leveldb_error);
// not available for LevelDB; provide for compatibility with BDB
- bool Flush() {
+ bool Flush()
+ {
return true;
}
- bool Sync() throw(leveldb_error) {
+ bool Sync() throw(leveldb_error)
+ {
CLevelDBBatch batch;
return WriteBatch(batch, true);
}
// not exactly clean encapsulation, but it's easiest for now
- leveldb::Iterator *NewIterator() {
+ leveldb::Iterator* NewIterator()
+ {
return pdb->NewIterator(iteroptions);
}
};
diff --git a/src/limitedmap.h b/src/limitedmap.h
index 58593688af..03727d7c42 100644
--- a/src/limitedmap.h
+++ b/src/limitedmap.h
@@ -1,15 +1,16 @@
-// Copyright (c) 2012 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2012-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_LIMITEDMAP_H
#define BITCOIN_LIMITEDMAP_H
-#include <assert.h> // TODO: remove
+#include <assert.h>
#include <map>
/** STL-like map container that only keeps the N elements with the highest value. */
-template <typename K, typename V> class limitedmap
+template <typename K, typename V>
+class limitedmap
{
public:
typedef K key_type;
@@ -36,10 +37,8 @@ public:
void insert(const value_type& x)
{
std::pair<iterator, bool> ret = map.insert(x);
- if (ret.second)
- {
- if (nMaxSize && map.size() == nMaxSize)
- {
+ if (ret.second) {
+ if (nMaxSize && map.size() == nMaxSize) {
map.erase(rmap.begin()->second);
rmap.erase(rmap.begin());
}
@@ -54,42 +53,36 @@ public:
return;
std::pair<rmap_iterator, rmap_iterator> itPair = rmap.equal_range(itTarget->second);
for (rmap_iterator it = itPair.first; it != itPair.second; ++it)
- if (it->second == itTarget)
- {
+ if (it->second == itTarget) {
rmap.erase(it);
map.erase(itTarget);
return;
}
// Shouldn't ever get here
- assert(0); //TODO remove me
- map.erase(itTarget);
+ assert(0);
}
void update(const_iterator itIn, const mapped_type& v)
{
- //TODO: When we switch to C++11, use map.erase(itIn, itIn) to get the non-const iterator
+ // TODO: When we switch to C++11, use map.erase(itIn, itIn) to get the non-const iterator.
iterator itTarget = map.find(itIn->first);
if (itTarget == map.end())
return;
std::pair<rmap_iterator, rmap_iterator> itPair = rmap.equal_range(itTarget->second);
for (rmap_iterator it = itPair.first; it != itPair.second; ++it)
- if (it->second == itTarget)
- {
+ if (it->second == itTarget) {
rmap.erase(it);
itTarget->second = v;
rmap.insert(make_pair(v, itTarget));
return;
}
// Shouldn't ever get here
- assert(0); //TODO remove me
- itTarget->second = v;
- rmap.insert(make_pair(v, itTarget));
+ assert(0);
}
size_type max_size() const { return nMaxSize; }
size_type max_size(size_type s)
{
if (s)
- while (map.size() > s)
- {
+ while (map.size() > s) {
map.erase(rmap.begin()->second);
rmap.erase(rmap.begin());
}
diff --git a/src/main.cpp b/src/main.cpp
index 5210f8ef55..9a4271eda2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -63,8 +63,13 @@ struct COrphanBlock {
map<uint256, COrphanBlock*> mapOrphanBlocks;
multimap<uint256, COrphanBlock*> mapOrphanBlocksByPrev;
-map<uint256, CTransaction> mapOrphanTransactions;
+struct COrphanTx {
+ CTransaction tx;
+ NodeId fromPeer;
+};
+map<uint256, COrphanTx> mapOrphanTransactions;
map<uint256, set<uint256> > mapOrphanTransactionsByPrev;
+void EraseOrphansFor(NodeId peer);
// Constant stuff for coinbase transactions we create:
CScript COINBASE_FLAGS;
@@ -264,6 +269,7 @@ void FinalizeNode(NodeId nodeid) {
mapBlocksInFlight.erase(entry.hash);
BOOST_FOREACH(const uint256& hash, state->vBlocksToDownload)
mapBlocksToDownload.erase(hash);
+ EraseOrphansFor(nodeid);
mapNodeState.erase(nodeid);
}
@@ -408,7 +414,7 @@ CBlockTreeDB *pblocktree = NULL;
// mapOrphanTransactions
//
-bool AddOrphanTx(const CTransaction& tx)
+bool AddOrphanTx(const CTransaction& tx, NodeId peer)
{
uint256 hash = tx.GetHash();
if (mapOrphanTransactions.count(hash))
@@ -428,29 +434,50 @@ bool AddOrphanTx(const CTransaction& tx)
return false;
}
- mapOrphanTransactions[hash] = tx;
+ mapOrphanTransactions[hash].tx = tx;
+ mapOrphanTransactions[hash].fromPeer = peer;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash);
- LogPrint("mempool", "stored orphan tx %s (mapsz %u)\n", hash.ToString(),
- mapOrphanTransactions.size());
+ LogPrint("mempool", "stored orphan tx %s (mapsz %u prevsz %u)\n", hash.ToString(),
+ mapOrphanTransactions.size(), mapOrphanTransactionsByPrev.size());
return true;
}
void static EraseOrphanTx(uint256 hash)
{
- if (!mapOrphanTransactions.count(hash))
+ map<uint256, COrphanTx>::iterator it = mapOrphanTransactions.find(hash);
+ if (it == mapOrphanTransactions.end())
return;
- const CTransaction& tx = mapOrphanTransactions[hash];
- BOOST_FOREACH(const CTxIn& txin, tx.vin)
+ BOOST_FOREACH(const CTxIn& txin, it->second.tx.vin)
+ {
+ map<uint256, set<uint256> >::iterator itPrev = mapOrphanTransactionsByPrev.find(txin.prevout.hash);
+ if (itPrev == mapOrphanTransactionsByPrev.end())
+ continue;
+ itPrev->second.erase(hash);
+ if (itPrev->second.empty())
+ mapOrphanTransactionsByPrev.erase(itPrev);
+ }
+ mapOrphanTransactions.erase(it);
+}
+
+void EraseOrphansFor(NodeId peer)
+{
+ int nErased = 0;
+ map<uint256, COrphanTx>::iterator iter = mapOrphanTransactions.begin();
+ while (iter != mapOrphanTransactions.end())
{
- mapOrphanTransactionsByPrev[txin.prevout.hash].erase(hash);
- if (mapOrphanTransactionsByPrev[txin.prevout.hash].empty())
- mapOrphanTransactionsByPrev.erase(txin.prevout.hash);
+ map<uint256, COrphanTx>::iterator maybeErase = iter++; // increment to avoid iterator becoming invalid
+ if (maybeErase->second.fromPeer == peer)
+ {
+ EraseOrphanTx(maybeErase->second.tx.GetHash());
+ ++nErased;
+ }
}
- mapOrphanTransactions.erase(hash);
+ if (nErased > 0) LogPrint("mempool", "Erased %d orphan tx from peer %d\n", nErased, peer);
}
+
unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans)
{
unsigned int nEvicted = 0;
@@ -458,7 +485,7 @@ unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans)
{
// Evict a random orphan:
uint256 randomhash = GetRandHash();
- map<uint256, CTransaction>::iterator it = mapOrphanTransactions.lower_bound(randomhash);
+ map<uint256, COrphanTx>::iterator it = mapOrphanTransactions.lower_bound(randomhash);
if (it == mapOrphanTransactions.end())
it = mapOrphanTransactions.begin();
EraseOrphanTx(it->first);
@@ -617,7 +644,7 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
// IsStandard() will have already returned false
// and this method isn't called.
vector<vector<unsigned char> > stack;
- if (!EvalScript(stack, tx.vin[i].scriptSig, tx, i, false, 0))
+ if (!EvalScript(stack, tx.vin[i].scriptSig, tx, i, false))
return false;
if (whichType == TX_SCRIPTHASH)
@@ -964,9 +991,9 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
int nHeight = -1;
{
CCoinsViewCache &view = *pcoinsTip;
- CCoins coins;
- if (view.GetCoins(hash, coins))
- nHeight = coins.nHeight;
+ const CCoins* coins = view.AccessCoins(hash);
+ if (coins)
+ nHeight = coins->nHeight;
}
if (nHeight > 0)
pindexSlow = chainActive[nHeight];
@@ -1002,7 +1029,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos)
{
// Open history file to append
- CAutoFile fileout = CAutoFile(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION);
+ CAutoFile fileout(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION);
if (!fileout)
return error("WriteBlockToDisk : OpenBlockFile failed");
@@ -1030,7 +1057,7 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
block.SetNull();
// Open history file to read
- CAutoFile filein = CAutoFile(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION);
+ CAutoFile filein(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION);
if (!filein)
return error("ReadBlockFromDisk : OpenBlockFile failed");
@@ -1271,12 +1298,13 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach
bool ret;
// mark inputs spent
if (!tx.IsCoinBase()) {
- BOOST_FOREACH(const CTxIn &txin, tx.vin) {
+ txundo.vprevout.reserve(tx.vin.size());
+ for (unsigned int i = 0; i < tx.vin.size(); i++) {
+ const CTxIn &txin = tx.vin[i];
CCoins &coins = inputs.GetCoins(txin.prevout.hash);
- CTxInUndo undo;
- ret = coins.Spend(txin.prevout, undo);
+ txundo.vprevout.push_back(CTxInUndo());
+ ret = coins.Spend(txin.prevout, txundo.vprevout.back());
assert(ret);
- txundo.vprevout.push_back(undo);
}
}
@@ -1287,16 +1315,11 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach
bool CScriptCheck::operator()() const {
const CScript &scriptSig = ptxTo->vin[nIn].scriptSig;
- if (!VerifyScript(scriptSig, scriptPubKey, *ptxTo, nIn, nFlags, nHashType))
+ if (!VerifyScript(scriptSig, scriptPubKey, *ptxTo, nIn, nFlags))
return error("CScriptCheck() : %s VerifySignature failed", ptxTo->GetHash().ToString());
return true;
}
-bool VerifySignature(const CCoins& txFrom, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType)
-{
- return CScriptCheck(txFrom, txTo, nIn, flags, nHashType)();
-}
-
bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, std::vector<CScriptCheck> *pvChecks)
{
if (!tx.IsCoinBase())
@@ -1318,19 +1341,20 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
for (unsigned int i = 0; i < tx.vin.size(); i++)
{
const COutPoint &prevout = tx.vin[i].prevout;
- const CCoins &coins = inputs.GetCoins(prevout.hash);
+ const CCoins *coins = inputs.AccessCoins(prevout.hash);
+ assert(coins);
// If prev is coinbase, check that it's matured
- if (coins.IsCoinBase()) {
- if (nSpendHeight - coins.nHeight < COINBASE_MATURITY)
+ if (coins->IsCoinBase()) {
+ if (nSpendHeight - coins->nHeight < COINBASE_MATURITY)
return state.Invalid(
- error("CheckInputs() : tried to spend coinbase at depth %d", nSpendHeight - coins.nHeight),
+ error("CheckInputs() : tried to spend coinbase at depth %d", nSpendHeight - coins->nHeight),
REJECT_INVALID, "bad-txns-premature-spend-of-coinbase");
}
// Check for negative or overflow input values
- nValueIn += coins.vout[prevout.n].nValue;
- if (!MoneyRange(coins.vout[prevout.n].nValue) || !MoneyRange(nValueIn))
+ nValueIn += coins->vout[prevout.n].nValue;
+ if (!MoneyRange(coins->vout[prevout.n].nValue) || !MoneyRange(nValueIn))
return state.DoS(100, error("CheckInputs() : txin values out of range"),
REJECT_INVALID, "bad-txns-inputvalues-outofrange");
@@ -1360,10 +1384,11 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
if (fScriptChecks) {
for (unsigned int i = 0; i < tx.vin.size(); i++) {
const COutPoint &prevout = tx.vin[i].prevout;
- const CCoins &coins = inputs.GetCoins(prevout.hash);
+ const CCoins* coins = inputs.AccessCoins(prevout.hash);
+ assert(coins);
// Verify signature
- CScriptCheck check(coins, tx, i, flags, 0);
+ CScriptCheck check(*coins, tx, i, flags);
if (pvChecks) {
pvChecks->push_back(CScriptCheck());
check.swap(pvChecks->back());
@@ -1375,8 +1400,8 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
// arguments; if so, don't trigger DoS protection to
// avoid splitting the network between upgraded and
// non-upgraded nodes.
- CScriptCheck check(coins, tx, i,
- flags & ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS, 0);
+ CScriptCheck check(*coins, tx, i,
+ flags & ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS);
if (check())
return state.Invalid(false, REJECT_NONSTANDARD, "non-mandatory-script-verify-flag");
}
@@ -1561,8 +1586,8 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
(pindex->nHeight==91880 && pindex->GetBlockHash() == uint256("0x00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721")));
if (fEnforceBIP30) {
BOOST_FOREACH(const CTransaction& tx, block.vtx) {
- const uint256& hash = tx.GetHash();
- if (view.HaveCoins(hash) && !view.GetCoins(hash).IsPruned())
+ const CCoins* coins = view.AccessCoins(tx.GetHash());
+ if (coins && !coins->IsPruned())
return state.DoS(100, error("ConnectBlock() : tried to overwrite transaction"),
REJECT_INVALID, "bad-txns-BIP30");
}
@@ -1586,6 +1611,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size()));
std::vector<std::pair<uint256, CDiskTxPos> > vPos;
vPos.reserve(block.vtx.size());
+ blockundo.vtxundo.reserve(block.vtx.size() - 1);
for (unsigned int i = 0; i < block.vtx.size(); i++)
{
const CTransaction &tx = block.vtx[i];
@@ -1621,10 +1647,11 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
control.Add(vChecks);
}
- CTxUndo txundo;
- UpdateCoins(tx, state, view, txundo, pindex->nHeight);
- if (!tx.IsCoinBase())
- blockundo.vtxundo.push_back(txundo);
+ CTxUndo undoDummy;
+ if (i > 0) {
+ blockundo.vtxundo.push_back(CTxUndo());
+ }
+ UpdateCoins(tx, state, view, i == 0 ? undoDummy : blockundo.vtxundo.back(), pindex->nHeight);
vPos.push_back(std::make_pair(tx.GetHash(), pos));
pos.nTxOffset += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION);
@@ -1720,11 +1747,6 @@ bool static WriteChainState(CValidationState &state) {
void static UpdateTip(CBlockIndex *pindexNew) {
chainActive.SetTip(pindexNew);
- // Update best block in wallet (so we can detect restored wallets)
- bool fIsInitialDownload = IsInitialBlockDownload();
- if ((chainActive.Height() % 20160) == 0 || (!fIsInitialDownload && (chainActive.Height() % 144) == 0))
- g_signals.SetBestChain(chainActive.GetLocator());
-
// New best block
nTimeBestReceived = GetTime();
mempool.AddTransactionsUpdated(1);
@@ -1737,7 +1759,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
cvBlockChange.notify_all();
// Check the version of the last 100 blocks to see if we need to upgrade:
- if (!fIsInitialDownload)
+ if (!IsInitialBlockDownload())
{
int nUpgraded = 0;
const CBlockIndex* pindex = chainActive.Tip();
@@ -1854,6 +1876,11 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
BOOST_FOREACH(const CTransaction &tx, pblock->vtx) {
SyncWithWallets(tx, pblock);
}
+ // Update best block in wallet (so we can detect restored wallets)
+ // Emit this signal after the SyncWithWallets signals as the wallet relies on that everything up to this point has been synced
+ if ((chainActive.Height() % 20160) == 0 || ((chainActive.Height() % 144) == 0 && !IsInitialBlockDownload()))
+ g_signals.SetBestChain(chainActive.GetLocator());
+
int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;
LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001);
LogPrint("bench", "- Connect block: %.2fms [%.2fs]\n", (nTime6 - nTime1) * 0.001, nTimeTotal * 0.000001);
@@ -2713,7 +2740,7 @@ FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
{
if (pos.IsNull())
return NULL;
- boost::filesystem::path path = GetDataDir() / "blocks" / strprintf("%s%05u.dat", prefix, pos.nFile);
+ boost::filesystem::path path = GetBlockPosFilename(pos, prefix);
boost::filesystem::create_directories(path.parent_path());
FILE* file = fopen(path.string().c_str(), "rb+");
if (!file && !fReadOnly)
@@ -2740,6 +2767,11 @@ FILE* OpenUndoFile(const CDiskBlockPos &pos, bool fReadOnly) {
return OpenDiskFile(pos, "rev", fReadOnly);
}
+boost::filesystem::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix)
+{
+ return GetDataDir() / "blocks" / strprintf("%s%05u.dat", prefix, pos.nFile);
+}
+
CBlockIndex * InsertBlockIndex(uint256 hash)
{
if (hash == 0)
@@ -3081,7 +3113,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
blkdat >> nSize;
if (nSize < 80 || nSize > MAX_BLOCK_SIZE)
continue;
- } catch (std::exception &e) {
+ } catch (const std::exception &) {
// no valid block header found; don't complain
break;
}
@@ -3585,6 +3617,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// Track requests for our stuff
g_signals.Inventory(inv.hash);
+
+ if (pfrom->nSendSize > (SendBufferSize() * 2)) {
+ Misbehaving(pfrom->GetId(), 50);
+ return error("send buffer size() = %u", pfrom->nSendSize);
+ }
}
}
@@ -3699,48 +3736,62 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
bool fMissingInputs = false;
CValidationState state;
+
+ mapAlreadyAskedFor.erase(inv);
+
if (AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs))
{
mempool.check(pcoinsTip);
RelayTransaction(tx);
- mapAlreadyAskedFor.erase(inv);
vWorkQueue.push_back(inv.hash);
vEraseQueue.push_back(inv.hash);
-
LogPrint("mempool", "AcceptToMemoryPool: peer=%d %s : accepted %s (poolsz %u)\n",
pfrom->id, pfrom->cleanSubVer,
tx.GetHash().ToString(),
mempool.mapTx.size());
// Recursively process any orphan transactions that depended on this one
+ set<NodeId> setMisbehaving;
for (unsigned int i = 0; i < vWorkQueue.size(); i++)
{
- uint256 hashPrev = vWorkQueue[i];
- for (set<uint256>::iterator mi = mapOrphanTransactionsByPrev[hashPrev].begin();
- mi != mapOrphanTransactionsByPrev[hashPrev].end();
+ map<uint256, set<uint256> >::iterator itByPrev = mapOrphanTransactionsByPrev.find(vWorkQueue[i]);
+ if (itByPrev == mapOrphanTransactionsByPrev.end())
+ continue;
+ for (set<uint256>::iterator mi = itByPrev->second.begin();
+ mi != itByPrev->second.end();
++mi)
{
const uint256& orphanHash = *mi;
- const CTransaction& orphanTx = mapOrphanTransactions[orphanHash];
+ const CTransaction& orphanTx = mapOrphanTransactions[orphanHash].tx;
+ NodeId fromPeer = mapOrphanTransactions[orphanHash].fromPeer;
bool fMissingInputs2 = false;
// Use a dummy CValidationState so someone can't setup nodes to counter-DoS based on orphan
// resolution (that is, feeding people an invalid transaction based on LegitTxX in order to get
// anyone relaying LegitTxX banned)
CValidationState stateDummy;
+ vEraseQueue.push_back(orphanHash);
+
+ if (setMisbehaving.count(fromPeer))
+ continue;
if (AcceptToMemoryPool(mempool, stateDummy, orphanTx, true, &fMissingInputs2))
{
LogPrint("mempool", " accepted orphan tx %s\n", orphanHash.ToString());
RelayTransaction(orphanTx);
- mapAlreadyAskedFor.erase(CInv(MSG_TX, orphanHash));
vWorkQueue.push_back(orphanHash);
- vEraseQueue.push_back(orphanHash);
}
else if (!fMissingInputs2)
{
- // invalid or too-little-fee orphan
- vEraseQueue.push_back(orphanHash);
+ int nDos = 0;
+ if (stateDummy.IsInvalid(nDos) && nDos > 0)
+ {
+ // Punish peer that gave us an invalid orphan tx
+ Misbehaving(fromPeer, nDos);
+ setMisbehaving.insert(fromPeer);
+ LogPrint("mempool", " invalid orphan tx %s\n", orphanHash.ToString());
+ }
+ // too-little-fee orphan
LogPrint("mempool", " removed orphan tx %s\n", orphanHash.ToString());
}
mempool.check(pcoinsTip);
@@ -3752,10 +3803,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
}
else if (fMissingInputs)
{
- AddOrphanTx(tx);
+ AddOrphanTx(tx, pfrom->GetId());
// DoS prevention: do not allow mapOrphanTransactions to grow unbounded
- unsigned int nEvicted = LimitOrphanTxSize(MAX_ORPHAN_TRANSACTIONS);
+ unsigned int nMaxOrphanTx = (unsigned int)std::max((int64_t)0, GetArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS));
+ unsigned int nEvicted = LimitOrphanTxSize(nMaxOrphanTx);
if (nEvicted > 0)
LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted);
} else if (pfrom->fWhitelisted) {
@@ -4004,21 +4056,25 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
else if (strCommand == "reject")
{
- if (fDebug)
- {
- string strMsg; unsigned char ccode; string strReason;
- vRecv >> LIMITED_STRING(strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING(strReason, 111);
+ if (fDebug) {
+ try {
+ string strMsg; unsigned char ccode; string strReason;
+ vRecv >> LIMITED_STRING(strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING(strReason, 111);
- ostringstream ss;
- ss << strMsg << " code " << itostr(ccode) << ": " << strReason;
+ ostringstream ss;
+ ss << strMsg << " code " << itostr(ccode) << ": " << strReason;
- if (strMsg == "block" || strMsg == "tx")
- {
- uint256 hash;
- vRecv >> hash;
- ss << ": hash " << hash.ToString();
+ if (strMsg == "block" || strMsg == "tx")
+ {
+ uint256 hash;
+ vRecv >> hash;
+ ss << ": hash " << hash.ToString();
+ }
+ LogPrint("net", "Reject %s\n", SanitizeString(ss.str()));
+ } catch (std::ios_base::failure& e) {
+ // Avoid feedback loops by preventing reject messages from triggering a new reject message.
+ LogPrint("net", "Unparseable reject message received\n");
}
- LogPrint("net", "Reject %s\n", SanitizeString(ss.str()));
}
}
@@ -4259,7 +4315,9 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
if (pto->addr.IsLocal())
LogPrintf("Warning: not banning local peer %s!\n", pto->addr.ToString());
else
+ {
CNode::Ban(pto->addr);
+ }
}
state.fShouldBan = false;
}
@@ -4339,7 +4397,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
if (!pto->fDisconnect && state.nBlocksInFlight &&
state.nLastBlockReceive < state.nLastBlockProcess - BLOCK_DOWNLOAD_TIMEOUT*1000000 &&
state.vBlocksInFlight.front().nTime < state.nLastBlockProcess - 2*BLOCK_DOWNLOAD_TIMEOUT*1000000) {
- LogPrintf("Peer %s is stalling block download, disconnecting\n", state.name.c_str());
+ LogPrintf("Peer %s is stalling block download, disconnecting\n", state.name);
pto->fDisconnect = true;
}
@@ -4392,7 +4450,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
bool CBlockUndo::WriteToDisk(CDiskBlockPos &pos, const uint256 &hashBlock)
{
// Open history file to append
- CAutoFile fileout = CAutoFile(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION);
+ CAutoFile fileout(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION);
if (!fileout)
return error("CBlockUndo::WriteToDisk : OpenUndoFile failed");
@@ -4424,7 +4482,7 @@ bool CBlockUndo::WriteToDisk(CDiskBlockPos &pos, const uint256 &hashBlock)
bool CBlockUndo::ReadFromDisk(const CDiskBlockPos &pos, const uint256 &hashBlock)
{
// Open history file to read
- CAutoFile filein = CAutoFile(OpenUndoFile(pos, true), SER_DISK, CLIENT_VERSION);
+ CAutoFile filein(OpenUndoFile(pos, true), SER_DISK, CLIENT_VERSION);
if (!filein)
return error("CBlockUndo::ReadFromDisk : OpenBlockFile failed");
@@ -4449,7 +4507,7 @@ bool CBlockUndo::ReadFromDisk(const CDiskBlockPos &pos, const uint256 &hashBlock
}
std::string CBlockFileInfo::ToString() const {
- return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, DateTimeStrFormat("%Y-%m-%d", nTimeFirst).c_str(), DateTimeStrFormat("%Y-%m-%d", nTimeLast).c_str());
+ return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, DateTimeStrFormat("%Y-%m-%d", nTimeFirst), DateTimeStrFormat("%Y-%m-%d", nTimeLast));
}
@@ -4473,5 +4531,6 @@ public:
// orphan transactions
mapOrphanTransactions.clear();
+ mapOrphanTransactionsByPrev.clear();
}
} instance_of_cmaincleanup;
diff --git a/src/main.h b/src/main.h
index ff55a26cac..c75841538f 100644
--- a/src/main.h
+++ b/src/main.h
@@ -52,8 +52,8 @@ static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
static const unsigned int MAX_P2SH_SIGOPS = 15;
/** The maximum number of sigops we're willing to relay/mine in a single tx */
static const unsigned int MAX_TX_SIGOPS = MAX_BLOCK_SIGOPS/5;
-/** The maximum number of orphan transactions kept in memory */
-static const unsigned int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100;
+/** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
+static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
/** Default for -maxorphanblocks, maximum number of orphan blocks kept in memory */
static const unsigned int DEFAULT_MAX_ORPHAN_BLOCKS = 750;
/** The maximum size of a blk?????.dat file (since 0.8) */
@@ -146,6 +146,8 @@ bool CheckDiskSpace(uint64_t nAdditionalBytes = 0);
FILE* OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly = false);
/** Open an undo file (rev?????.dat) */
FILE* OpenUndoFile(const CDiskBlockPos &pos, bool fReadOnly = false);
+/** Translation to a filesystem path */
+boost::filesystem::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix);
/** Import blocks from an external file */
bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp = NULL);
/** Initialize a new block tree database + block data on disk */
@@ -174,8 +176,6 @@ int64_t GetBlockValue(int nHeight, int64_t nFees);
/** Create a new block index entry for a given block hash */
CBlockIndex * InsertBlockIndex(uint256 hash);
-/** Verify a signature */
-bool VerifySignature(const CCoins& txFrom, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType);
/** Abort with a message */
bool AbortNode(const std::string &msg);
/** Get statistics from node state */
@@ -302,13 +302,12 @@ private:
const CTransaction *ptxTo;
unsigned int nIn;
unsigned int nFlags;
- int nHashType;
public:
- CScriptCheck(): ptxTo(0), nIn(0), nFlags(0), nHashType(0) {}
- CScriptCheck(const CCoins& txFromIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, int nHashTypeIn) :
+ CScriptCheck(): ptxTo(0), nIn(0), nFlags(0) {}
+ CScriptCheck(const CCoins& txFromIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn) :
scriptPubKey(txFromIn.vout[txToIn.vin[nInIn].prevout.n].scriptPubKey),
- ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), nHashType(nHashTypeIn) { }
+ ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn) { }
bool operator()() const;
@@ -317,7 +316,6 @@ public:
std::swap(ptxTo, check.ptxTo);
std::swap(nIn, check.nIn);
std::swap(nFlags, check.nFlags);
- std::swap(nHashType, check.nHashType);
}
};
diff --git a/src/miner.cpp b/src/miner.cpp
index 96dc80a26d..d05ddbeb1f 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -167,12 +167,13 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
nTotalIn += mempool.mapTx[txin.prevout.hash].GetTx().vout[txin.prevout.n].nValue;
continue;
}
- const CCoins &coins = view.GetCoins(txin.prevout.hash);
+ const CCoins* coins = view.AccessCoins(txin.prevout.hash);
+ assert(coins);
- int64_t nValueIn = coins.vout[txin.prevout.n].nValue;
+ int64_t nValueIn = coins->vout[txin.prevout.n].nValue;
nTotalIn += nValueIn;
- int nConf = pindexPrev->nHeight - coins.nHeight + 1;
+ int nConf = pindexPrev->nHeight - coins->nHeight + 1;
dPriority += (double)nValueIn * nConf;
}
diff --git a/src/mruset.h b/src/mruset.h
index b9f325d874..1691875f57 100644
--- a/src/mruset.h
+++ b/src/mruset.h
@@ -10,7 +10,8 @@
#include <utility>
/** STL-like set container that only keeps the most recent N elements. */
-template <typename T> class mruset
+template <typename T>
+class mruset
{
public:
typedef T key_type;
@@ -32,17 +33,19 @@ public:
bool empty() const { return set.empty(); }
iterator find(const key_type& k) const { return set.find(k); }
size_type count(const key_type& k) const { return set.count(k); }
- void clear() { set.clear(); queue.clear(); }
+ void clear()
+ {
+ set.clear();
+ queue.clear();
+ }
bool inline friend operator==(const mruset<T>& a, const mruset<T>& b) { return a.set == b.set; }
bool inline friend operator==(const mruset<T>& a, const std::set<T>& b) { return a.set == b; }
bool inline friend operator<(const mruset<T>& a, const mruset<T>& b) { return a.set < b.set; }
std::pair<iterator, bool> insert(const key_type& x)
{
std::pair<iterator, bool> ret = set.insert(x);
- if (ret.second)
- {
- if (nMaxSize && queue.size() == nMaxSize)
- {
+ if (ret.second) {
+ if (nMaxSize && queue.size() == nMaxSize) {
set.erase(queue.front());
queue.pop_front();
}
@@ -54,8 +57,7 @@ public:
size_type max_size(size_type s)
{
if (s)
- while (queue.size() > s)
- {
+ while (queue.size() > s) {
set.erase(queue.front());
queue.pop_front();
}
diff --git a/src/net.cpp b/src/net.cpp
index 2546826f9a..866bac2c0e 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -48,8 +48,8 @@
#endif
#endif
-using namespace std;
using namespace boost;
+using namespace std;
namespace {
const int MAX_OUTBOUND_CONNECTIONS = 8;
@@ -488,10 +488,6 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest)
{
addrman.Attempt(addrConnect);
- // Set to non-blocking
- if (!SetSocketNonBlocking(hSocket, true))
- LogPrintf("ConnectNode: Setting socket to non-blocking failed, error %s\n", NetworkErrorString(WSAGetLastError()));
-
// Add node
CNode* pnode = new CNode(hSocket, addrConnect, pszDest ? pszDest : "", false);
pnode->AddRef();
@@ -689,7 +685,7 @@ int CNetMessage::readHeader(const char *pch, unsigned int nBytes)
try {
hdrbuf >> hdr;
}
- catch (std::exception &e) {
+ catch (const std::exception &) {
return -1;
}
@@ -1961,7 +1957,7 @@ bool CAddrDB::Write(const CAddrMan& addr)
// open temp output file, and associate with CAutoFile
boost::filesystem::path pathTmp = GetDataDir() / tmpfn;
FILE *file = fopen(pathTmp.string().c_str(), "wb");
- CAutoFile fileout = CAutoFile(file, SER_DISK, CLIENT_VERSION);
+ CAutoFile fileout(file, SER_DISK, CLIENT_VERSION);
if (!fileout)
return error("%s : Failed to open file %s", __func__, pathTmp.string());
@@ -1986,7 +1982,7 @@ bool CAddrDB::Read(CAddrMan& addr)
{
// open input file, and associate with CAutoFile
FILE *file = fopen(pathAddr.string().c_str(), "rb");
- CAutoFile filein = CAutoFile(file, SER_DISK, CLIENT_VERSION);
+ CAutoFile filein(file, SER_DISK, CLIENT_VERSION);
if (!filein)
return error("%s : Failed to open file %s", __func__, pathAddr.string());
@@ -2106,6 +2102,8 @@ CNode::~CNode()
void CNode::AskFor(const CInv& inv)
{
+ if (mapAskFor.size() > MAPASKFOR_MAX_SZ)
+ return;
// We're using mapAskFor as a priority queue,
// the key is the earliest time the request can be sent
int64_t nRequestTime;
@@ -2114,7 +2112,7 @@ void CNode::AskFor(const CInv& inv)
nRequestTime = it->second;
else
nRequestTime = 0;
- LogPrint("net", "askfor %s %d (%s) peer=%d\n", inv.ToString(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str(), id);
+ LogPrint("net", "askfor %s %d (%s) peer=%d\n", inv.ToString(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000), id);
// Make sure not to reuse time indexes to keep things in the same order
int64_t nNow = GetTimeMicros() - 1000000;
diff --git a/src/net.h b/src/net.h
index e2700c0975..ad0a1df7e2 100644
--- a/src/net.h
+++ b/src/net.h
@@ -51,6 +51,8 @@ static const bool DEFAULT_UPNP = USE_UPNP;
#else
static const bool DEFAULT_UPNP = false;
#endif
+/** The maximum number of entries in mapAskFor */
+static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ;
unsigned int ReceiveFloodSize();
unsigned int SendBufferSize();
diff --git a/src/netbase.cpp b/src/netbase.cpp
index d5821d4465..5819c152a3 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -45,6 +45,9 @@ bool fNameLookup = false;
static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
+// Need ample time for negotiation for very slow proxies such as Tor (milliseconds)
+static const int SOCKS5_RECV_TIMEOUT = 20 * 1000;
+
enum Network ParseNetwork(std::string net) {
boost::to_lower(net);
if (net == "ipv4") return NET_IPV4;
@@ -225,6 +228,63 @@ bool LookupNumeric(const char *pszName, CService& addr, int portDefault)
return Lookup(pszName, addr, portDefault, false);
}
+/**
+ * Convert milliseconds to a struct timeval for select.
+ */
+struct timeval static MillisToTimeval(int64_t nTimeout)
+{
+ struct timeval timeout;
+ timeout.tv_sec = nTimeout / 1000;
+ timeout.tv_usec = (nTimeout % 1000) * 1000;
+ return timeout;
+}
+
+/**
+ * Read bytes from socket. This will either read the full number of bytes requested
+ * or return False on error or timeout.
+ * This function can be interrupted by boost thread interrupt.
+ *
+ * @param data Buffer to receive into
+ * @param len Length of data to receive
+ * @param timeout Timeout in milliseconds for receive operation
+ *
+ * @note This function requires that hSocket is in non-blocking mode.
+ */
+bool static InterruptibleRecv(char* data, size_t len, int timeout, SOCKET& hSocket)
+{
+ int64_t curTime = GetTimeMillis();
+ int64_t endTime = curTime + timeout;
+ // Maximum time to wait in one select call. It will take up until this time (in millis)
+ // to break off in case of an interruption.
+ const int64_t maxWait = 1000;
+ while (len > 0 && curTime < endTime) {
+ ssize_t ret = recv(hSocket, data, len, 0); // Optimistically try the recv first
+ if (ret > 0) {
+ len -= ret;
+ data += ret;
+ } else if (ret == 0) { // Unexpected disconnection
+ return false;
+ } else { // Other error or blocking
+ int nErr = WSAGetLastError();
+ if (nErr == WSAEINPROGRESS || nErr == WSAEWOULDBLOCK || nErr == WSAEINVAL) {
+ struct timeval tval = MillisToTimeval(std::min(endTime - curTime, maxWait));
+ fd_set fdset;
+ FD_ZERO(&fdset);
+ FD_SET(hSocket, &fdset);
+ int nRet = select(hSocket + 1, &fdset, NULL, NULL, &tval);
+ if (nRet == SOCKET_ERROR) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ boost::this_thread::interruption_point();
+ curTime = GetTimeMillis();
+ }
+ return len == 0;
+}
+
bool static Socks5(string strDest, int port, SOCKET& hSocket)
{
LogPrintf("SOCKS5 connecting %s\n", strDest);
@@ -243,7 +303,7 @@ bool static Socks5(string strDest, int port, SOCKET& hSocket)
return error("Error sending to proxy");
}
char pchRet1[2];
- if (recv(hSocket, pchRet1, 2, 0) != 2)
+ if (!InterruptibleRecv(pchRet1, 2, SOCKS5_RECV_TIMEOUT, hSocket))
{
CloseSocket(hSocket);
return error("Error reading proxy response");
@@ -259,14 +319,14 @@ bool static Socks5(string strDest, int port, SOCKET& hSocket)
strSocks5 += strDest;
strSocks5 += static_cast<char>((port >> 8) & 0xFF);
strSocks5 += static_cast<char>((port >> 0) & 0xFF);
- ret = send(hSocket, strSocks5.c_str(), strSocks5.size(), MSG_NOSIGNAL);
+ ret = send(hSocket, strSocks5.data(), strSocks5.size(), MSG_NOSIGNAL);
if (ret != (ssize_t)strSocks5.size())
{
CloseSocket(hSocket);
return error("Error sending to proxy");
}
char pchRet2[4];
- if (recv(hSocket, pchRet2, 4, 0) != 4)
+ if (!InterruptibleRecv(pchRet2, 4, SOCKS5_RECV_TIMEOUT, hSocket))
{
CloseSocket(hSocket);
return error("Error reading proxy response");
@@ -300,27 +360,27 @@ bool static Socks5(string strDest, int port, SOCKET& hSocket)
char pchRet3[256];
switch (pchRet2[3])
{
- case 0x01: ret = recv(hSocket, pchRet3, 4, 0) != 4; break;
- case 0x04: ret = recv(hSocket, pchRet3, 16, 0) != 16; break;
+ case 0x01: ret = InterruptibleRecv(pchRet3, 4, SOCKS5_RECV_TIMEOUT, hSocket); break;
+ case 0x04: ret = InterruptibleRecv(pchRet3, 16, SOCKS5_RECV_TIMEOUT, hSocket); break;
case 0x03:
{
- ret = recv(hSocket, pchRet3, 1, 0) != 1;
- if (ret) {
+ ret = InterruptibleRecv(pchRet3, 1, SOCKS5_RECV_TIMEOUT, hSocket);
+ if (!ret) {
CloseSocket(hSocket);
return error("Error reading from proxy");
}
int nRecv = pchRet3[0];
- ret = recv(hSocket, pchRet3, nRecv, 0) != nRecv;
+ ret = InterruptibleRecv(pchRet3, nRecv, SOCKS5_RECV_TIMEOUT, hSocket);
break;
}
default: CloseSocket(hSocket); return error("Error: malformed proxy response");
}
- if (ret)
+ if (!ret)
{
CloseSocket(hSocket);
return error("Error reading from proxy");
}
- if (recv(hSocket, pchRet3, 2, 0) != 2)
+ if (!InterruptibleRecv(pchRet3, 2, SOCKS5_RECV_TIMEOUT, hSocket))
{
CloseSocket(hSocket);
return error("Error reading from proxy");
@@ -360,10 +420,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
// WSAEINVAL is here because some legacy version of winsock uses it
if (nErr == WSAEINPROGRESS || nErr == WSAEWOULDBLOCK || nErr == WSAEINVAL)
{
- struct timeval timeout;
- timeout.tv_sec = nTimeout / 1000;
- timeout.tv_usec = (nTimeout % 1000) * 1000;
-
+ struct timeval timeout = MillisToTimeval(nTimeout);
fd_set fdset;
FD_ZERO(&fdset);
FD_SET(hSocket, &fdset);
@@ -410,11 +467,6 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
}
}
- // This is required when using SOCKS5 proxy!
- // CNode::ConnectNode turns the socket back to non-blocking.
- if (!SetSocketNonBlocking(hSocket, false))
- return error("ConnectSocketDirectly: Setting socket to blocking failed, error %s\n", NetworkErrorString(WSAGetLastError()));
-
hSocketRet = hSocket;
return true;
}
diff --git a/src/noui.cpp b/src/noui.cpp
index 8b00fd4057..f786a20db5 100644
--- a/src/noui.cpp
+++ b/src/noui.cpp
@@ -35,7 +35,7 @@ static bool noui_ThreadSafeMessageBox(const std::string& message, const std::str
return false;
}
-static void noui_InitMessage(const std::string &message)
+static void noui_InitMessage(const std::string& message)
{
LogPrintf("init message: %s\n", message);
}
diff --git a/src/pow.h b/src/pow.h
index 2a0d9b24bb..5d91108ac4 100644
--- a/src/pow.h
+++ b/src/pow.h
@@ -8,8 +8,8 @@
#include <stdint.h>
-class CBlockIndex;
class CBlockHeader;
+class CBlockIndex;
class uint256;
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock);
diff --git a/src/protocol.h b/src/protocol.h
index 82d29e66de..b73041a9fd 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -4,7 +4,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef __cplusplus
-# error This header can only be compiled as C++.
+#error This header can only be compiled as C++.
#endif
#ifndef __INCLUDED_PROTOCOL_H__
@@ -28,43 +28,43 @@
*/
class CMessageHeader
{
- public:
- CMessageHeader();
- CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn);
+public:
+ CMessageHeader();
+ CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn);
- std::string GetCommand() const;
- bool IsValid() const;
+ std::string GetCommand() const;
+ bool IsValid() const;
- ADD_SERIALIZE_METHODS;
+ ADD_SERIALIZE_METHODS;
- template <typename Stream, typename Operation>
- inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- READWRITE(FLATDATA(pchMessageStart));
- READWRITE(FLATDATA(pchCommand));
- READWRITE(nMessageSize);
- READWRITE(nChecksum);
- }
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
+ {
+ READWRITE(FLATDATA(pchMessageStart));
+ READWRITE(FLATDATA(pchCommand));
+ READWRITE(nMessageSize);
+ READWRITE(nChecksum);
+ }
// TODO: make private (improves encapsulation)
- public:
- enum {
- COMMAND_SIZE=12,
- MESSAGE_SIZE_SIZE=sizeof(int),
- CHECKSUM_SIZE=sizeof(int),
-
- MESSAGE_SIZE_OFFSET=MESSAGE_START_SIZE+COMMAND_SIZE,
- CHECKSUM_OFFSET=MESSAGE_SIZE_OFFSET+MESSAGE_SIZE_SIZE,
- HEADER_SIZE=MESSAGE_START_SIZE+COMMAND_SIZE+MESSAGE_SIZE_SIZE+CHECKSUM_SIZE
- };
- char pchMessageStart[MESSAGE_START_SIZE];
- char pchCommand[COMMAND_SIZE];
- unsigned int nMessageSize;
- unsigned int nChecksum;
+public:
+ enum {
+ COMMAND_SIZE = 12,
+ MESSAGE_SIZE_SIZE = sizeof(int),
+ CHECKSUM_SIZE = sizeof(int),
+
+ MESSAGE_SIZE_OFFSET = MESSAGE_START_SIZE + COMMAND_SIZE,
+ CHECKSUM_OFFSET = MESSAGE_SIZE_OFFSET + MESSAGE_SIZE_SIZE,
+ HEADER_SIZE = MESSAGE_START_SIZE + COMMAND_SIZE + MESSAGE_SIZE_SIZE + CHECKSUM_SIZE
+ };
+ char pchMessageStart[MESSAGE_START_SIZE];
+ char pchCommand[COMMAND_SIZE];
+ unsigned int nMessageSize;
+ unsigned int nChecksum;
};
/** nServices flags */
-enum
-{
+enum {
NODE_NETWORK = (1 << 0),
// Bits 24-31 are reserved for temporary experiments. Just pick a bit that
@@ -79,68 +79,69 @@ enum
/** A CService with information about it as peer */
class CAddress : public CService
{
- public:
- CAddress();
- explicit CAddress(CService ipIn, uint64_t nServicesIn=NODE_NETWORK);
-
- void Init();
-
- ADD_SERIALIZE_METHODS;
-
- template <typename Stream, typename Operation>
- inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- if (ser_action.ForRead())
- Init();
- if (nType & SER_DISK)
- READWRITE(nVersion);
- if ((nType & SER_DISK) ||
- (nVersion >= CADDR_TIME_VERSION && !(nType & SER_GETHASH)))
- READWRITE(nTime);
- READWRITE(nServices);
- READWRITE(*(CService*)this);
- }
+public:
+ CAddress();
+ explicit CAddress(CService ipIn, uint64_t nServicesIn = NODE_NETWORK);
+
+ void Init();
+
+ ADD_SERIALIZE_METHODS;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
+ {
+ if (ser_action.ForRead())
+ Init();
+ if (nType & SER_DISK)
+ READWRITE(nVersion);
+ if ((nType & SER_DISK) ||
+ (nVersion >= CADDR_TIME_VERSION && !(nType & SER_GETHASH)))
+ READWRITE(nTime);
+ READWRITE(nServices);
+ READWRITE(*(CService*)this);
+ }
// TODO: make private (improves encapsulation)
- public:
- uint64_t nServices;
+public:
+ uint64_t nServices;
- // disk and network only
- unsigned int nTime;
+ // disk and network only
+ unsigned int nTime;
- // memory only
- int64_t nLastTry;
+ // memory only
+ int64_t nLastTry;
};
/** inv message data */
class CInv
{
- public:
- CInv();
- CInv(int typeIn, const uint256& hashIn);
- CInv(const std::string& strType, const uint256& hashIn);
+public:
+ CInv();
+ CInv(int typeIn, const uint256& hashIn);
+ CInv(const std::string& strType, const uint256& hashIn);
- ADD_SERIALIZE_METHODS;
+ ADD_SERIALIZE_METHODS;
- template <typename Stream, typename Operation>
- inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
- READWRITE(type);
- READWRITE(hash);
- }
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
+ {
+ READWRITE(type);
+ READWRITE(hash);
+ }
- friend bool operator<(const CInv& a, const CInv& b);
+ friend bool operator<(const CInv& a, const CInv& b);
- bool IsKnownType() const;
- const char* GetCommand() const;
- std::string ToString() const;
+ bool IsKnownType() const;
+ const char* GetCommand() const;
+ std::string ToString() const;
// TODO: make private (improves encapsulation)
- public:
- int type;
- uint256 hash;
+public:
+ int type;
+ uint256 hash;
};
-enum
-{
+enum {
MSG_TX = 1,
MSG_BLOCK,
// Nodes may always request a MSG_FILTERED_BLOCK in a getdata, however,
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 6cc6b99ceb..bd686041c1 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -16,6 +16,7 @@
#include "splashscreen.h"
#include "utilitydialog.h"
#include "winshutdownmonitor.h"
+
#ifdef ENABLE_WALLET
#include "paymentserver.h"
#include "walletmodel.h"
@@ -26,6 +27,7 @@
#include "rpcserver.h"
#include "ui_interface.h"
#include "util.h"
+
#ifdef ENABLE_WALLET
#include "wallet.h"
#endif
@@ -34,15 +36,16 @@
#include <boost/filesystem/operations.hpp>
#include <boost/thread.hpp>
+
#include <QApplication>
#include <QDebug>
#include <QLibraryInfo>
#include <QLocale>
#include <QMessageBox>
#include <QSettings>
+#include <QThread>
#include <QTimer>
#include <QTranslator>
-#include <QThread>
#if defined(QT_STATICPLUGIN)
#include <QtPlugin>
@@ -338,7 +341,9 @@ void BitcoinApplication::createWindow(bool isaTestNet)
void BitcoinApplication::createSplashScreen(bool isaTestNet)
{
- SplashScreen *splash = new SplashScreen(QPixmap(), 0, isaTestNet);
+ SplashScreen *splash = new SplashScreen(0, isaTestNet);
+ // We don't hold a direct pointer to the splash screen after creation, so use
+ // Qt::WA_DeleteOnClose to make sure that the window will be deleted eventually.
splash->setAttribute(Qt::WA_DeleteOnClose);
splash->show();
connect(this, SIGNAL(splashFinished(QWidget*)), splash, SLOT(slotFinish(QWidget*)));
@@ -423,8 +428,6 @@ void BitcoinApplication::initializeResult(int retval)
}
#endif
- emit splashFinished(window);
-
// If -min option passed, start window minimized.
if(GetBoolArg("-min", false))
{
@@ -434,6 +437,8 @@ void BitcoinApplication::initializeResult(int retval)
{
window->show();
}
+ emit splashFinished(window);
+
#ifdef ENABLE_WALLET
// Now that initialization/startup is done, process any command-line
// bitcoin: URIs or payment requests:
diff --git a/src/qt/bitcoinamountfield.h b/src/qt/bitcoinamountfield.h
index c713f5d687..84795a7e7a 100644
--- a/src/qt/bitcoinamountfield.h
+++ b/src/qt/bitcoinamountfield.h
@@ -7,12 +7,12 @@
#include <QWidget>
+class AmountSpinBox;
+
QT_BEGIN_NAMESPACE
class QValueComboBox;
QT_END_NAMESPACE
-class AmountSpinBox;
-
/** Widget for entering bitcoin amounts.
*/
class BitcoinAmountField: public QWidget
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 790301a1eb..443bed14d7 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -14,6 +14,7 @@
#include "optionsmodel.h"
#include "rpcconsole.h"
#include "utilitydialog.h"
+
#ifdef ENABLE_WALLET
#include "walletframe.h"
#include "walletmodel.h"
@@ -24,8 +25,8 @@
#endif
#include "init.h"
-#include "util.h"
#include "ui_interface.h"
+#include "util.h"
#include <iostream>
@@ -50,8 +51,8 @@
#include <QVBoxLayout>
#if QT_VERSION < 0x050000
-#include <QUrl>
#include <QTextDocument>
+#include <QUrl>
#else
#include <QUrlQuery>
#endif
@@ -661,6 +662,9 @@ void BitcoinGUI::setNumConnections(int count)
void BitcoinGUI::setNumBlocks(int count)
{
+ if(!clientModel)
+ return;
+
// Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text)
statusBar()->clearMessage();
@@ -831,7 +835,7 @@ void BitcoinGUI::changeEvent(QEvent *e)
#ifndef Q_OS_MAC // Ignored on Mac
if(e->type() == QEvent::WindowStateChange)
{
- if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray())
+ if(clientModel && clientModel->getOptionsModel() && clientModel->getOptionsModel()->getMinimizeToTray())
{
QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
@@ -846,16 +850,16 @@ void BitcoinGUI::changeEvent(QEvent *e)
void BitcoinGUI::closeEvent(QCloseEvent *event)
{
- if(clientModel)
- {
#ifndef Q_OS_MAC // Ignored on Mac
+ if(clientModel && clientModel->getOptionsModel())
+ {
if(!clientModel->getOptionsModel()->getMinimizeToTray() &&
!clientModel->getOptionsModel()->getMinimizeOnClose())
{
QApplication::quit();
}
-#endif
}
+#endif
QMainWindow::closeEvent(event);
}
@@ -916,8 +920,7 @@ bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
gotoSendCoinsPage();
return true;
}
- else
- return false;
+ return false;
}
void BitcoinGUI::setEncryptionStatus(int status)
diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp
index 6f506d3f25..3215363fa0 100644
--- a/src/qt/bitcoinunits.cpp
+++ b/src/qt/bitcoinunits.cpp
@@ -115,11 +115,6 @@ QString BitcoinUnits::format(int unit, qint64 n, bool fPlus, SeparatorStyle sepa
for (int i = 3; i < q_size; i += 3)
quotient_str.insert(q_size - i, thin_sp);
- int r_size = remainder_str.size();
- if (separators == separatorAlways || (separators == separatorStandard && r_size > 4))
- for (int i = 3, adj = 0; i < r_size ; i += 3, adj++)
- remainder_str.insert(i + adj, thin_sp);
-
if (n < 0)
quotient_str.insert(0, '-');
else if (fPlus && n > 0)
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp
index 7b30f8de09..d10463fd8f 100644
--- a/src/qt/coincontroldialog.cpp
+++ b/src/qt/coincontroldialog.cpp
@@ -705,7 +705,7 @@ void CoinControlDialog::updateView()
QString sAddress = "";
if(ExtractDestination(out.tx->vout[out.i].scriptPubKey, outputAddress))
{
- sAddress = CBitcoinAddress(outputAddress).ToString().c_str();
+ sAddress = QString::fromStdString(CBitcoinAddress(outputAddress).ToString());
// if listMode or change => show bitcoin address. In tree mode, address is not shown again for direct wallet address outputs
if (!treeMode || (!(sAddress == sWalletAddress)))
@@ -752,7 +752,7 @@ void CoinControlDialog::updateView()
// transaction hash
uint256 txhash = out.tx->GetHash();
- itemOutput->setText(COLUMN_TXHASH, txhash.GetHex().c_str());
+ itemOutput->setText(COLUMN_TXHASH, QString::fromStdString(txhash.GetHex()));
// vout index
itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(out.i));
diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h
index 4f7422642f..a6f239a898 100644
--- a/src/qt/coincontroldialog.h
+++ b/src/qt/coincontroldialog.h
@@ -14,13 +14,15 @@
#include <QString>
#include <QTreeWidgetItem>
-namespace Ui {
- class CoinControlDialog;
-}
class WalletModel;
+
class CCoinControl;
class CTxMemPool;
+namespace Ui {
+ class CoinControlDialog;
+}
+
class CoinControlDialog : public QDialog
{
Q_OBJECT
diff --git a/src/qt/forms/addressbookpage.ui b/src/qt/forms/addressbookpage.ui
index f40c446050..52fdc6ef06 100644
--- a/src/qt/forms/addressbookpage.ui
+++ b/src/qt/forms/addressbookpage.ui
@@ -63,6 +63,9 @@
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/add</normaloff>:/icons/add</iconset>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
</widget>
</item>
<item>
@@ -77,6 +80,9 @@
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/editcopy</normaloff>:/icons/editcopy</iconset>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
</widget>
</item>
<item>
@@ -91,6 +97,9 @@
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/remove</normaloff>:/icons/remove</iconset>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
</widget>
</item>
<item>
@@ -118,6 +127,9 @@
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/export</normaloff>:/icons/export</iconset>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
</widget>
</item>
<item>
@@ -131,6 +143,9 @@
<property name="text">
<string>C&amp;lose</string>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
</widget>
</item>
</layout>
diff --git a/src/qt/forms/coincontroldialog.ui b/src/qt/forms/coincontroldialog.ui
index 67ea3a9d8c..cbe58fec65 100644
--- a/src/qt/forms/coincontroldialog.ui
+++ b/src/qt/forms/coincontroldialog.ui
@@ -363,6 +363,9 @@
<property name="text">
<string>(un)select all</string>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
</widget>
</item>
<item>
diff --git a/src/qt/forms/openuridialog.ui b/src/qt/forms/openuridialog.ui
index cd09ed0246..7fce858bd2 100644
--- a/src/qt/forms/openuridialog.ui
+++ b/src/qt/forms/openuridialog.ui
@@ -31,8 +31,7 @@
</widget>
</item>
<item>
- <widget class="QValidatedLineEdit" name="uriEdit">
- </widget>
+ <widget class="QValidatedLineEdit" name="uriEdit"/>
</item>
<item>
<widget class="QPushButton" name="selectFileButton">
@@ -42,6 +41,9 @@
<property name="text">
<string notr="true">…</string>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
</widget>
</item>
</layout>
diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui
index 47ed4c8bc6..9d094c1a73 100644
--- a/src/qt/forms/optionsdialog.ui
+++ b/src/qt/forms/optionsdialog.ui
@@ -609,6 +609,12 @@
<property name="text">
<string>&amp;OK</string>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item>
diff --git a/src/qt/forms/receivecoinsdialog.ui b/src/qt/forms/receivecoinsdialog.ui
index e1a0a28f81..03fcb2fb50 100644
--- a/src/qt/forms/receivecoinsdialog.ui
+++ b/src/qt/forms/receivecoinsdialog.ui
@@ -12,192 +12,189 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1">
<item>
- <widget class="QFrame" name="frame2">
- <property name="sizePolicy">
+ <widget class="QFrame" name="frame2">
+ <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
</sizepolicy>
- </property>
- <property name="frameShape">
+ </property>
+ <property name="frameShape">
<enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
+ </property>
+ <property name="frameShadow">
<enum>QFrame::Sunken</enum>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <item>
- <layout class="QGridLayout" name="gridLayout">
- <item row="7" column="2">
- <widget class="QCheckBox" name="reuseAddress">
- <property name="toolTip">
- <string>Reuse one of the previously used receiving addresses. Reusing addresses has security and privacy issues. Do not use this unless re-generating a payment request made before.</string>
- </property>
- <property name="text">
- <string>R&amp;euse an existing receiving address (not recommended)</string>
- </property>
- </widget>
- </item>
- <item row="7" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="6" column="0">
- <widget class="QLabel" name="label_3">
- <property name="toolTip">
- <string>An optional message to attach to the payment request, which will be displayed when the request is opened. Note: The message will not be sent with the payment over the Bitcoin network.</string>
- </property>
- <property name="text">
- <string>&amp;Message:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>reqMessage</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="2">
- <widget class="QLineEdit" name="reqLabel">
- <property name="toolTip">
- <string>An optional label to associate with the new receiving address.</string>
- </property>
- </widget>
- </item>
- <item row="6" column="2">
- <widget class="QLineEdit" name="reqMessage">
- <property name="toolTip">
- <string>An optional message to attach to the payment request, which will be displayed when the request is opened. Note: The message will not be sent with the payment over the Bitcoin network.</string>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Use this form to request payments. All fields are &lt;b&gt;optional&lt;/b&gt;.</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_2">
- <property name="toolTip">
- <string>An optional label to associate with the new receiving address.</string>
- </property>
- <property name="text">
- <string>&amp;Label:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>reqLabel</cstring>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="label">
- <property name="toolTip">
- <string>An optional amount to request. Leave this empty or zero to not request a specific amount.</string>
- </property>
- <property name="text">
- <string>&amp;Amount:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>reqAmount</cstring>
- </property>
- </widget>
- </item>
- <item row="5" column="2">
- <widget class="BitcoinAmountField" name="reqAmount">
- <property name="minimumSize">
- <size>
- <width>80</width>
- <height>0</height>
- </size>
- </property>
- <property name="toolTip">
- <string>An optional amount to request. Leave this empty or zero to not request a specific amount.</string>
- </property>
- </widget>
- </item>
- <item row="8" column="2">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QPushButton" name="receiveButton">
- <property name="minimumSize">
- <size>
- <width>150</width>
- <height>0</height>
- </size>
- </property>
- <property name="text">
- <string>&amp;Request payment</string>
- </property>
- <property name="icon">
- <iconset resource="../bitcoin.qrc">
- <normaloff>:/icons/receiving_addresses</normaloff>:/icons/receiving_addresses</iconset>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="clearButton">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Clear all fields of the form.</string>
- </property>
- <property name="text">
- <string>Clear</string>
- </property>
- <property name="icon">
- <iconset resource="../bitcoin.qrc">
- <normaloff>:/icons/remove</normaloff>:/icons/remove</iconset>
- </property>
- <property name="autoRepeatDelay">
- <number>300</number>
- </property>
- <property name="autoDefault">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item row="8" column="0">
- <widget class="QLabel" name="label_7">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="7" column="2">
+ <widget class="QCheckBox" name="reuseAddress">
+ <property name="toolTip">
+ <string>Reuse one of the previously used receiving addresses. Reusing addresses has security and privacy issues. Do not use this unless re-generating a payment request made before.</string>
+ </property>
+ <property name="text">
+ <string>R&amp;euse an existing receiving address (not recommended)</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="toolTip">
+ <string>An optional message to attach to the payment request, which will be displayed when the request is opened. Note: The message will not be sent with the payment over the Bitcoin network.</string>
+ </property>
+ <property name="text">
+ <string>&amp;Message:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="buddy">
+ <cstring>reqMessage</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2">
+ <widget class="QLineEdit" name="reqLabel">
+ <property name="toolTip">
+ <string>An optional label to associate with the new receiving address.</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="2">
+ <widget class="QLineEdit" name="reqMessage">
+ <property name="toolTip">
+ <string>An optional message to attach to the payment request, which will be displayed when the request is opened. Note: The message will not be sent with the payment over the Bitcoin network.</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Use this form to request payments. All fields are &lt;b&gt;optional&lt;/b&gt;.</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="toolTip">
+ <string>An optional label to associate with the new receiving address.</string>
+ </property>
+ <property name="text">
+ <string>&amp;Label:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="buddy">
+ <cstring>reqLabel</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="label">
+ <property name="toolTip">
+ <string>An optional amount to request. Leave this empty or zero to not request a specific amount.</string>
+ </property>
+ <property name="text">
+ <string>&amp;Amount:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="buddy">
+ <cstring>reqAmount</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="2">
+ <widget class="BitcoinAmountField" name="reqAmount">
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>An optional amount to request. Leave this empty or zero to not request a specific amount.</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="2">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="receiveButton">
+ <property name="minimumSize">
+ <size>
+ <width>150</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>&amp;Request payment</string>
+ </property>
+ <property name="icon">
+ <iconset resource="../bitcoin.qrc">
+ <normaloff>:/icons/receiving_addresses</normaloff>:/icons/receiving_addresses</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="clearButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Clear all fields of the form.</string>
+ </property>
+ <property name="text">
+ <string>Clear</string>
+ </property>
+ <property name="icon">
+ <iconset resource="../bitcoin.qrc">
+ <normaloff>:/icons/remove</normaloff>:/icons/remove</iconset>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="8" column="0">
+ <widget class="QLabel" name="label_7">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
</item>
<item>
<spacer name="verticalSpacer_2">
@@ -257,36 +254,42 @@
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="showRequestButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="toolTip">
<string>Show the selected request (does the same as double clicking an entry)</string>
</property>
<property name="text">
<string>Show</string>
</property>
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/edit</normaloff>:/icons/edit</iconset>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeRequestButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="toolTip">
<string>Remove the selected entries from the list</string>
</property>
<property name="text">
<string>Remove</string>
</property>
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/remove</normaloff>:/icons/remove</iconset>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
</widget>
</item>
<item>
@@ -314,6 +317,7 @@
<class>BitcoinAmountField</class>
<extends>QLineEdit</extends>
<header>bitcoinamountfield.h</header>
+ <container>1</container>
</customwidget>
</customwidgets>
<tabstops>
diff --git a/src/qt/forms/receiverequestdialog.ui b/src/qt/forms/receiverequestdialog.ui
index 85928c9be5..1e484dd9a0 100644
--- a/src/qt/forms/receiverequestdialog.ui
+++ b/src/qt/forms/receiverequestdialog.ui
@@ -74,6 +74,9 @@
<property name="text">
<string>Copy &amp;URI</string>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
</widget>
</item>
<item>
@@ -81,6 +84,9 @@
<property name="text">
<string>Copy &amp;Address</string>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
</widget>
</item>
<item>
@@ -88,6 +94,9 @@
<property name="text">
<string>&amp;Save Image...</string>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
</widget>
</item>
<item>
diff --git a/src/qt/forms/rpcconsole.ui b/src/qt/forms/rpcconsole.ui
index b9b90aa846..7f28209c9a 100644
--- a/src/qt/forms/rpcconsole.ui
+++ b/src/qt/forms/rpcconsole.ui
@@ -484,6 +484,9 @@
<property name="text">
<string>&amp;Clear</string>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
</widget>
</item>
</layout>
diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui
index a631b04670..dce7f4ce4c 100644
--- a/src/qt/forms/sendcoinsdialog.ui
+++ b/src/qt/forms/sendcoinsdialog.ui
@@ -109,6 +109,9 @@
<property name="text">
<string>Inputs...</string>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
</widget>
</item>
<item>
@@ -674,6 +677,9 @@
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/send</normaloff>:/icons/send</iconset>
</property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
<property name="default">
<bool>true</bool>
</property>
@@ -697,9 +703,6 @@
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/remove</normaloff>:/icons/remove</iconset>
</property>
- <property name="autoRepeatDelay">
- <number>300</number>
- </property>
<property name="autoDefault">
<bool>false</bool>
</property>
diff --git a/src/qt/forms/signverifymessagedialog.ui b/src/qt/forms/signverifymessagedialog.ui
index 53573ec821..40b2da3228 100644
--- a/src/qt/forms/signverifymessagedialog.ui
+++ b/src/qt/forms/signverifymessagedialog.ui
@@ -19,6 +19,9 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
<widget class="QWidget" name="tabSignMessage">
<attribute name="title">
<string>&amp;Sign Message</string>
diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h
index 5ae4bc833d..4c8a67b663 100644
--- a/src/qt/guiconstants.h
+++ b/src/qt/guiconstants.h
@@ -23,6 +23,12 @@ static const int STATUSBAR_ICONSIZE = 16;
#define COLOR_NEGATIVE QColor(255, 0, 0)
/* Transaction list -- bare address (without label) */
#define COLOR_BAREADDRESS QColor(140, 140, 140)
+/* Transaction list -- TX status decoration - open until date */
+#define COLOR_TX_STATUS_OPENUNTILDATE QColor(64, 64, 255)
+/* Transaction list -- TX status decoration - offline */
+#define COLOR_TX_STATUS_OFFLINE QColor(192, 192, 192)
+/* Transaction list -- TX status decoration - default color */
+#define COLOR_BLACK QColor(0, 0, 0)
/* Tooltips longer than this (in characters) are converted into rich text,
so that they can be word-wrapped.
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index 304177ee11..fc22871a6b 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -13,6 +13,8 @@
#include "init.h"
#include "main.h"
#include "protocol.h"
+#include "script/script.h"
+#include "script/standard.h"
#include "util.h"
#ifdef WIN32
@@ -222,7 +224,7 @@ QString formatBitcoinURI(const SendCoinsRecipient &info)
bool isDust(const QString& address, qint64 amount)
{
CTxDestination dest = CBitcoinAddress(address.toStdString()).Get();
- CScript script; script.SetDestination(dest);
+ CScript script = GetScriptForDestination(dest);
CTxOut txOut(amount, script);
return txOut.IsDust(::minRelayTxFee);
}
diff --git a/src/qt/intro.h b/src/qt/intro.h
index 295a75562f..e3e396d369 100644
--- a/src/qt/intro.h
+++ b/src/qt/intro.h
@@ -12,7 +12,7 @@
class FreespaceChecker;
namespace Ui {
-class Intro;
+ class Intro;
}
/** Introduction screen (pre-GUI startup).
diff --git a/src/qt/openuridialog.h b/src/qt/openuridialog.h
index 28da7d6d9d..67a5f167d1 100644
--- a/src/qt/openuridialog.h
+++ b/src/qt/openuridialog.h
@@ -8,7 +8,7 @@
#include <QDialog>
namespace Ui {
-class OpenURIDialog;
+ class OpenURIDialog;
}
class OpenURIDialog : public QDialog
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index c775a7f8d6..279467129f 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -17,11 +17,13 @@
#include "main.h" // for MAX_SCRIPTCHECK_THREADS
#include "netbase.h"
#include "txdb.h" // for -dbcache defaults
+
#ifdef ENABLE_WALLET
#include "wallet.h" // for CWallet::minTxFee
#endif
#include <boost/thread.hpp>
+
#include <QDir>
#include <QIntValidator>
#include <QLocale>
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 99928ebe4d..bd747faeb6 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -15,6 +15,7 @@
#include "main.h"
#include "net.h"
#include "txdb.h" // for -dbcache defaults
+
#ifdef ENABLE_WALLET
#include "wallet.h"
#include "walletdb.h"
diff --git a/src/qt/paymentrequestplus.cpp b/src/qt/paymentrequestplus.cpp
index acce42e203..7b7de49831 100644
--- a/src/qt/paymentrequestplus.cpp
+++ b/src/qt/paymentrequestplus.cpp
@@ -13,6 +13,7 @@
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
+
#include <QDateTime>
#include <QDebug>
#include <QSslCertificate>
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp
index f6a4b599de..cc4478f39f 100644
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -10,6 +10,7 @@
#include "optionsmodel.h"
#include "base58.h"
+#include "chainparams.h"
#include "ui_interface.h"
#include "util.h"
#include "wallet.h"
@@ -200,8 +201,11 @@ bool PaymentServer::ipcParseCommandLine(int argc, char* argv[])
{
CBitcoinAddress address(r.address.toStdString());
- SelectParams(CBaseChainParams::MAIN);
- if (!address.IsValid())
+ if (address.IsValid(Params(CBaseChainParams::MAIN)))
+ {
+ SelectParams(CBaseChainParams::MAIN);
+ }
+ else if (address.IsValid(Params(CBaseChainParams::TESTNET)))
{
SelectParams(CBaseChainParams::TESTNET);
}
@@ -605,7 +609,7 @@ void PaymentServer::fetchPaymentACK(CWallet* wallet, SendCoinsRecipient recipien
std::string strAccount = account.toStdString();
set<CTxDestination> refundAddresses = wallet->GetAccountAddresses(strAccount);
if (!refundAddresses.empty()) {
- CScript s; s.SetDestination(*refundAddresses.begin());
+ CScript s = GetScriptForDestination(*refundAddresses.begin());
payments::Output* refund_to = payment.add_refund_to();
refund_to->set_script(&s[0], s.size());
}
@@ -616,7 +620,7 @@ void PaymentServer::fetchPaymentACK(CWallet* wallet, SendCoinsRecipient recipien
CKeyID keyID = newKey.GetID();
wallet->SetAddressBook(keyID, strAccount, "refund");
- CScript s; s.SetDestination(keyID);
+ CScript s = GetScriptForDestination(keyID);
payments::Output* refund_to = payment.add_refund_to();
refund_to->set_script(&s[0], s.size());
}
diff --git a/src/qt/receivecoinsdialog.h b/src/qt/receivecoinsdialog.h
index 663cb157a4..7a7e38e25e 100644
--- a/src/qt/receivecoinsdialog.h
+++ b/src/qt/receivecoinsdialog.h
@@ -5,6 +5,8 @@
#ifndef RECEIVECOINSDIALOG_H
#define RECEIVECOINSDIALOG_H
+#include "guiutil.h"
+
#include <QDialog>
#include <QHeaderView>
#include <QItemSelection>
@@ -13,13 +15,12 @@
#include <QPoint>
#include <QVariant>
-#include "guiutil.h"
+class OptionsModel;
+class WalletModel;
namespace Ui {
class ReceiveCoinsDialog;
}
-class OptionsModel;
-class WalletModel;
QT_BEGIN_NAMESPACE
class QModelIndex;
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 11089b2497..8129353d4b 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -16,10 +16,12 @@
#include "util.h"
#include "json/json_spirit_value.h"
+
+#include <openssl/crypto.h>
+
#ifdef ENABLE_WALLET
#include <db_cxx.h>
#endif
-#include <openssl/crypto.h>
#include <QKeyEvent>
#include <QScrollBar>
diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h
index 64bb5c29b3..1ffff92758 100644
--- a/src/qt/rpcconsole.h
+++ b/src/qt/rpcconsole.h
@@ -14,14 +14,14 @@
class ClientModel;
-QT_BEGIN_NAMESPACE
-class QItemSelection;
-QT_END_NAMESPACE
-
namespace Ui {
class RPCConsole;
}
+QT_BEGIN_NAMESPACE
+class QItemSelection;
+QT_END_NAMESPACE
+
/** Local Bitcoin RPC console. */
class RPCConsole: public QDialog
{
diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h
index 6cdf4a00c8..a090fa42d5 100644
--- a/src/qt/sendcoinsdialog.h
+++ b/src/qt/sendcoinsdialog.h
@@ -14,14 +14,14 @@ class OptionsModel;
class SendCoinsEntry;
class SendCoinsRecipient;
-QT_BEGIN_NAMESPACE
-class QUrl;
-QT_END_NAMESPACE
-
namespace Ui {
class SendCoinsDialog;
}
+QT_BEGIN_NAMESPACE
+class QUrl;
+QT_END_NAMESPACE
+
/** Dialog for sending bitcoins */
class SendCoinsDialog : public QDialog
{
diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp
index 5dd110b36a..4fe610794f 100644
--- a/src/qt/splashscreen.cpp
+++ b/src/qt/splashscreen.cpp
@@ -4,23 +4,24 @@
#include "splashscreen.h"
-#include "version.h"
#include "clientversion.h"
#include "init.h"
#include "ui_interface.h"
#include "util.h"
+#include "version.h"
+
#ifdef ENABLE_WALLET
#include "wallet.h"
#endif
#include <QApplication>
+#include <QCloseEvent>
+#include <QDesktopWidget>
#include <QPainter>
-SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTestNet) :
- QSplashScreen(pixmap, f)
+SplashScreen::SplashScreen(Qt::WindowFlags f, bool isTestNet) :
+ QWidget(0, f), curAlignment(0)
{
- setAutoFillBackground(true);
-
// set reference point, paddings
int paddingRight = 50;
int paddingTop = 50;
@@ -38,15 +39,14 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTest
QString font = "Arial";
// load the bitmap for writing some text over it
- QPixmap newPixmap;
if(isTestNet) {
- newPixmap = QPixmap(":/images/splash_testnet");
+ pixmap = QPixmap(":/images/splash_testnet");
}
else {
- newPixmap = QPixmap(":/images/splash");
+ pixmap = QPixmap(":/images/splash");
}
- QPainter pixPaint(&newPixmap);
+ QPainter pixPaint(&pixmap);
pixPaint.setPen(QColor(100,100,100));
// check font size and drawing with
@@ -61,7 +61,7 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTest
pixPaint.setFont(QFont(font, 33*fontFactor));
fm = pixPaint.fontMetrics();
titleTextWidth = fm.width(titleText);
- pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop,titleText);
+ pixPaint.drawText(pixmap.width()-titleTextWidth-paddingRight,paddingTop,titleText);
pixPaint.setFont(QFont(font, 15*fontFactor));
@@ -72,11 +72,11 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTest
pixPaint.setFont(QFont(font, 10*fontFactor));
titleVersionVSpace -= 5;
}
- pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);
+ pixPaint.drawText(pixmap.width()-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);
// draw copyright stuff
pixPaint.setFont(QFont(font, 10*fontFactor));
- pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText);
+ pixPaint.drawText(pixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText);
// draw testnet string if testnet is on
if(isTestNet) {
@@ -85,12 +85,22 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTest
pixPaint.setFont(boldFont);
fm = pixPaint.fontMetrics();
int testnetAddTextWidth = fm.width(testnetAddText);
- pixPaint.drawText(newPixmap.width()-testnetAddTextWidth-10,15,testnetAddText);
+ pixPaint.drawText(pixmap.width()-testnetAddTextWidth-10,15,testnetAddText);
}
pixPaint.end();
- this->setPixmap(newPixmap);
+ // Set window title
+ if(isTestNet)
+ setWindowTitle(titleText + " " + testnetAddText);
+ else
+ setWindowTitle(titleText);
+
+ // Resize window and move to center of desktop, disallow resizing
+ QRect r(QPoint(), pixmap.size());
+ resize(r.size());
+ setFixedSize(r.size());
+ move(QApplication::desktop()->screenGeometry().center() - r.center());
subscribeToCoreSignals();
}
@@ -102,7 +112,8 @@ SplashScreen::~SplashScreen()
void SplashScreen::slotFinish(QWidget *mainWin)
{
- finish(mainWin);
+ Q_UNUSED(mainWin);
+ hide();
}
static void InitMessage(SplashScreen *splash, const std::string &message)
@@ -146,3 +157,25 @@ void SplashScreen::unsubscribeFromCoreSignals()
pwalletMain->ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
#endif
}
+
+void SplashScreen::showMessage(const QString &message, int alignment, const QColor &color)
+{
+ curMessage = message;
+ curAlignment = alignment;
+ curColor = color;
+ update();
+}
+
+void SplashScreen::paintEvent(QPaintEvent *event)
+{
+ QPainter painter(this);
+ painter.drawPixmap(0, 0, pixmap);
+ QRect r = rect().adjusted(5, 5, -5, -5);
+ painter.setPen(curColor);
+ painter.drawText(r, curAlignment, curMessage);
+}
+
+void SplashScreen::closeEvent(QCloseEvent *event)
+{
+ event->ignore();
+}
diff --git a/src/qt/splashscreen.h b/src/qt/splashscreen.h
index d79038d81d..89c21e6457 100644
--- a/src/qt/splashscreen.h
+++ b/src/qt/splashscreen.h
@@ -7,25 +7,41 @@
#include <QSplashScreen>
-/** class for the splashscreen with information of the running client
+/** Class for the splashscreen with information of the running client.
+ *
+ * @note this is intentionally not a QSplashScreen. Bitcoin Core initialization
+ * can take a long time, and in that case a progress window that cannot be
+ * moved around and minimized has turned out to be frustrating to the user.
*/
-class SplashScreen : public QSplashScreen
+class SplashScreen : public QWidget
{
Q_OBJECT
public:
- explicit SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTestNet);
+ explicit SplashScreen(Qt::WindowFlags f, bool isTestNet);
~SplashScreen();
+protected:
+ void paintEvent(QPaintEvent *event);
+ void closeEvent(QCloseEvent *event);
+
public slots:
/** Slot to call finish() method as it's not defined as slot */
void slotFinish(QWidget *mainWin);
+ /** Show message and progress */
+ void showMessage(const QString &message, int alignment, const QColor &color);
+
private:
/** Connect core signals to splash screen */
void subscribeToCoreSignals();
/** Disconnect core signals to splash screen */
void unsubscribeFromCoreSignals();
+
+ QPixmap pixmap;
+ QString curMessage;
+ QColor curColor;
+ int curAlignment;
};
#endif // SPLASHSCREEN_H
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 727b8dc66d..4923718341 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -6,13 +6,13 @@
#include "bitcoinunits.h"
#include "guiutil.h"
+#include "paymentserver.h"
+#include "transactionrecord.h"
#include "base58.h"
#include "db.h"
#include "main.h"
-#include "paymentserver.h"
#include "script/script.h"
-#include "transactionrecord.h"
#include "timedata.h"
#include "ui_interface.h"
#include "util.h"
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index 734c7afc4e..2b869b4ea5 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -209,10 +209,7 @@ public:
}
return rec;
}
- else
- {
- return 0;
- }
+ return 0;
}
QString describe(TransactionRecord *rec, int unit)
@@ -225,7 +222,7 @@ public:
return TransactionDesc::toHTML(wallet, mi->second, rec, unit);
}
}
- return QString("");
+ return QString();
}
};
@@ -330,10 +327,7 @@ QString TransactionTableModel::formatTxDate(const TransactionRecord *wtx) const
{
return GUIUtil::dateTimeStr(wtx->time);
}
- else
- {
- return QString();
- }
+ return QString();
}
/* Look up address in address book, if found return label (address)
@@ -345,11 +339,11 @@ QString TransactionTableModel::lookupAddress(const std::string &address, bool to
QString description;
if(!label.isEmpty())
{
- description += label + QString(" ");
+ description += label;
}
if(label.isEmpty() || tooltip)
{
- description += QString("(") + QString::fromStdString(address) + QString(")");
+ description += QString(" (") + QString::fromStdString(address) + QString(")");
}
return description;
}
@@ -389,7 +383,6 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx
default:
return QIcon(":/icons/tx_inout");
}
- return QVariant();
}
QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
@@ -456,9 +449,9 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
{
case TransactionStatus::OpenUntilBlock:
case TransactionStatus::OpenUntilDate:
- return QColor(64,64,255);
+ return COLOR_TX_STATUS_OPENUNTILDATE;
case TransactionStatus::Offline:
- return QColor(192,192,192);
+ return COLOR_TX_STATUS_OFFLINE;
case TransactionStatus::Unconfirmed:
return QIcon(":/icons/transaction_0");
case TransactionStatus::Confirming:
@@ -482,8 +475,9 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
case TransactionStatus::MaturesWarning:
case TransactionStatus::NotAccepted:
return QIcon(":/icons/transaction_0");
+ default:
+ return COLOR_BLACK;
}
- return QColor(0,0,0);
}
QVariant TransactionTableModel::txWatchonlyDecoration(const TransactionRecord *wtx) const
@@ -646,10 +640,7 @@ QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex
{
return createIndex(row, column, priv->index(row));
}
- else
- {
- return QModelIndex();
- }
+ return QModelIndex();
}
void TransactionTableModel::updateDisplayUnit()
diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp
index 7df9d1bc2d..84f88dff5a 100644
--- a/src/qt/utilitydialog.cpp
+++ b/src/qt/utilitydialog.cpp
@@ -15,6 +15,7 @@
#include <stdio.h>
+#include <QCloseEvent>
#include <QLabel>
#include <QRegExp>
#include <QVBoxLayout>
@@ -106,18 +107,26 @@ void HelpMessageDialog::on_okButton_accepted()
/** "Shutdown" window */
+ShutdownWindow::ShutdownWindow(QWidget *parent, Qt::WindowFlags f):
+ QWidget(parent, f)
+{
+ QVBoxLayout *layout = new QVBoxLayout();
+ layout->addWidget(new QLabel(
+ tr("Bitcoin Core is shutting down...") + "<br /><br />" +
+ tr("Do not shut down the computer until this window disappears.")));
+ setLayout(layout);
+}
+
void ShutdownWindow::showShutdownWindow(BitcoinGUI *window)
{
if (!window)
return;
// Show a simple window indicating shutdown status
- QWidget *shutdownWindow = new QWidget();
- QVBoxLayout *layout = new QVBoxLayout();
- layout->addWidget(new QLabel(
- tr("Bitcoin Core is shutting down...") + "<br /><br />" +
- tr("Do not shut down the computer until this window disappears.")));
- shutdownWindow->setLayout(layout);
+ QWidget *shutdownWindow = new ShutdownWindow();
+ // We don't hold a direct pointer to the shutdown window after creation, so use
+ // Qt::WA_DeleteOnClose to make sure that the window will be deleted eventually.
+ shutdownWindow->setAttribute(Qt::WA_DeleteOnClose);
shutdownWindow->setWindowTitle(window->windowTitle());
// Center shutdown window at where main window was
@@ -125,3 +134,8 @@ void ShutdownWindow::showShutdownWindow(BitcoinGUI *window)
shutdownWindow->move(global.x() - shutdownWindow->width() / 2, global.y() - shutdownWindow->height() / 2);
shutdownWindow->show();
}
+
+void ShutdownWindow::closeEvent(QCloseEvent *event)
+{
+ event->ignore();
+}
diff --git a/src/qt/utilitydialog.h b/src/qt/utilitydialog.h
index 154bb70b8b..ae5045cca9 100644
--- a/src/qt/utilitydialog.h
+++ b/src/qt/utilitydialog.h
@@ -37,12 +37,16 @@ private slots:
/** "Shutdown" window */
-class ShutdownWindow : public QObject
+class ShutdownWindow : public QWidget
{
Q_OBJECT
public:
+ ShutdownWindow(QWidget *parent=0, Qt::WindowFlags f=0);
static void showShutdownWindow(BitcoinGUI *window);
+
+protected:
+ void closeEvent(QCloseEvent *event);
};
#endif // UTILITYDIALOG_H
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 530c46cdb4..ed90914ba7 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -241,8 +241,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
setAddress.insert(rcp.address);
++nAddresses;
- CScript scriptPubKey;
- scriptPubKey.SetDestination(CBitcoinAddress(rcp.address.toStdString()).Get());
+ CScript scriptPubKey = GetScriptForDestination(CBitcoinAddress(rcp.address.toStdString()).Get());
vecSend.push_back(std::pair<CScript, int64_t>(scriptPubKey, rcp.amount));
total += rcp.amount;
@@ -622,7 +621,7 @@ void WalletModel::listCoins(std::map<QString, std::vector<COutput> >& mapCoins)
CTxDestination address;
if(!out.fSpendable || !ExtractDestination(cout.tx->vout[cout.i].scriptPubKey, address))
continue;
- mapCoins[CBitcoinAddress(address).ToString().c_str()].push_back(out);
+ mapCoins[QString::fromStdString(CBitcoinAddress(address).ToString())].push_back(out);
}
}
diff --git a/src/random.cpp b/src/random.cpp
index 22c942acc0..998e7dfb08 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -8,14 +8,16 @@
#ifdef WIN32
#include "compat.h" // for Windows API
#endif
-#include "serialize.h" // for begin_ptr(vec)
-#include "util.h" // for LogPrint()
+#include "serialize.h" // for begin_ptr(vec)
+#include "util.h" // for LogPrint()
#include "utilstrencodings.h" // for GetTime()
+#include <limits>
+
#ifndef WIN32
#include <sys/time.h>
#endif
-#include <limits>
+
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/rand.h>
@@ -54,28 +56,25 @@ void RandAddSeedPerfmon()
#ifdef WIN32
// Don't need this on Linux, OpenSSL automatically uses /dev/urandom
// Seed with the entire set of perfmon data
- std::vector <unsigned char> vData(250000,0);
+ std::vector<unsigned char> vData(250000, 0);
long ret = 0;
unsigned long nSize = 0;
const size_t nMaxSize = 10000000; // Bail out at more than 10MB of performance data
- while (true)
- {
+ while (true) {
nSize = vData.size();
ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, begin_ptr(vData), &nSize);
if (ret != ERROR_MORE_DATA || vData.size() >= nMaxSize)
break;
- vData.resize(std::max((vData.size()*3)/2, nMaxSize)); // Grow size of buffer exponentially
+ vData.resize(std::max((vData.size() * 3) / 2, nMaxSize)); // Grow size of buffer exponentially
}
RegCloseKey(HKEY_PERFORMANCE_DATA);
- if (ret == ERROR_SUCCESS)
- {
- RAND_add(begin_ptr(vData), nSize, nSize/100.0);
+ if (ret == ERROR_SUCCESS) {
+ RAND_add(begin_ptr(vData), nSize, nSize / 100.0);
OPENSSL_cleanse(begin_ptr(vData), nSize);
LogPrint("rand", "%s: %lu bytes\n", __func__, nSize);
} else {
static bool warned = false; // Warn only once
- if (!warned)
- {
+ if (!warned) {
LogPrintf("%s: Warning: RegQueryValueExA(HKEY_PERFORMANCE_DATA) failed with code %i\n", __func__, ret);
warned = true;
}
@@ -83,7 +82,7 @@ void RandAddSeedPerfmon()
#endif
}
-bool GetRandBytes(unsigned char *buf, int num)
+bool GetRandBytes(unsigned char* buf, int num)
{
if (RAND_bytes(buf, num) != 1) {
LogPrintf("%s: OpenSSL RAND_bytes() failed with error: %s\n", __func__, ERR_error_string(ERR_get_error(), NULL));
@@ -124,18 +123,17 @@ 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)
- {
+ if (fDeterministic) {
insecure_rand_Rz = insecure_rand_Rw = 11;
} else {
uint32_t tmp;
do {
GetRandBytes((unsigned char*)&tmp, 4);
- } while(tmp == 0 || tmp == 0x9068ffffU);
+ } while (tmp == 0 || tmp == 0x9068ffffU);
insecure_rand_Rz = tmp;
do {
GetRandBytes((unsigned char*)&tmp, 4);
- } while(tmp == 0 || tmp == 0x464fffffU);
+ } while (tmp == 0 || tmp == 0x464fffffU);
insecure_rand_Rw = tmp;
}
}
diff --git a/src/random.h b/src/random.h
index a599b08478..161ebe8986 100644
--- a/src/random.h
+++ b/src/random.h
@@ -19,7 +19,7 @@ void RandAddSeedPerfmon();
/**
* Functions to gather random data via the OpenSSL PRNG
*/
-bool GetRandBytes(unsigned char *buf, int num);
+bool GetRandBytes(unsigned char* buf, int num);
uint64_t GetRand(uint64_t nMax);
int GetRandInt(int nMax);
uint256 GetRandHash();
diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp
index a0921453cc..a9c491cede 100644
--- a/src/rpcclient.cpp
+++ b/src/rpcclient.cpp
@@ -3,14 +3,13 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <set>
#include "rpcclient.h"
#include "rpcprotocol.h"
#include "util.h"
#include "ui_interface.h"
-#include "chainparams.h" // for Params().RPCPort()
+#include <set>
#include <stdint.h>
using namespace std;
@@ -67,6 +66,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "listunspent", 1 },
{ "listunspent", 2 },
{ "getblock", 1 },
+ { "gettransaction", 1 },
{ "getrawtransaction", 1 },
{ "createrawtransaction", 0 },
{ "createrawtransaction", 1 },
diff --git a/src/rpcclient.h b/src/rpcclient.h
index 1233ea3875..307aa2aab8 100644
--- a/src/rpcclient.h
+++ b/src/rpcclient.h
@@ -10,6 +10,6 @@
#include "json/json_spirit_utils.h"
#include "json/json_spirit_writer_template.h"
-json_spirit::Array RPCConvertValues(const std::string &strMethod, const std::vector<std::string> &strParams);
+json_spirit::Array RPCConvertValues(const std::string& strMethod, const std::vector<std::string>& strParams);
#endif // _BITCOINRPC_CLIENT_H_
diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp
index c286626fd3..1ac7024550 100644
--- a/src/rpcdump.cpp
+++ b/src/rpcdump.cpp
@@ -6,9 +6,11 @@
#include "rpcserver.h"
#include "init.h"
#include "main.h"
+#include "script/script.h"
+#include "script/standard.h"
#include "sync.h"
-#include "utiltime.h"
#include "util.h"
+#include "utiltime.h"
#include "wallet.h"
#include <fstream>
@@ -16,6 +18,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
+
#include "json/json_spirit_value.h"
using namespace json_spirit;
@@ -160,7 +163,7 @@ Value importaddress(const Array& params, bool fHelp)
CBitcoinAddress address(params[0].get_str());
if (address.IsValid()) {
- script.SetDestination(address.Get());
+ script = GetScriptForDestination(address.Get());
} else if (IsHex(params[0].get_str())) {
std::vector<unsigned char> data(ParseHex(params[0].get_str()));
script = CScript(data.begin(), data.end());
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index e4a5bc4162..82eaf5d037 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -3,14 +3,14 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include "rpcserver.h"
#include "chainparams.h"
+#include "core_io.h"
#include "init.h"
#include "net.h"
#include "main.h"
#include "miner.h"
#include "pow.h"
-#include "core_io.h"
+#include "rpcserver.h"
#include "util.h"
#ifdef ENABLE_WALLET
#include "db.h"
@@ -553,7 +553,7 @@ Value submitblock(const Array& params, bool fHelp)
try {
ssBlock >> pblock;
}
- catch (std::exception &e) {
+ catch (const std::exception &) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
}
diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp
index bd992397b8..dd45eefd58 100644
--- a/src/rpcmisc.cpp
+++ b/src/rpcmisc.cpp
@@ -74,8 +74,8 @@ Value getinfo(const Array& params, bool fHelp)
GetProxy(NET_IPV4, proxy);
Object obj;
- obj.push_back(Pair("version", (int)CLIENT_VERSION));
- obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION));
+ obj.push_back(Pair("version", CLIENT_VERSION));
+ obj.push_back(Pair("protocolversion", PROTOCOL_VERSION));
#ifdef ENABLE_WALLET
if (pwalletMain) {
obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
@@ -250,8 +250,7 @@ CScript _createmultisig_redeemScript(const Array& params)
throw runtime_error(" Invalid public key: "+ks);
}
}
- CScript result;
- result.SetMultisig(nRequired, pubkeys);
+ CScript result = GetScriptForMultisig(nRequired, pubkeys);
if (result.size() > MAX_SCRIPT_ELEMENT_SIZE)
throw runtime_error(
diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp
index 2baa481c4e..fb159d96f6 100644
--- a/src/rpcnet.cpp
+++ b/src/rpcnet.cpp
@@ -11,8 +11,10 @@
#include "sync.h"
#include "timedata.h"
#include "util.h"
+#include "version.h"
#include <boost/foreach.hpp>
+
#include "json/json_spirit_value.h"
using namespace json_spirit;
@@ -94,8 +96,8 @@ Value getpeerinfo(const Array& params, bool fHelp)
" \"subver\": \"/Satoshi:0.8.5/\", (string) The string version\n"
" \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n"
" \"startingheight\": n, (numeric) The starting height (block) of the peer\n"
- " \"banscore\": n, (numeric) The ban score (stats.nMisbehavior)\n"
- " \"syncnode\" : true|false (booleamn) if sync node\n"
+ " \"banscore\": n, (numeric) The ban score\n"
+ " \"syncnode\": true|false (boolean) if sync node\n"
" }\n"
" ,...\n"
"]\n"
@@ -392,6 +394,8 @@ Value getnetworkinfo(const Array& params, bool fHelp)
Object obj;
obj.push_back(Pair("version", (int)CLIENT_VERSION));
+ obj.push_back(Pair("subversion",
+ FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>())));
obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION));
obj.push_back(Pair("localservices", strprintf("%016x", nLocalServices)));
obj.push_back(Pair("timeoffset", GetTimeOffset()));
diff --git a/src/rpcprotocol.cpp b/src/rpcprotocol.cpp
index 808b9bbd2a..c99d113bc3 100644
--- a/src/rpcprotocol.cpp
+++ b/src/rpcprotocol.cpp
@@ -5,8 +5,8 @@
#include "rpcprotocol.h"
-#include "util.h"
#include "tinyformat.h"
+#include "util.h"
#include "utilstrencodings.h"
#include "utiltime.h"
#include "version.h"
diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp
index b5551524be..dbb0966ae2 100644
--- a/src/rpcrawtransaction.cpp
+++ b/src/rpcrawtransaction.cpp
@@ -12,8 +12,8 @@
#include "net.h"
#include "rpcserver.h"
#include "script/script.h"
-#include "script/standard.h"
#include "script/sign.h"
+#include "script/standard.h"
#include "uint256.h"
#ifdef ENABLE_WALLET
#include "wallet.h"
@@ -25,10 +25,10 @@
#include "json/json_spirit_utils.h"
#include "json/json_spirit_value.h"
-using namespace std;
using namespace boost;
using namespace boost::assign;
using namespace json_spirit;
+using namespace std;
void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeHex)
{
@@ -366,8 +366,7 @@ Value createrawtransaction(const Array& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+s.name_);
setAddress.insert(address);
- CScript scriptPubKey;
- scriptPubKey.SetDestination(address.Get());
+ CScript scriptPubKey = GetScriptForDestination(address.Get());
int64_t nAmount = AmountFromValue(s.value_);
CTxOut out(nAmount, scriptPubKey);
@@ -543,7 +542,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
ssData >> tx;
txVariants.push_back(tx);
}
- catch (std::exception &e) {
+ catch (const std::exception &) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
}
}
@@ -568,7 +567,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
BOOST_FOREACH(const CTxIn& txin, mergedTx.vin) {
const uint256& prevHash = txin.prevout.hash;
CCoins coins;
- view.GetCoins(prevHash, coins); // this is certainly allowed to fail
+ view.AccessCoins(prevHash); // this is certainly allowed to fail
}
view.SetBackend(viewDummy); // switch back to avoid locking mempool for too long
@@ -672,12 +671,12 @@ Value signrawtransaction(const Array& params, bool fHelp)
// Sign what we can:
for (unsigned int i = 0; i < mergedTx.vin.size(); i++) {
CTxIn& txin = mergedTx.vin[i];
- CCoins coins;
- if (!view.GetCoins(txin.prevout.hash, coins) || !coins.IsAvailable(txin.prevout.n)) {
+ const CCoins* coins = view.AccessCoins(txin.prevout.hash);
+ if (coins == NULL || !coins->IsAvailable(txin.prevout.n)) {
fComplete = false;
continue;
}
- const CScript& prevPubKey = coins.vout[txin.prevout.n].scriptPubKey;
+ const CScript& prevPubKey = coins->vout[txin.prevout.n].scriptPubKey;
txin.scriptSig.clear();
// Only sign SIGHASH_SINGLE if there's a corresponding output:
@@ -688,7 +687,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
BOOST_FOREACH(const CMutableTransaction& txv, txVariants) {
txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig);
}
- if (!VerifyScript(txin.scriptSig, prevPubKey, mergedTx, i, STANDARD_SCRIPT_VERIFY_FLAGS, 0))
+ if (!VerifyScript(txin.scriptSig, prevPubKey, mergedTx, i, STANDARD_SCRIPT_VERIFY_FLAGS))
fComplete = false;
}
@@ -735,9 +734,9 @@ Value sendrawtransaction(const Array& params, bool fHelp)
fOverrideFees = params[1].get_bool();
CCoinsViewCache &view = *pcoinsTip;
- CCoins existingCoins;
+ const CCoins* existingCoins = view.AccessCoins(hashTx);
bool fHaveMempool = mempool.exists(hashTx);
- bool fHaveChain = view.GetCoins(hashTx, existingCoins) && existingCoins.nHeight < 1000000000;
+ bool fHaveChain = existingCoins && existingCoins->nHeight < 1000000000;
if (!fHaveMempool && !fHaveChain) {
// push to local node and sync with wallets
CValidationState state;
diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp
index c9133bd3d2..190de62282 100644
--- a/src/rpcserver.cpp
+++ b/src/rpcserver.cpp
@@ -628,7 +628,7 @@ void StartRPCThreads()
try {
vEndpoints.push_back(ParseEndpoint(addr, defaultPort));
}
- catch(boost::system::system_error &e)
+ catch(const boost::system::system_error &)
{
uiInterface.ThreadSafeMessageBox(
strprintf(_("Could not parse -rpcbind value %s as network address"), addr),
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index 100d6c2bd0..35637362a4 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -124,8 +124,7 @@ CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew=false)
// Check if the current key has been used
if (account.vchPubKey.IsValid())
{
- CScript scriptPubKey;
- scriptPubKey.SetDestination(account.vchPubKey.GetID());
+ CScript scriptPubKey = GetScriptForDestination(account.vchPubKey.GetID());
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin();
it != pwalletMain->mapWallet.end() && account.vchPubKey.IsValid();
++it)
@@ -472,10 +471,9 @@ Value getreceivedbyaddress(const Array& params, bool fHelp)
// Bitcoin address
CBitcoinAddress address = CBitcoinAddress(params[0].get_str());
- CScript scriptPubKey;
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
- scriptPubKey.SetDestination(address.Get());
+ CScript scriptPubKey = GetScriptForDestination(address.Get());
if (!IsMine(*pwalletMain,scriptPubKey))
return (double)0.0;
@@ -849,8 +847,7 @@ Value sendmany(const Array& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+s.name_);
setAddress.insert(address);
- CScript scriptPubKey;
- scriptPubKey.SetDestination(address.Get());
+ CScript scriptPubKey = GetScriptForDestination(address.Get());
int64_t nAmount = AmountFromValue(s.value_);
totalAmount += nAmount;
@@ -1490,7 +1487,7 @@ Value gettransaction(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
- "gettransaction \"txid\"\n"
+ "gettransaction \"txid\" ( includeWatchonly )\n"
"\nGet detailed information about in-wallet transaction <txid>\n"
"\nArguments:\n"
"1. \"txid\" (string, required) The transaction id\n"
@@ -1520,6 +1517,7 @@ Value gettransaction(const Array& params, bool fHelp)
"\nExamples:\n"
+ HelpExampleCli("gettransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
+ + HelpExampleCli("gettransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\" true")
+ HelpExampleRpc("gettransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
);
@@ -1536,7 +1534,7 @@ Value gettransaction(const Array& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id");
const CWalletTx& wtx = pwalletMain->mapWallet[hash];
- int64_t nCredit = wtx.GetCredit(filter);
+ int64_t nCredit = wtx.GetCredit(filter != 0);
int64_t nDebit = wtx.GetDebit(filter);
int64_t nNet = nCredit - nDebit;
int64_t nFee = (wtx.IsFromMe(filter) ? wtx.GetValueOut() - nDebit : 0);
diff --git a/src/script/compressor.cpp b/src/script/compressor.cpp
index 2f8df602bf..51a3cf6025 100644
--- a/src/script/compressor.cpp
+++ b/src/script/compressor.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "compressor.h"
diff --git a/src/script/compressor.h b/src/script/compressor.h
index f0a3754f02..53c6bf3ecc 100644
--- a/src/script/compressor.h
+++ b/src/script/compressor.h
@@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef H_BITCOIN_SCRIPT_COMPRESSOR
@@ -81,4 +81,4 @@ public:
}
};
-#endif
+#endif // H_BITCOIN_SCRIPT_COMPRESSOR
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 4f4fdb6b7f..d742fb9eb9 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "interpreter.h"
@@ -132,7 +132,7 @@ bool IsCanonicalSignature(const valtype &vchSig, unsigned int flags) {
return true;
}
-bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType)
+bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, unsigned int flags)
{
CScript::const_iterator pc = script.begin();
CScript::const_iterator pend = script.end();
@@ -637,19 +637,19 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
valtype& vch = stacktop(-1);
valtype vchHash((opcode == OP_RIPEMD160 || opcode == OP_SHA1 || opcode == OP_HASH160) ? 20 : 32);
if (opcode == OP_RIPEMD160)
- CRIPEMD160().Write(&vch[0], vch.size()).Finalize(&vchHash[0]);
+ CRIPEMD160().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash));
else if (opcode == OP_SHA1)
- CSHA1().Write(&vch[0], vch.size()).Finalize(&vchHash[0]);
+ CSHA1().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash));
else if (opcode == OP_SHA256)
- CSHA256().Write(&vch[0], vch.size()).Finalize(&vchHash[0]);
+ CSHA256().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash));
else if (opcode == OP_HASH160)
- CHash160().Write(&vch[0], vch.size()).Finalize(&vchHash[0]);
+ CHash160().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash));
else if (opcode == OP_HASH256)
- CHash256().Write(&vch[0], vch.size()).Finalize(&vchHash[0]);
+ CHash256().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash));
popstack(stack);
stack.push_back(vchHash);
}
- break;
+ break;
case OP_CODESEPARATOR:
{
@@ -675,7 +675,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
scriptCode.FindAndDelete(CScript(vchSig));
bool fSuccess = IsCanonicalSignature(vchSig, flags) && IsCanonicalPubKey(vchPubKey, flags) &&
- CheckSig(vchSig, vchPubKey, scriptCode, txTo, nIn, nHashType, flags);
+ CheckSig(vchSig, vchPubKey, scriptCode, txTo, nIn, flags);
popstack(stack);
popstack(stack);
@@ -736,7 +736,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
// Check signature
bool fOk = IsCanonicalSignature(vchSig, flags) && IsCanonicalPubKey(vchPubKey, flags) &&
- CheckSig(vchSig, vchPubKey, scriptCode, txTo, nIn, nHashType, flags);
+ CheckSig(vchSig, vchPubKey, scriptCode, txTo, nIn, flags);
if (fOk) {
isig++;
@@ -975,7 +975,7 @@ public:
}
};
-bool CheckSig(vector<unsigned char> vchSig, const vector<unsigned char> &vchPubKey, const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType, int flags)
+bool CheckSig(vector<unsigned char> vchSig, const vector<unsigned char>& vchPubKey, const CScript& scriptCode, const CTransaction& txTo, unsigned int nIn, int flags)
{
static CSignatureCache signatureCache;
@@ -986,10 +986,7 @@ bool CheckSig(vector<unsigned char> vchSig, const vector<unsigned char> &vchPubK
// Hash type is one byte tacked on to the end of the signature
if (vchSig.empty())
return false;
- if (nHashType == 0)
- nHashType = vchSig.back();
- else if (nHashType != vchSig.back())
- return false;
+ int nHashType = vchSig.back();
vchSig.pop_back();
uint256 sighash = SignatureHash(scriptCode, txTo, nIn, nHashType);
@@ -1006,15 +1003,14 @@ bool CheckSig(vector<unsigned char> vchSig, const vector<unsigned char> &vchPubK
return true;
}
-bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn,
- unsigned int flags, int nHashType)
+bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, unsigned int flags)
{
vector<vector<unsigned char> > stack, stackCopy;
- if (!EvalScript(stack, scriptSig, txTo, nIn, flags, nHashType))
+ if (!EvalScript(stack, scriptSig, txTo, nIn, flags))
return false;
if (flags & SCRIPT_VERIFY_P2SH)
stackCopy = stack;
- if (!EvalScript(stack, scriptPubKey, txTo, nIn, flags, nHashType))
+ if (!EvalScript(stack, scriptPubKey, txTo, nIn, flags))
return false;
if (stack.empty())
return false;
@@ -1037,7 +1033,7 @@ bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const C
CScript pubKey2(pubKeySerialized.begin(), pubKeySerialized.end());
popstack(stackCopy);
- if (!EvalScript(stackCopy, pubKey2, txTo, nIn, flags, nHashType))
+ if (!EvalScript(stackCopy, pubKey2, txTo, nIn, flags))
return false;
if (stackCopy.empty())
return false;
diff --git a/src/script/interpreter.h b/src/script/interpreter.h
index 0c6f8b9d13..adca2142ac 100644
--- a/src/script/interpreter.h
+++ b/src/script/interpreter.h
@@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef H_BITCOIN_SCRIPT_INTERPRETER
@@ -10,9 +10,9 @@
#include <stdint.h>
#include <string>
-class uint256;
class CScript;
class CTransaction;
+class uint256;
/** Signature hash types/flags */
enum
@@ -38,8 +38,8 @@ bool IsCanonicalPubKey(const std::vector<unsigned char> &vchPubKey, unsigned int
bool IsCanonicalSignature(const std::vector<unsigned char> &vchSig, unsigned int flags);
uint256 SignatureHash(const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
-bool CheckSig(std::vector<unsigned char> vchSig, const std::vector<unsigned char> &vchPubKey, const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType, int flags);
-bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType);
-bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType);
+bool CheckSig(std::vector<unsigned char> vchSig, const std::vector<unsigned char> &vchPubKey, const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int flags);
+bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, unsigned int flags);
+bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, unsigned int flags);
-#endif
+#endif // H_BITCOIN_SCRIPT_INTERPRETER
diff --git a/src/script/script.cpp b/src/script/script.cpp
index 60d1beac95..a5126e7cc2 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "script.h"
@@ -253,43 +253,3 @@ bool CScript::HasCanonicalPushes() const
}
return true;
}
-
-class CScriptVisitor : public boost::static_visitor<bool>
-{
-private:
- CScript *script;
-public:
- CScriptVisitor(CScript *scriptin) { script = scriptin; }
-
- bool operator()(const CNoDestination &dest) const {
- script->clear();
- return false;
- }
-
- bool operator()(const CKeyID &keyID) const {
- script->clear();
- *script << OP_DUP << OP_HASH160 << keyID << OP_EQUALVERIFY << OP_CHECKSIG;
- return true;
- }
-
- bool operator()(const CScriptID &scriptID) const {
- script->clear();
- *script << OP_HASH160 << scriptID << OP_EQUAL;
- return true;
- }
-};
-
-void CScript::SetDestination(const CTxDestination& dest)
-{
- boost::apply_visitor(CScriptVisitor(this), dest);
-}
-
-void CScript::SetMultisig(int nRequired, const std::vector<CPubKey>& keys)
-{
- this->clear();
-
- *this << EncodeOP_N(nRequired);
- BOOST_FOREACH(const CPubKey& key, keys)
- *this << key;
- *this << EncodeOP_N(keys.size()) << OP_CHECKMULTISIG;
-}
diff --git a/src/script/script.h b/src/script/script.h
index 21847c09bd..caf176476f 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef H_BITCOIN_SCRIPT
@@ -304,7 +304,7 @@ private:
// If the input vector's most significant byte is 0x80, remove it from
// the result's msb and return a negative.
if (vch.back() & 0x80)
- return -(result & ~(0x80ULL << (8 * (vch.size() - 1))));
+ return -((int64_t)(result & ~(0x80ULL << (8 * (vch.size() - 1)))));
return result;
}
@@ -320,20 +320,6 @@ inline std::string ValueString(const std::vector<unsigned char>& vch)
return HexStr(vch);
}
-class CNoDestination {
-public:
- friend bool operator==(const CNoDestination &a, const CNoDestination &b) { return true; }
- friend bool operator<(const CNoDestination &a, const CNoDestination &b) { return true; }
-};
-
-/** A txout script template with a specific destination. It is either:
- * * CNoDestination: no destination set
- * * CKeyID: TX_PUBKEYHASH destination
- * * CScriptID: TX_SCRIPTHASH destination
- * A CTxDestination is the internal data type encoded in a CBitcoinAddress
- */
-typedef boost::variant<CNoDestination, CKeyID, CScriptID> CTxDestination;
-
/** Serialized script, used inside transaction inputs and outputs */
class CScript : public std::vector<unsigned char>
{
@@ -354,9 +340,7 @@ public:
CScript() { }
CScript(const CScript& b) : std::vector<unsigned char>(b.begin(), b.end()) { }
CScript(const_iterator pbegin, const_iterator pend) : std::vector<unsigned char>(pbegin, pend) { }
-#ifndef _MSC_VER
CScript(const unsigned char* pbegin, const unsigned char* pend) : std::vector<unsigned char>(pbegin, pend) { }
-#endif
CScript& operator+=(const CScript& b)
{
@@ -560,7 +544,7 @@ public:
{
while (end() - pc >= (long)b.size() && memcmp(&pc[0], &b[0], b.size()) == 0)
{
- erase(pc, pc + b.size());
+ pc = erase(pc, pc + b.size());
++nFound;
}
}
@@ -604,9 +588,6 @@ public:
return (size() > 0 && *begin() == OP_RETURN);
}
- void SetDestination(const CTxDestination& address);
- void SetMultisig(int nRequired, const std::vector<CPubKey>& keys);
-
std::string ToString() const
{
std::string str;
@@ -642,4 +623,4 @@ public:
}
};
-#endif
+#endif // H_BITCOIN_SCRIPT
diff --git a/src/script/sign.cpp b/src/script/sign.cpp
index 958177de3d..8abd8d221d 100644
--- a/src/script/sign.cpp
+++ b/src/script/sign.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "script/sign.h"
@@ -123,7 +123,7 @@ bool SignSignature(const CKeyStore &keystore, const CScript& fromPubKey, CMutabl
}
// Test solution
- return VerifyScript(txin.scriptSig, fromPubKey, txTo, nIn, STANDARD_SCRIPT_VERIFY_FLAGS, 0);
+ return VerifyScript(txin.scriptSig, fromPubKey, txTo, nIn, STANDARD_SCRIPT_VERIFY_FLAGS);
}
bool SignSignature(const CKeyStore &keystore, const CTransaction& txFrom, CMutableTransaction& txTo, unsigned int nIn, int nHashType)
@@ -174,7 +174,7 @@ static CScript CombineMultisig(CScript scriptPubKey, const CMutableTransaction&
if (sigs.count(pubkey))
continue; // Already got a sig for this pubkey
- if (CheckSig(sig, pubkey, scriptPubKey, txTo, nIn, 0, 0))
+ if (CheckSig(sig, pubkey, scriptPubKey, txTo, nIn, 0))
{
sigs[pubkey] = sig;
break;
@@ -252,9 +252,9 @@ CScript CombineSignatures(CScript scriptPubKey, const CTransaction& txTo, unsign
Solver(scriptPubKey, txType, vSolutions);
vector<valtype> stack1;
- EvalScript(stack1, scriptSig1, CTransaction(), 0, SCRIPT_VERIFY_STRICTENC, 0);
+ EvalScript(stack1, scriptSig1, CTransaction(), 0, SCRIPT_VERIFY_STRICTENC);
vector<valtype> stack2;
- EvalScript(stack2, scriptSig2, CTransaction(), 0, SCRIPT_VERIFY_STRICTENC, 0);
+ EvalScript(stack2, scriptSig2, CTransaction(), 0, SCRIPT_VERIFY_STRICTENC);
return CombineSignatures(scriptPubKey, txTo, nIn, txType, vSolutions, stack1, stack2);
}
diff --git a/src/script/sign.h b/src/script/sign.h
index 51723b53af..f218a64562 100644
--- a/src/script/sign.h
+++ b/src/script/sign.h
@@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef H_BITCOIN_SCRIPT_SIGN
@@ -11,6 +11,7 @@
class CKeyStore;
class CScript;
class CTransaction;
+
struct CMutableTransaction;
bool SignSignature(const CKeyStore& keystore, const CScript& fromPubKey, CMutableTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL);
@@ -20,4 +21,4 @@ bool SignSignature(const CKeyStore& keystore, const CTransaction& txFrom, CMutab
// combine them intelligently and return the result.
CScript CombineSignatures(CScript scriptPubKey, const CTransaction& txTo, unsigned int nIn, const CScript& scriptSig1, const CScript& scriptSig2);
-#endif
+#endif // H_BITCOIN_SCRIPT_SIGN
diff --git a/src/script/standard.cpp b/src/script/standard.cpp
index 684edff4d2..407baf621d 100644
--- a/src/script/standard.cpp
+++ b/src/script/standard.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "script/standard.h"
@@ -252,3 +252,50 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto
return true;
}
+
+namespace
+{
+class CScriptVisitor : public boost::static_visitor<bool>
+{
+private:
+ CScript *script;
+public:
+ CScriptVisitor(CScript *scriptin) { script = scriptin; }
+
+ bool operator()(const CNoDestination &dest) const {
+ script->clear();
+ return false;
+ }
+
+ bool operator()(const CKeyID &keyID) const {
+ script->clear();
+ *script << OP_DUP << OP_HASH160 << keyID << OP_EQUALVERIFY << OP_CHECKSIG;
+ return true;
+ }
+
+ bool operator()(const CScriptID &scriptID) const {
+ script->clear();
+ *script << OP_HASH160 << scriptID << OP_EQUAL;
+ return true;
+ }
+};
+}
+
+CScript GetScriptForDestination(const CTxDestination& dest)
+{
+ CScript script;
+
+ boost::apply_visitor(CScriptVisitor(&script), dest);
+ return script;
+}
+
+CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys)
+{
+ CScript script;
+
+ script << CScript::EncodeOP_N(nRequired);
+ BOOST_FOREACH(const CPubKey& key, keys)
+ script << key;
+ script << CScript::EncodeOP_N(keys.size()) << OP_CHECKMULTISIG;
+ return script;
+}
diff --git a/src/script/standard.h b/src/script/standard.h
index 18092e879e..ead79b82a2 100644
--- a/src/script/standard.h
+++ b/src/script/standard.h
@@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef H_BITCOIN_SCRIPT_STANDARD
@@ -45,6 +45,20 @@ enum txnouttype
TX_NULL_DATA,
};
+class CNoDestination {
+public:
+ friend bool operator==(const CNoDestination &a, const CNoDestination &b) { return true; }
+ friend bool operator<(const CNoDestination &a, const CNoDestination &b) { return true; }
+};
+
+/** A txout script template with a specific destination. It is either:
+ * * CNoDestination: no destination set
+ * * CKeyID: TX_PUBKEYHASH destination
+ * * CScriptID: TX_SCRIPTHASH destination
+ * A CTxDestination is the internal data type encoded in a CBitcoinAddress
+ */
+typedef boost::variant<CNoDestination, CKeyID, CScriptID> CTxDestination;
+
const char* GetTxnOutputType(txnouttype t);
bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet);
@@ -53,4 +67,7 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType);
bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet);
bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<CTxDestination>& addressRet, int& nRequiredRet);
-#endif
+CScript GetScriptForDestination(const CTxDestination& dest);
+CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys);
+
+#endif // H_BITCOIN_SCRIPT_STANDARD
diff --git a/src/serialize.h b/src/serialize.h
index dba3460d1b..7f8f933284 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -10,8 +10,8 @@
#include <algorithm>
#include <assert.h>
-#include <limits>
#include <ios>
+#include <limits>
#include <map>
#include <set>
#include <stdint.h>
@@ -921,7 +921,7 @@ public:
Init(nTypeIn, nVersionIn);
}
- CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn, int nVersionIn) : vch((char*)&vchIn.begin()[0], (char*)&vchIn.end()[0])
+ CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn, int nVersionIn) : vch(vchIn.begin(), vchIn.end())
{
Init(nTypeIn, nVersionIn);
}
@@ -1154,7 +1154,7 @@ public:
-/** RAII wrapper for FILE*.
+/** Non-refcounted RAII wrapper for FILE*.
*
* Will automatically close the file when it goes out of scope if not null.
* If you're returning the file pointer, return file.release().
@@ -1162,6 +1162,10 @@ public:
*/
class CAutoFile
{
+private:
+ // Disallow copies
+ CAutoFile(const CAutoFile&);
+ CAutoFile& operator=(const CAutoFile&);
protected:
FILE* file;
public:
diff --git a/src/sync.cpp b/src/sync.cpp
index 066c1ca744..ef35c9d646 100644
--- a/src/sync.cpp
+++ b/src/sync.cpp
@@ -7,9 +7,10 @@
#include "util.h"
#include "utilstrencodings.h"
+#include <stdio.h>
+
#include <boost/foreach.hpp>
#include <boost/thread.hpp>
-#include <stdio.h>
#ifdef DEBUG_LOCKCONTENTION
void PrintLockContention(const char* pszName, const char* pszFile, int nLine)
@@ -31,8 +32,7 @@ void PrintLockContention(const char* pszName, const char* pszFile, int nLine)
// Complain if any thread tries to lock in a different order.
//
-struct CLockLocation
-{
+struct CLockLocation {
CLockLocation(const char* pszName, const char* pszFile, int nLine)
{
mutexName = pszName;
@@ -42,7 +42,7 @@ struct CLockLocation
std::string ToString() const
{
- return mutexName+" "+sourceFile+":"+itostr(sourceLine);
+ return mutexName + " " + sourceFile + ":" + itostr(sourceLine);
}
std::string MutexName() const { return mutexName; }
@@ -53,7 +53,7 @@ private:
int sourceLine;
};
-typedef std::vector< std::pair<void*, CLockLocation> > LockStack;
+typedef std::vector<std::pair<void*, CLockLocation> > LockStack;
static boost::mutex dd_mutex;
static std::map<std::pair<void*, void*>, LockStack> lockorders;
@@ -64,17 +64,19 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
{
LogPrintf("POTENTIAL DEADLOCK DETECTED\n");
LogPrintf("Previous lock order was:\n");
- BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, s2)
- {
- if (i.first == mismatch.first) LogPrintf(" (1)");
- if (i.first == mismatch.second) LogPrintf(" (2)");
+ BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, s2) {
+ if (i.first == mismatch.first)
+ LogPrintf(" (1)");
+ if (i.first == mismatch.second)
+ LogPrintf(" (2)");
LogPrintf(" %s\n", i.second.ToString());
}
LogPrintf("Current lock order is:\n");
- BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, s1)
- {
- if (i.first == mismatch.first) LogPrintf(" (1)");
- if (i.first == mismatch.second) LogPrintf(" (2)");
+ BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, s1) {
+ if (i.first == mismatch.first)
+ LogPrintf(" (1)");
+ if (i.first == mismatch.second)
+ LogPrintf(" (2)");
LogPrintf(" %s\n", i.second.ToString());
}
}
@@ -90,8 +92,9 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
(*lockstack).push_back(std::make_pair(c, locklocation));
if (!fTry) {
- BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, (*lockstack)) {
- if (i.first == c) break;
+ BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, (*lockstack)) {
+ if (i.first == c)
+ break;
std::pair<void*, void*> p1 = std::make_pair(i.first, c);
if (lockorders.count(p1))
@@ -99,8 +102,7 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
lockorders[p1] = (*lockstack);
std::pair<void*, void*> p2 = std::make_pair(c, i.first);
- if (lockorders.count(p2))
- {
+ if (lockorders.count(p2)) {
potential_deadlock_detected(p1, lockorders[p2], lockorders[p1]);
break;
}
@@ -111,8 +113,7 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
static void pop_lock()
{
- if (fDebug)
- {
+ if (fDebug) {
const CLockLocation& locklocation = (*lockstack).rbegin()->second;
LogPrint("lock", "Unlocked: %s\n", locklocation.ToString());
}
@@ -134,17 +135,17 @@ void LeaveCritical()
std::string LocksHeld()
{
std::string result;
- BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)&i, *lockstack)
+ BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, *lockstack)
result += i.second.ToString() + std::string("\n");
return result;
}
-void AssertLockHeldInternal(const char *pszName, const char* pszFile, int nLine, void *cs)
+void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs)
{
- BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)&i, *lockstack)
- if (i.first == cs) return;
- fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s",
- pszName, pszFile, nLine, LocksHeld().c_str());
+ BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, *lockstack)
+ if (i.first == cs)
+ return;
+ fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str());
abort();
}
diff --git a/src/sync.h b/src/sync.h
index 4b81b4bd32..cd0aa7b20e 100644
--- a/src/sync.h
+++ b/src/sync.h
@@ -48,7 +48,6 @@ LEAVE_CRITICAL_SECTION(mutex); // no RAII
*/
-
///////////////////////////////
// //
// THE ACTUAL IMPLEMENTATION //
@@ -63,17 +62,17 @@ class LOCKABLE AnnotatedMixin : public PARENT
public:
void lock() EXCLUSIVE_LOCK_FUNCTION()
{
- PARENT::lock();
+ PARENT::lock();
}
void unlock() UNLOCK_FUNCTION()
{
- PARENT::unlock();
+ PARENT::unlock();
}
bool try_lock() EXCLUSIVE_TRYLOCK_FUNCTION(true)
{
- return PARENT::try_lock();
+ return PARENT::try_lock();
}
};
@@ -91,11 +90,13 @@ typedef boost::condition_variable CConditionVariable;
void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false);
void LeaveCritical();
std::string LocksHeld();
-void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void *cs);
+void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs);
#else
-void static inline EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false) {}
+void static inline EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false)
+{
+}
void static inline LeaveCritical() {}
-void static inline AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void *cs) {}
+void static inline AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs) {}
#endif
#define AssertLockHeld(cs) AssertLockHeldInternal(#cs, __FILE__, __LINE__, &cs)
@@ -104,7 +105,7 @@ void PrintLockContention(const char* pszName, const char* pszFile, int nLine);
#endif
/** Wrapper around boost::unique_lock<Mutex> */
-template<typename Mutex>
+template <typename Mutex>
class CMutexLock
{
private:
@@ -114,11 +115,10 @@ private:
{
EnterCritical(pszName, pszFile, nLine, (void*)(lock.mutex()));
#ifdef DEBUG_LOCKCONTENTION
- if (!lock.try_lock())
- {
+ if (!lock.try_lock()) {
PrintLockContention(pszName, pszFile, nLine);
#endif
- lock.lock();
+ lock.lock();
#ifdef DEBUG_LOCKCONTENTION
}
#endif
@@ -157,19 +157,19 @@ public:
typedef CMutexLock<CCriticalSection> CCriticalBlock;
#define LOCK(cs) CCriticalBlock criticalblock(cs, #cs, __FILE__, __LINE__)
-#define LOCK2(cs1,cs2) CCriticalBlock criticalblock1(cs1, #cs1, __FILE__, __LINE__),criticalblock2(cs2, #cs2, __FILE__, __LINE__)
-#define TRY_LOCK(cs,name) CCriticalBlock name(cs, #cs, __FILE__, __LINE__, true)
+#define LOCK2(cs1, cs2) CCriticalBlock criticalblock1(cs1, #cs1, __FILE__, __LINE__), criticalblock2(cs2, #cs2, __FILE__, __LINE__)
+#define TRY_LOCK(cs, name) CCriticalBlock name(cs, #cs, __FILE__, __LINE__, true)
-#define ENTER_CRITICAL_SECTION(cs) \
- { \
+#define ENTER_CRITICAL_SECTION(cs) \
+ { \
EnterCritical(#cs, __FILE__, __LINE__, (void*)(&cs)); \
- (cs).lock(); \
+ (cs).lock(); \
}
#define LEAVE_CRITICAL_SECTION(cs) \
- { \
- (cs).unlock(); \
- LeaveCritical(); \
+ { \
+ (cs).unlock(); \
+ LeaveCritical(); \
}
class CSemaphore
@@ -182,7 +182,8 @@ private:
public:
CSemaphore(int init) : value(init) {}
- void wait() {
+ void wait()
+ {
boost::unique_lock<boost::mutex> lock(mutex);
while (value < 1) {
condition.wait(lock);
@@ -190,7 +191,8 @@ public:
value--;
}
- bool try_wait() {
+ bool try_wait()
+ {
boost::unique_lock<boost::mutex> lock(mutex);
if (value < 1)
return false;
@@ -198,7 +200,8 @@ public:
return true;
}
- void post() {
+ void post()
+ {
{
boost::unique_lock<boost::mutex> lock(mutex);
value++;
@@ -211,31 +214,35 @@ public:
class CSemaphoreGrant
{
private:
- CSemaphore *sem;
+ CSemaphore* sem;
bool fHaveGrant;
public:
- void Acquire() {
+ void Acquire()
+ {
if (fHaveGrant)
return;
sem->wait();
fHaveGrant = true;
}
- void Release() {
+ void Release()
+ {
if (!fHaveGrant)
return;
sem->post();
fHaveGrant = false;
}
- bool TryAcquire() {
+ bool TryAcquire()
+ {
if (!fHaveGrant && sem->try_wait())
fHaveGrant = true;
return fHaveGrant;
}
- void MoveTo(CSemaphoreGrant &grant) {
+ void MoveTo(CSemaphoreGrant& grant)
+ {
grant.Release();
grant.sem = sem;
grant.fHaveGrant = fHaveGrant;
@@ -245,18 +252,21 @@ public:
CSemaphoreGrant() : sem(NULL), fHaveGrant(false) {}
- CSemaphoreGrant(CSemaphore &sema, bool fTry = false) : sem(&sema), fHaveGrant(false) {
+ CSemaphoreGrant(CSemaphore& sema, bool fTry = false) : sem(&sema), fHaveGrant(false)
+ {
if (fTry)
TryAcquire();
else
Acquire();
}
- ~CSemaphoreGrant() {
+ ~CSemaphoreGrant()
+ {
Release();
}
- operator bool() {
+ operator bool()
+ {
return fHaveGrant;
}
};
diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp
index fa4edff63f..7bec12b665 100644
--- a/src/test/DoS_tests.cpp
+++ b/src/test/DoS_tests.cpp
@@ -24,9 +24,14 @@
#include <boost/test/unit_test.hpp>
// Tests this internal-to-main.cpp method:
-extern bool AddOrphanTx(const CTransaction& tx);
+extern bool AddOrphanTx(const CTransaction& tx, NodeId peer);
+extern void EraseOrphansFor(NodeId peer);
extern unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans);
-extern std::map<uint256, CTransaction> mapOrphanTransactions;
+struct COrphanTx {
+ CTransaction tx;
+ NodeId fromPeer;
+};
+extern std::map<uint256, COrphanTx> mapOrphanTransactions;
extern std::map<uint256, std::set<uint256> > mapOrphanTransactionsByPrev;
CService ip(uint32_t i)
@@ -148,11 +153,11 @@ BOOST_AUTO_TEST_CASE(DoS_checknbits)
CTransaction RandomOrphan()
{
- std::map<uint256, CTransaction>::iterator it;
+ std::map<uint256, COrphanTx>::iterator it;
it = mapOrphanTransactions.lower_bound(GetRandHash());
if (it == mapOrphanTransactions.end())
it = mapOrphanTransactions.begin();
- return it->second;
+ return it->second.tx;
}
BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
@@ -172,9 +177,9 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
tx.vin[0].scriptSig << OP_1;
tx.vout.resize(1);
tx.vout[0].nValue = 1*CENT;
- tx.vout[0].scriptPubKey.SetDestination(key.GetPubKey().GetID());
+ tx.vout[0].scriptPubKey = GetScriptForDestination(key.GetPubKey().GetID());
- AddOrphanTx(tx);
+ AddOrphanTx(tx, i);
}
// ... and 50 that depend on other orphans:
@@ -188,10 +193,10 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
tx.vin[0].prevout.hash = txPrev.GetHash();
tx.vout.resize(1);
tx.vout[0].nValue = 1*CENT;
- tx.vout[0].scriptPubKey.SetDestination(key.GetPubKey().GetID());
+ tx.vout[0].scriptPubKey = GetScriptForDestination(key.GetPubKey().GetID());
SignSignature(keystore, txPrev, tx, 0);
- AddOrphanTx(tx);
+ AddOrphanTx(tx, i);
}
// This really-big orphan should be ignored:
@@ -202,7 +207,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
CMutableTransaction tx;
tx.vout.resize(1);
tx.vout[0].nValue = 1*CENT;
- tx.vout[0].scriptPubKey.SetDestination(key.GetPubKey().GetID());
+ tx.vout[0].scriptPubKey = GetScriptForDestination(key.GetPubKey().GetID());
tx.vin.resize(500);
for (unsigned int j = 0; j < tx.vin.size(); j++)
{
@@ -215,7 +220,15 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
for (unsigned int j = 1; j < tx.vin.size(); j++)
tx.vin[j].scriptSig = tx.vin[0].scriptSig;
- BOOST_CHECK(!AddOrphanTx(tx));
+ BOOST_CHECK(!AddOrphanTx(tx, i));
+ }
+
+ // Test EraseOrphansFor:
+ for (NodeId i = 0; i < 3; i++)
+ {
+ size_t sizeBefore = mapOrphanTransactions.size();
+ EraseOrphansFor(i);
+ BOOST_CHECK(mapOrphanTransactions.size() < sizeBefore);
}
// Test LimitOrphanTxSize() function:
diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp
index fe68e9e974..58fffb6df4 100644
--- a/src/test/base58_tests.cpp
+++ b/src/test/base58_tests.cpp
@@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE(base58_EncodeBase58)
std::vector<unsigned char> sourcedata = ParseHex(test[0].get_str());
std::string base58string = test[1].get_str();
BOOST_CHECK_MESSAGE(
- EncodeBase58(&sourcedata[0], &sourcedata[sourcedata.size()]) == base58string,
+ EncodeBase58(begin_ptr(sourcedata), end_ptr(sourcedata)) == base58string,
strTest);
}
}
diff --git a/src/test/checkblock_tests.cpp b/src/test/checkblock_tests.cpp
index fdea12846a..67d40a45c7 100644
--- a/src/test/checkblock_tests.cpp
+++ b/src/test/checkblock_tests.cpp
@@ -35,7 +35,7 @@ bool read_block(const std::string& filename, CBlock& block)
fseek(fp, 8, SEEK_SET); // skip msgheader/size
- CAutoFile filein = CAutoFile(fp, SER_DISK, CLIENT_VERSION);
+ CAutoFile filein(fp, SER_DISK, CLIENT_VERSION);
if (!filein) return false;
filein >> block;
diff --git a/src/test/crypto_tests.cpp b/src/test/crypto_tests.cpp
index a3eec270ee..68232a2ff1 100644
--- a/src/test/crypto_tests.cpp
+++ b/src/test/crypto_tests.cpp
@@ -32,7 +32,7 @@ void TestVector(const Hasher &h, const In &in, const Out &out) {
size_t len = insecure_rand() % ((in.size() - pos + 1) / 2 + 1);
hasher.Write((unsigned char*)&in[pos], len);
pos += len;
- if (pos > 0 && pos + 2 * out.size() > in.size()) {
+ if (pos > 0 && pos + 2 * out.size() > in.size() && pos < in.size()) {
// Test that writing the rest at once to a copy of a hasher works.
Hasher(hasher).Write((unsigned char*)&in[pos], in.size() - pos).Finalize(&hash[0]);
BOOST_CHECK(hash == out);
diff --git a/src/test/data/bitcoin-util-test.json b/src/test/data/bitcoin-util-test.json
index 7db87d7c11..cb74d73ef2 100644
--- a/src/test/data/bitcoin-util-test.json
+++ b/src/test/data/bitcoin-util-test.json
@@ -34,5 +34,8 @@
"outaddr=0.18:13tuJJDR2RgArmgfv6JScSdreahzgc4T6o",
"outaddr=4:1P8yWvZW8jVihP1bzHeqfE4aoXNX8AVa46"],
"output_cmp": "txcreate1.hex"
+ },
+ { "exec": ["./bitcoin-tx", "-create", "outscript=0:"],
+ "output_cmp": "txcreate2.hex"
}
]
diff --git a/src/test/data/script_invalid.json b/src/test/data/script_invalid.json
index e3e1ccbf3c..401031ad12 100644
--- a/src/test/data/script_invalid.json
+++ b/src/test/data/script_invalid.json
@@ -1,366 +1,402 @@
[
-["", "DEPTH", "Test the test: we should have an empty stack after scriptSig evaluation"],
-[" ", "DEPTH", "and multiple spaces should not change that."],
-[" ", "DEPTH"],
-[" ", "DEPTH"],
-
-["", ""],
-["", "NOP"],
-["", "NOP DEPTH"],
-["NOP", ""],
-["NOP", "DEPTH"],
-["NOP","NOP"],
-["NOP","NOP DEPTH"],
-
-["DEPTH", ""],
-
-["0x4c01","0x01 NOP", "PUSHDATA1 with not enough bytes"],
-["0x4d0200ff","0x01 NOP", "PUSHDATA2 with not enough bytes"],
-["0x4e03000000ffff","0x01 NOP", "PUSHDATA4 with not enough bytes"],
-
-["1", "IF 0x50 ENDIF 1", "0x50 is reserved"],
-["0x52", "0x5f ADD 0x60 EQUAL", "0x51 through 0x60 push 1 through 16 onto stack"],
-["0","NOP"],
-["1", "IF VER ELSE 1 ENDIF", "VER non-functional"],
-["0", "IF VERIF ELSE 1 ENDIF", "VERIF illegal everywhere"],
-["0", "IF ELSE 1 ELSE VERIF ENDIF", "VERIF illegal everywhere"],
-["0", "IF VERNOTIF ELSE 1 ENDIF", "VERNOTIF illegal everywhere"],
-["0", "IF ELSE 1 ELSE VERNOTIF ENDIF", "VERNOTIF illegal everywhere"],
-
-["1 IF", "1 ENDIF", "IF/ENDIF can't span scriptSig/scriptPubKey"],
-["1 IF 0 ENDIF", "1 ENDIF"],
-["1 ELSE 0 ENDIF", "1"],
-["0 NOTIF", "123"],
-
-["0", "DUP IF ENDIF"],
-["0", "IF 1 ENDIF"],
-["0", "DUP IF ELSE ENDIF"],
-["0", "IF 1 ELSE ENDIF"],
-["0", "NOTIF ELSE 1 ENDIF"],
-
-["0 1", "IF IF 1 ELSE 0 ENDIF ENDIF"],
-["0 0", "IF IF 1 ELSE 0 ENDIF ENDIF"],
-["1 0", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-["0 1", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-
-["0 0", "NOTIF IF 1 ELSE 0 ENDIF ENDIF"],
-["0 1", "NOTIF IF 1 ELSE 0 ENDIF ENDIF"],
-["1 1", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-["0 0", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-
-["1", "IF RETURN ELSE ELSE 1 ENDIF", "Multiple ELSEs"],
-["1", "IF 1 ELSE ELSE RETURN ENDIF"],
-
-["1", "ENDIF", "Malformed IF/ELSE/ENDIF sequence"],
-["1", "ELSE ENDIF"],
-["1", "ENDIF ELSE"],
-["1", "ENDIF ELSE IF"],
-["1", "IF ELSE ENDIF ELSE"],
-["1", "IF ELSE ENDIF ELSE ENDIF"],
-["1", "IF ENDIF ENDIF"],
-["1", "IF ELSE ELSE ENDIF ENDIF"],
-
-["1", "RETURN"],
-["1", "DUP IF RETURN ENDIF"],
-
-["1", "RETURN 'data'", "canonical prunable txout format"],
-["0 IF", "RETURN ENDIF 1", "still prunable because IF/ENDIF can't span scriptSig/scriptPubKey"],
-
-["0", "VERIFY 1"],
-["1", "VERIFY"],
-["1", "VERIFY 0"],
-
-["1 TOALTSTACK", "FROMALTSTACK 1", "alt stack not shared between sig/pubkey"],
-
-["IFDUP", "DEPTH 0 EQUAL"],
-["DROP", "DEPTH 0 EQUAL"],
-["DUP", "DEPTH 0 EQUAL"],
-["1", "DUP 1 ADD 2 EQUALVERIFY 0 EQUAL"],
-["NOP", "NIP"],
-["NOP", "1 NIP"],
-["NOP", "1 0 NIP"],
-["NOP", "OVER 1"],
-["1", "OVER"],
-["0 1", "OVER DEPTH 3 EQUALVERIFY"],
-["19 20 21", "PICK 19 EQUALVERIFY DEPTH 2 EQUAL"],
-["NOP", "0 PICK"],
-["1", "-1 PICK"],
-["19 20 21", "0 PICK 20 EQUALVERIFY DEPTH 3 EQUAL"],
-["19 20 21", "1 PICK 21 EQUALVERIFY DEPTH 3 EQUAL"],
-["19 20 21", "2 PICK 22 EQUALVERIFY DEPTH 3 EQUAL"],
-["NOP", "0 ROLL"],
-["1", "-1 ROLL"],
-["19 20 21", "0 ROLL 20 EQUALVERIFY DEPTH 2 EQUAL"],
-["19 20 21", "1 ROLL 21 EQUALVERIFY DEPTH 2 EQUAL"],
-["19 20 21", "2 ROLL 22 EQUALVERIFY DEPTH 2 EQUAL"],
-["NOP", "ROT 1"],
-["NOP", "1 ROT 1"],
-["NOP", "1 2 ROT 1"],
-["NOP", "0 1 2 ROT"],
-["NOP", "SWAP 1"],
-["1", "SWAP 1"],
-["0 1", "SWAP 1 EQUALVERIFY"],
-["NOP", "TUCK 1"],
-["1", "TUCK 1"],
-["1 0", "TUCK DEPTH 3 EQUALVERIFY SWAP 2DROP"],
-["NOP", "2DUP 1"],
-["1", "2DUP 1"],
-["NOP", "3DUP 1"],
-["1", "3DUP 1"],
-["1 2", "3DUP 1"],
-["NOP", "2OVER 1"],
-["1", "2 3 2OVER 1"],
-["NOP", "2SWAP 1"],
-["1", "2 3 2SWAP 1"],
-
-["'a' 'b'", "CAT", "CAT disabled"],
-["'a' 'b' 0", "IF CAT ELSE 1 ENDIF", "CAT disabled"],
-["'abc' 1 1", "SUBSTR", "SUBSTR disabled"],
-["'abc' 1 1 0", "IF SUBSTR ELSE 1 ENDIF", "SUBSTR disabled"],
-["'abc' 2 0", "IF LEFT ELSE 1 ENDIF", "LEFT disabled"],
-["'abc' 2 0", "IF RIGHT ELSE 1 ENDIF", "RIGHT disabled"],
-
-["NOP", "SIZE 1"],
-
-["'abc'", "IF INVERT ELSE 1 ENDIF", "INVERT disabled"],
-["1 2 0 IF AND ELSE 1 ENDIF", "NOP", "AND disabled"],
-["1 2 0 IF OR ELSE 1 ENDIF", "NOP", "OR disabled"],
-["1 2 0 IF XOR ELSE 1 ENDIF", "NOP", "XOR disabled"],
-["2 0 IF 2MUL ELSE 1 ENDIF", "NOP", "2MUL disabled"],
-["2 0 IF 2DIV ELSE 1 ENDIF", "NOP", "2DIV disabled"],
-["2 2 0 IF MUL ELSE 1 ENDIF", "NOP", "MUL disabled"],
-["2 2 0 IF DIV ELSE 1 ENDIF", "NOP", "DIV disabled"],
-["2 2 0 IF MOD ELSE 1 ENDIF", "NOP", "MOD disabled"],
-["2 2 0 IF LSHIFT ELSE 1 ENDIF", "NOP", "LSHIFT disabled"],
-["2 2 0 IF RSHIFT ELSE 1 ENDIF", "NOP", "RSHIFT disabled"],
-
-["0 1","EQUAL"],
-["1 1 ADD", "0 EQUAL"],
-["11 1 ADD 12 SUB", "11 EQUAL"],
-
-["2147483648 0 ADD", "NOP", "arithmetic operands must be in range [-2^31...2^31] "],
-["-2147483648 0 ADD", "NOP", "arithmetic operands must be in range [-2^31...2^31] "],
-["2147483647 DUP ADD", "4294967294 NUMEQUAL", "NUMEQUAL must be in numeric range"],
-["'abcdef' NOT", "0 EQUAL", "NOT is an arithmetic operand"],
-
-["2 DUP MUL", "4 EQUAL", "disabled"],
-["2 DUP DIV", "1 EQUAL", "disabled"],
-["2 2MUL", "4 EQUAL", "disabled"],
-["2 2DIV", "1 EQUAL", "disabled"],
-["7 3 MOD", "1 EQUAL", "disabled"],
-["2 2 LSHIFT", "8 EQUAL", "disabled"],
-["2 1 RSHIFT", "1 EQUAL", "disabled"],
-
-["1","NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 2 EQUAL"],
-["'NOP_1_to_10' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_11' EQUAL"],
-
-["0x50","1", "opcode 0x50 is reserved"],
-["1", "IF 0xba ELSE 1 ENDIF", "opcodes above NOP10 invalid if executed"],
-["1", "IF 0xbb ELSE 1 ENDIF"],
-["1", "IF 0xbc ELSE 1 ENDIF"],
-["1", "IF 0xbd ELSE 1 ENDIF"],
-["1", "IF 0xbe ELSE 1 ENDIF"],
-["1", "IF 0xbf ELSE 1 ENDIF"],
-["1", "IF 0xc0 ELSE 1 ENDIF"],
-["1", "IF 0xc1 ELSE 1 ENDIF"],
-["1", "IF 0xc2 ELSE 1 ENDIF"],
-["1", "IF 0xc3 ELSE 1 ENDIF"],
-["1", "IF 0xc4 ELSE 1 ENDIF"],
-["1", "IF 0xc5 ELSE 1 ENDIF"],
-["1", "IF 0xc6 ELSE 1 ENDIF"],
-["1", "IF 0xc7 ELSE 1 ENDIF"],
-["1", "IF 0xc8 ELSE 1 ENDIF"],
-["1", "IF 0xc9 ELSE 1 ENDIF"],
-["1", "IF 0xca ELSE 1 ENDIF"],
-["1", "IF 0xcb ELSE 1 ENDIF"],
-["1", "IF 0xcc ELSE 1 ENDIF"],
-["1", "IF 0xcd ELSE 1 ENDIF"],
-["1", "IF 0xce ELSE 1 ENDIF"],
-["1", "IF 0xcf ELSE 1 ENDIF"],
-["1", "IF 0xd0 ELSE 1 ENDIF"],
-["1", "IF 0xd1 ELSE 1 ENDIF"],
-["1", "IF 0xd2 ELSE 1 ENDIF"],
-["1", "IF 0xd3 ELSE 1 ENDIF"],
-["1", "IF 0xd4 ELSE 1 ENDIF"],
-["1", "IF 0xd5 ELSE 1 ENDIF"],
-["1", "IF 0xd6 ELSE 1 ENDIF"],
-["1", "IF 0xd7 ELSE 1 ENDIF"],
-["1", "IF 0xd8 ELSE 1 ENDIF"],
-["1", "IF 0xd9 ELSE 1 ENDIF"],
-["1", "IF 0xda ELSE 1 ENDIF"],
-["1", "IF 0xdb ELSE 1 ENDIF"],
-["1", "IF 0xdc ELSE 1 ENDIF"],
-["1", "IF 0xdd ELSE 1 ENDIF"],
-["1", "IF 0xde ELSE 1 ENDIF"],
-["1", "IF 0xdf ELSE 1 ENDIF"],
-["1", "IF 0xe0 ELSE 1 ENDIF"],
-["1", "IF 0xe1 ELSE 1 ENDIF"],
-["1", "IF 0xe2 ELSE 1 ENDIF"],
-["1", "IF 0xe3 ELSE 1 ENDIF"],
-["1", "IF 0xe4 ELSE 1 ENDIF"],
-["1", "IF 0xe5 ELSE 1 ENDIF"],
-["1", "IF 0xe6 ELSE 1 ENDIF"],
-["1", "IF 0xe7 ELSE 1 ENDIF"],
-["1", "IF 0xe8 ELSE 1 ENDIF"],
-["1", "IF 0xe9 ELSE 1 ENDIF"],
-["1", "IF 0xea ELSE 1 ENDIF"],
-["1", "IF 0xeb ELSE 1 ENDIF"],
-["1", "IF 0xec ELSE 1 ENDIF"],
-["1", "IF 0xed ELSE 1 ENDIF"],
-["1", "IF 0xee ELSE 1 ENDIF"],
-["1", "IF 0xef ELSE 1 ENDIF"],
-["1", "IF 0xf0 ELSE 1 ENDIF"],
-["1", "IF 0xf1 ELSE 1 ENDIF"],
-["1", "IF 0xf2 ELSE 1 ENDIF"],
-["1", "IF 0xf3 ELSE 1 ENDIF"],
-["1", "IF 0xf4 ELSE 1 ENDIF"],
-["1", "IF 0xf5 ELSE 1 ENDIF"],
-["1", "IF 0xf6 ELSE 1 ENDIF"],
-["1", "IF 0xf7 ELSE 1 ENDIF"],
-["1", "IF 0xf8 ELSE 1 ENDIF"],
-["1", "IF 0xf9 ELSE 1 ENDIF"],
-["1", "IF 0xfa ELSE 1 ENDIF"],
-["1", "IF 0xfb ELSE 1 ENDIF"],
-["1", "IF 0xfc ELSE 1 ENDIF"],
-["1", "IF 0xfd ELSE 1 ENDIF"],
-["1", "IF 0xfe ELSE 1 ENDIF"],
-["1", "IF 0xff ELSE 1 ENDIF"],
-
-["1 IF 1 ELSE", "0xff ENDIF", "invalid because scriptSig and scriptPubKey are processed separately"],
-
-["NOP", "RIPEMD160"],
-["NOP", "SHA1"],
-["NOP", "SHA256"],
-["NOP", "HASH160"],
-["NOP", "HASH256"],
+["
+Format is: [scriptPubKey, scriptSig, flags, ... comments]
+It is evaluated as if there was a crediting coinbase transaction with two 0
+pushes as scriptSig, and one output of 0 satoshi and given scriptPubKey,
+followed by a spending transaction which spends this output as only input (and
+correct prevout hash), using the given scriptSig. All nLockTimes are 0, all
+nSequences are max.
+"],
+
+["", "DEPTH", "P2SH,STRICTENC", "Test the test: we should have an empty stack after scriptSig evaluation"],
+[" ", "DEPTH", "P2SH,STRICTENC", "and multiple spaces should not change that."],
+[" ", "DEPTH", "P2SH,STRICTENC"],
+[" ", "DEPTH", "P2SH,STRICTENC"],
+
+["", "", "P2SH,STRICTENC"],
+["", "NOP", "P2SH,STRICTENC"],
+["", "NOP DEPTH", "P2SH,STRICTENC"],
+["NOP", "", "P2SH,STRICTENC"],
+["NOP", "DEPTH", "P2SH,STRICTENC"],
+["NOP","NOP", "P2SH,STRICTENC"],
+["NOP","NOP DEPTH", "P2SH,STRICTENC"],
+
+["DEPTH", "", "P2SH,STRICTENC"],
+
+["0x4c01","0x01 NOP", "P2SH,STRICTENC", "PUSHDATA1 with not enough bytes"],
+["0x4d0200ff","0x01 NOP", "P2SH,STRICTENC", "PUSHDATA2 with not enough bytes"],
+["0x4e03000000ffff","0x01 NOP", "P2SH,STRICTENC", "PUSHDATA4 with not enough bytes"],
+
+["1", "IF 0x50 ENDIF 1", "P2SH,STRICTENC", "0x50 is reserved"],
+["0x52", "0x5f ADD 0x60 EQUAL", "P2SH,STRICTENC", "0x51 through 0x60 push 1 through 16 onto stack"],
+["0","NOP", "P2SH,STRICTENC"],
+["1", "IF VER ELSE 1 ENDIF", "P2SH,STRICTENC", "VER non-functional"],
+["0", "IF VERIF ELSE 1 ENDIF", "P2SH,STRICTENC", "VERIF illegal everywhere"],
+["0", "IF ELSE 1 ELSE VERIF ENDIF", "P2SH,STRICTENC", "VERIF illegal everywhere"],
+["0", "IF VERNOTIF ELSE 1 ENDIF", "P2SH,STRICTENC", "VERNOTIF illegal everywhere"],
+["0", "IF ELSE 1 ELSE VERNOTIF ENDIF", "P2SH,STRICTENC", "VERNOTIF illegal everywhere"],
+
+["1 IF", "1 ENDIF", "P2SH,STRICTENC", "IF/ENDIF can't span scriptSig/scriptPubKey"],
+["1 IF 0 ENDIF", "1 ENDIF", "P2SH,STRICTENC"],
+["1 ELSE 0 ENDIF", "1", "P2SH,STRICTENC"],
+["0 NOTIF", "123", "P2SH,STRICTENC"],
+
+["0", "DUP IF ENDIF", "P2SH,STRICTENC"],
+["0", "IF 1 ENDIF", "P2SH,STRICTENC"],
+["0", "DUP IF ELSE ENDIF", "P2SH,STRICTENC"],
+["0", "IF 1 ELSE ENDIF", "P2SH,STRICTENC"],
+["0", "NOTIF ELSE 1 ENDIF", "P2SH,STRICTENC"],
+
+["0 1", "IF IF 1 ELSE 0 ENDIF ENDIF", "P2SH,STRICTENC"],
+["0 0", "IF IF 1 ELSE 0 ENDIF ENDIF", "P2SH,STRICTENC"],
+["1 0", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "P2SH,STRICTENC"],
+["0 1", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "P2SH,STRICTENC"],
+
+["0 0", "NOTIF IF 1 ELSE 0 ENDIF ENDIF", "P2SH,STRICTENC"],
+["0 1", "NOTIF IF 1 ELSE 0 ENDIF ENDIF", "P2SH,STRICTENC"],
+["1 1", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "P2SH,STRICTENC"],
+["0 0", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "P2SH,STRICTENC"],
+
+["1", "IF RETURN ELSE ELSE 1 ENDIF", "P2SH,STRICTENC", "Multiple ELSEs"],
+["1", "IF 1 ELSE ELSE RETURN ENDIF", "P2SH,STRICTENC"],
+
+["1", "ENDIF", "P2SH,STRICTENC", "Malformed IF/ELSE/ENDIF sequence"],
+["1", "ELSE ENDIF", "P2SH,STRICTENC"],
+["1", "ENDIF ELSE", "P2SH,STRICTENC"],
+["1", "ENDIF ELSE IF", "P2SH,STRICTENC"],
+["1", "IF ELSE ENDIF ELSE", "P2SH,STRICTENC"],
+["1", "IF ELSE ENDIF ELSE ENDIF", "P2SH,STRICTENC"],
+["1", "IF ENDIF ENDIF", "P2SH,STRICTENC"],
+["1", "IF ELSE ELSE ENDIF ENDIF", "P2SH,STRICTENC"],
+
+["1", "RETURN", "P2SH,STRICTENC"],
+["1", "DUP IF RETURN ENDIF", "P2SH,STRICTENC"],
+
+["1", "RETURN 'data'", "P2SH,STRICTENC", "canonical prunable txout format"],
+["0 IF", "RETURN ENDIF 1", "P2SH,STRICTENC", "still prunable because IF/ENDIF can't span scriptSig/scriptPubKey"],
+
+["0", "VERIFY 1", "P2SH,STRICTENC"],
+["1", "VERIFY", "P2SH,STRICTENC"],
+["1", "VERIFY 0", "P2SH,STRICTENC"],
+
+["1 TOALTSTACK", "FROMALTSTACK 1", "P2SH,STRICTENC", "alt stack not shared between sig/pubkey"],
+
+["IFDUP", "DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["DROP", "DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["DUP", "DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["1", "DUP 1 ADD 2 EQUALVERIFY 0 EQUAL", "P2SH,STRICTENC"],
+["NOP", "NIP", "P2SH,STRICTENC"],
+["NOP", "1 NIP", "P2SH,STRICTENC"],
+["NOP", "1 0 NIP", "P2SH,STRICTENC"],
+["NOP", "OVER 1", "P2SH,STRICTENC"],
+["1", "OVER", "P2SH,STRICTENC"],
+["0 1", "OVER DEPTH 3 EQUALVERIFY", "P2SH,STRICTENC"],
+["19 20 21", "PICK 19 EQUALVERIFY DEPTH 2 EQUAL", "P2SH,STRICTENC"],
+["NOP", "0 PICK", "P2SH,STRICTENC"],
+["1", "-1 PICK", "P2SH,STRICTENC"],
+["19 20 21", "0 PICK 20 EQUALVERIFY DEPTH 3 EQUAL", "P2SH,STRICTENC"],
+["19 20 21", "1 PICK 21 EQUALVERIFY DEPTH 3 EQUAL", "P2SH,STRICTENC"],
+["19 20 21", "2 PICK 22 EQUALVERIFY DEPTH 3 EQUAL", "P2SH,STRICTENC"],
+["NOP", "0 ROLL", "P2SH,STRICTENC"],
+["1", "-1 ROLL", "P2SH,STRICTENC"],
+["19 20 21", "0 ROLL 20 EQUALVERIFY DEPTH 2 EQUAL", "P2SH,STRICTENC"],
+["19 20 21", "1 ROLL 21 EQUALVERIFY DEPTH 2 EQUAL", "P2SH,STRICTENC"],
+["19 20 21", "2 ROLL 22 EQUALVERIFY DEPTH 2 EQUAL", "P2SH,STRICTENC"],
+["NOP", "ROT 1", "P2SH,STRICTENC"],
+["NOP", "1 ROT 1", "P2SH,STRICTENC"],
+["NOP", "1 2 ROT 1", "P2SH,STRICTENC"],
+["NOP", "0 1 2 ROT", "P2SH,STRICTENC"],
+["NOP", "SWAP 1", "P2SH,STRICTENC"],
+["1", "SWAP 1", "P2SH,STRICTENC"],
+["0 1", "SWAP 1 EQUALVERIFY", "P2SH,STRICTENC"],
+["NOP", "TUCK 1", "P2SH,STRICTENC"],
+["1", "TUCK 1", "P2SH,STRICTENC"],
+["1 0", "TUCK DEPTH 3 EQUALVERIFY SWAP 2DROP", "P2SH,STRICTENC"],
+["NOP", "2DUP 1", "P2SH,STRICTENC"],
+["1", "2DUP 1", "P2SH,STRICTENC"],
+["NOP", "3DUP 1", "P2SH,STRICTENC"],
+["1", "3DUP 1", "P2SH,STRICTENC"],
+["1 2", "3DUP 1", "P2SH,STRICTENC"],
+["NOP", "2OVER 1", "P2SH,STRICTENC"],
+["1", "2 3 2OVER 1", "P2SH,STRICTENC"],
+["NOP", "2SWAP 1", "P2SH,STRICTENC"],
+["1", "2 3 2SWAP 1", "P2SH,STRICTENC"],
+
+["'a' 'b'", "CAT", "P2SH,STRICTENC", "CAT disabled"],
+["'a' 'b' 0", "IF CAT ELSE 1 ENDIF", "P2SH,STRICTENC", "CAT disabled"],
+["'abc' 1 1", "SUBSTR", "P2SH,STRICTENC", "SUBSTR disabled"],
+["'abc' 1 1 0", "IF SUBSTR ELSE 1 ENDIF", "P2SH,STRICTENC", "SUBSTR disabled"],
+["'abc' 2 0", "IF LEFT ELSE 1 ENDIF", "P2SH,STRICTENC", "LEFT disabled"],
+["'abc' 2 0", "IF RIGHT ELSE 1 ENDIF", "P2SH,STRICTENC", "RIGHT disabled"],
+
+["NOP", "SIZE 1", "P2SH,STRICTENC"],
+
+["'abc'", "IF INVERT ELSE 1 ENDIF", "P2SH,STRICTENC", "INVERT disabled"],
+["1 2 0 IF AND ELSE 1 ENDIF", "NOP", "P2SH,STRICTENC", "AND disabled"],
+["1 2 0 IF OR ELSE 1 ENDIF", "NOP", "P2SH,STRICTENC", "OR disabled"],
+["1 2 0 IF XOR ELSE 1 ENDIF", "NOP", "P2SH,STRICTENC", "XOR disabled"],
+["2 0 IF 2MUL ELSE 1 ENDIF", "NOP", "P2SH,STRICTENC", "2MUL disabled"],
+["2 0 IF 2DIV ELSE 1 ENDIF", "NOP", "P2SH,STRICTENC", "2DIV disabled"],
+["2 2 0 IF MUL ELSE 1 ENDIF", "NOP", "P2SH,STRICTENC", "MUL disabled"],
+["2 2 0 IF DIV ELSE 1 ENDIF", "NOP", "P2SH,STRICTENC", "DIV disabled"],
+["2 2 0 IF MOD ELSE 1 ENDIF", "NOP", "P2SH,STRICTENC", "MOD disabled"],
+["2 2 0 IF LSHIFT ELSE 1 ENDIF", "NOP", "P2SH,STRICTENC", "LSHIFT disabled"],
+["2 2 0 IF RSHIFT ELSE 1 ENDIF", "NOP", "P2SH,STRICTENC", "RSHIFT disabled"],
+
+["0 1","EQUAL", "P2SH,STRICTENC"],
+["1 1 ADD", "0 EQUAL", "P2SH,STRICTENC"],
+["11 1 ADD 12 SUB", "11 EQUAL", "P2SH,STRICTENC"],
+
+["2147483648 0 ADD", "NOP", "P2SH,STRICTENC", "arithmetic operands must be in range [-2^31...2^31] "],
+["-2147483648 0 ADD", "NOP", "P2SH,STRICTENC", "arithmetic operands must be in range [-2^31...2^31] "],
+["2147483647 DUP ADD", "4294967294 NUMEQUAL", "P2SH,STRICTENC", "NUMEQUAL must be in numeric range"],
+["'abcdef' NOT", "0 EQUAL", "P2SH,STRICTENC", "NOT is an arithmetic operand"],
+
+["2 DUP MUL", "4 EQUAL", "P2SH,STRICTENC", "disabled"],
+["2 DUP DIV", "1 EQUAL", "P2SH,STRICTENC", "disabled"],
+["2 2MUL", "4 EQUAL", "P2SH,STRICTENC", "disabled"],
+["2 2DIV", "1 EQUAL", "P2SH,STRICTENC", "disabled"],
+["7 3 MOD", "1 EQUAL", "P2SH,STRICTENC", "disabled"],
+["2 2 LSHIFT", "8 EQUAL", "P2SH,STRICTENC", "disabled"],
+["2 1 RSHIFT", "1 EQUAL", "P2SH,STRICTENC", "disabled"],
+
+["1","NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 2 EQUAL", "P2SH,STRICTENC"],
+["'NOP_1_to_10' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_11' EQUAL", "P2SH,STRICTENC"],
+
+["0x50","1", "P2SH,STRICTENC", "opcode 0x50 is reserved"],
+["1", "IF 0xba ELSE 1 ENDIF", "P2SH,STRICTENC", "opcodes above NOP10 invalid if executed"],
+["1", "IF 0xbb ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xbc ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xbd ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xbe ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xbf ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xc0 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xc1 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xc2 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xc3 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xc4 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xc5 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xc6 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xc7 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xc8 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xc9 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xca ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xcb ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xcc ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xcd ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xce ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xcf ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xd0 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xd1 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xd2 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xd3 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xd4 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xd5 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xd6 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xd7 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xd8 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xd9 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xda ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xdb ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xdc ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xdd ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xde ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xdf ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xe0 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xe1 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xe2 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xe3 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xe4 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xe5 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xe6 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xe7 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xe8 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xe9 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xea ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xeb ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xec ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xed ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xee ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xef ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xf0 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xf1 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xf2 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xf3 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xf4 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xf5 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xf6 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xf7 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xf8 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xf9 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xfa ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xfb ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xfc ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xfd ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xfe ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 0xff ELSE 1 ENDIF", "P2SH,STRICTENC"],
+
+["1 IF 1 ELSE", "0xff ENDIF", "P2SH,STRICTENC", "invalid because scriptSig and scriptPubKey are processed separately"],
+
+["NOP", "RIPEMD160", "P2SH,STRICTENC"],
+["NOP", "SHA1", "P2SH,STRICTENC"],
+["NOP", "SHA256", "P2SH,STRICTENC"],
+["NOP", "HASH160", "P2SH,STRICTENC"],
+["NOP", "HASH256", "P2SH,STRICTENC"],
["NOP",
"'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'",
+"P2SH,STRICTENC",
">520 byte push"],
["0",
"IF 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' ENDIF 1",
+"P2SH,STRICTENC",
">520 byte push in non-executed IF branch"],
["1",
"0x61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161",
+"P2SH,STRICTENC",
">201 opcodes executed. 0x61 is NOP"],
["0",
"IF 0x6161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161 ENDIF 1",
+"P2SH,STRICTENC",
">201 opcodes including non-executed IF branch. 0x61 is NOP"],
["1 2 3 4 5 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f",
"1 2 3 4 5 6 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f",
+"P2SH,STRICTENC",
">1,000 stack size (0x6f is 3DUP)"],
["1 2 3 4 5 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f",
"1 TOALTSTACK 2 TOALTSTACK 3 4 5 6 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f",
+"P2SH,STRICTENC",
">1,000 stack+altstack size"],
["NOP",
"0 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f 2DUP 0x616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161",
+"P2SH,STRICTENC",
"10,001-byte scriptPubKey"],
-["NOP1","NOP10"],
-
-["1","VER", "OP_VER is reserved"],
-["1","VERIF", "OP_VERIF is reserved"],
-["1","VERNOTIF", "OP_VERNOTIF is reserved"],
-["1","RESERVED", "OP_RESERVED is reserved"],
-["1","RESERVED1", "OP_RESERVED1 is reserved"],
-["1","RESERVED2", "OP_RESERVED2 is reserved"],
-["1","0xba", "0xba == OP_NOP10 + 1"],
-
-["2147483648", "1ADD 1", "We cannot do math on 5-byte integers"],
-["2147483648", "NEGATE 1", "We cannot do math on 5-byte integers"],
-["-2147483648", "1ADD 1", "Because we use a sign bit, -2147483648 is also 5 bytes"],
-["2147483647", "1ADD 1SUB 1", "We cannot do math on 5-byte integers, even if the result is 4-bytes"],
-["2147483648", "1SUB 1", "We cannot do math on 5-byte integers, even if the result is 4-bytes"],
-
-["2147483648 1", "BOOLOR 1", "We cannot do BOOLOR on 5-byte integers (but we can still do IF etc)"],
-["2147483648 1", "BOOLAND 1", "We cannot do BOOLAND on 5-byte integers"],
-
-["1", "1 ENDIF", "ENDIF without IF"],
-["1", "IF 1", "IF without ENDIF"],
-["1 IF 1", "ENDIF", "IFs don't carry over"],
-
-["NOP", "IF 1 ENDIF", "The following tests check the if(stack.size() < N) tests in each opcode"],
-["NOP", "NOTIF 1 ENDIF", "They are here to catch copy-and-paste errors"],
-["NOP", "VERIFY 1", "Most of them are duplicated elsewhere,"],
-
-["NOP", "TOALTSTACK 1", "but, hey, more is always better, right?"],
-["1", "FROMALTSTACK"],
-["1", "2DROP 1"],
-["1", "2DUP"],
-["1 1", "3DUP"],
-["1 1 1", "2OVER"],
-["1 1 1 1 1", "2ROT"],
-["1 1 1", "2SWAP"],
-["NOP", "IFDUP 1"],
-["NOP", "DROP 1"],
-["NOP", "DUP 1"],
-["1", "NIP"],
-["1", "OVER"],
-["1 1 1 3", "PICK"],
-["0", "PICK 1"],
-["1 1 1 3", "ROLL"],
-["0", "ROLL 1"],
-["1 1", "ROT"],
-["1", "SWAP"],
-["1", "TUCK"],
-
-["NOP", "SIZE 1"],
-
-["1", "EQUAL 1"],
-["1", "EQUALVERIFY 1"],
-
-["NOP", "1ADD 1"],
-["NOP", "1SUB 1"],
-["NOP", "NEGATE 1"],
-["NOP", "ABS 1"],
-["NOP", "NOT 1"],
-["NOP", "0NOTEQUAL 1"],
-
-["1", "ADD"],
-["1", "SUB"],
-["1", "BOOLAND"],
-["1", "BOOLOR"],
-["1", "NUMEQUAL"],
-["1", "NUMEQUALVERIFY 1"],
-["1", "NUMNOTEQUAL"],
-["1", "LESSTHAN"],
-["1", "GREATERTHAN"],
-["1", "LESSTHANOREQUAL"],
-["1", "GREATERTHANOREQUAL"],
-["1", "MIN"],
-["1", "MAX"],
-["1 1", "WITHIN"],
-
-["NOP", "RIPEMD160 1"],
-["NOP", "SHA1 1"],
-["NOP", "SHA256 1"],
-["NOP", "HASH160 1"],
-["NOP", "HASH256 1"],
+["NOP1","NOP10", "P2SH,STRICTENC"],
+
+["1","VER", "P2SH,STRICTENC", "OP_VER is reserved"],
+["1","VERIF", "P2SH,STRICTENC", "OP_VERIF is reserved"],
+["1","VERNOTIF", "P2SH,STRICTENC", "OP_VERNOTIF is reserved"],
+["1","RESERVED", "P2SH,STRICTENC", "OP_RESERVED is reserved"],
+["1","RESERVED1", "P2SH,STRICTENC", "OP_RESERVED1 is reserved"],
+["1","RESERVED2", "P2SH,STRICTENC", "OP_RESERVED2 is reserved"],
+["1","0xba", "P2SH,STRICTENC", "0xba == OP_NOP10 + 1"],
+
+["2147483648", "1ADD 1", "P2SH,STRICTENC", "We cannot do math on 5-byte integers"],
+["2147483648", "NEGATE 1", "P2SH,STRICTENC", "We cannot do math on 5-byte integers"],
+["-2147483648", "1ADD 1", "P2SH,STRICTENC", "Because we use a sign bit, -2147483648 is also 5 bytes"],
+["2147483647", "1ADD 1SUB 1", "P2SH,STRICTENC", "We cannot do math on 5-byte integers, even if the result is 4-bytes"],
+["2147483648", "1SUB 1", "P2SH,STRICTENC", "We cannot do math on 5-byte integers, even if the result is 4-bytes"],
+
+["2147483648 1", "BOOLOR 1", "P2SH,STRICTENC", "We cannot do BOOLOR on 5-byte integers (but we can still do IF etc)"],
+["2147483648 1", "BOOLAND 1", "P2SH,STRICTENC", "We cannot do BOOLAND on 5-byte integers"],
+
+["1", "1 ENDIF", "P2SH,STRICTENC", "ENDIF without IF"],
+["1", "IF 1", "P2SH,STRICTENC", "IF without ENDIF"],
+["1 IF 1", "ENDIF", "P2SH,STRICTENC", "IFs don't carry over"],
+
+["NOP", "IF 1 ENDIF", "P2SH,STRICTENC", "The following tests check the if(stack.size() < N) tests in each opcode"],
+["NOP", "NOTIF 1 ENDIF", "P2SH,STRICTENC", "They are here to catch copy-and-paste errors"],
+["NOP", "VERIFY 1", "P2SH,STRICTENC", "Most of them are duplicated elsewhere,"],
+
+["NOP", "TOALTSTACK 1", "P2SH,STRICTENC", "but, hey, more is always better, right?"],
+["1", "FROMALTSTACK", "P2SH,STRICTENC"],
+["1", "2DROP 1", "P2SH,STRICTENC"],
+["1", "2DUP", "P2SH,STRICTENC"],
+["1 1", "3DUP", "P2SH,STRICTENC"],
+["1 1 1", "2OVER", "P2SH,STRICTENC"],
+["1 1 1 1 1", "2ROT", "P2SH,STRICTENC"],
+["1 1 1", "2SWAP", "P2SH,STRICTENC"],
+["NOP", "IFDUP 1", "P2SH,STRICTENC"],
+["NOP", "DROP 1", "P2SH,STRICTENC"],
+["NOP", "DUP 1", "P2SH,STRICTENC"],
+["1", "NIP", "P2SH,STRICTENC"],
+["1", "OVER", "P2SH,STRICTENC"],
+["1 1 1 3", "PICK", "P2SH,STRICTENC"],
+["0", "PICK 1", "P2SH,STRICTENC"],
+["1 1 1 3", "ROLL", "P2SH,STRICTENC"],
+["0", "ROLL 1", "P2SH,STRICTENC"],
+["1 1", "ROT", "P2SH,STRICTENC"],
+["1", "SWAP", "P2SH,STRICTENC"],
+["1", "TUCK", "P2SH,STRICTENC"],
+
+["NOP", "SIZE 1", "P2SH,STRICTENC"],
+
+["1", "EQUAL 1", "P2SH,STRICTENC"],
+["1", "EQUALVERIFY 1", "P2SH,STRICTENC"],
+
+["NOP", "1ADD 1", "P2SH,STRICTENC"],
+["NOP", "1SUB 1", "P2SH,STRICTENC"],
+["NOP", "NEGATE 1", "P2SH,STRICTENC"],
+["NOP", "ABS 1", "P2SH,STRICTENC"],
+["NOP", "NOT 1", "P2SH,STRICTENC"],
+["NOP", "0NOTEQUAL 1", "P2SH,STRICTENC"],
+
+["1", "ADD", "P2SH,STRICTENC"],
+["1", "SUB", "P2SH,STRICTENC"],
+["1", "BOOLAND", "P2SH,STRICTENC"],
+["1", "BOOLOR", "P2SH,STRICTENC"],
+["1", "NUMEQUAL", "P2SH,STRICTENC"],
+["1", "NUMEQUALVERIFY 1", "P2SH,STRICTENC"],
+["1", "NUMNOTEQUAL", "P2SH,STRICTENC"],
+["1", "LESSTHAN", "P2SH,STRICTENC"],
+["1", "GREATERTHAN", "P2SH,STRICTENC"],
+["1", "LESSTHANOREQUAL", "P2SH,STRICTENC"],
+["1", "GREATERTHANOREQUAL", "P2SH,STRICTENC"],
+["1", "MIN", "P2SH,STRICTENC"],
+["1", "MAX", "P2SH,STRICTENC"],
+["1 1", "WITHIN", "P2SH,STRICTENC"],
+
+["NOP", "RIPEMD160 1", "P2SH,STRICTENC"],
+["NOP", "SHA1 1", "P2SH,STRICTENC"],
+["NOP", "SHA256 1", "P2SH,STRICTENC"],
+["NOP", "HASH160 1", "P2SH,STRICTENC"],
+["NOP", "HASH256 1", "P2SH,STRICTENC"],
["",
"0 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG",
+"P2SH,STRICTENC",
"202 CHECKMULTISIGS, fails due to 201 op limit"],
["1",
-"0 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY"],
+"0 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY 0 0 CHECKMULTISIGVERIFY",
+"P2SH,STRICTENC"],
["",
"NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG",
+"P2SH,STRICTENC",
"Fails due to 201 sig op limit"],
["1",
-"NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY"],
+"NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY",
+"P2SH,STRICTENC"],
-["0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21", "21 CHECKMULTISIG 1", "nPubKeys > 20"],
-["0 'sig' 1 0", "CHECKMULTISIG 1", "nSigs > nPubKeys"],
+["0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21", "21 CHECKMULTISIG 1", "P2SH,STRICTENC", "nPubKeys > 20"],
+["0 'sig' 1 0", "CHECKMULTISIG 1", "P2SH,STRICTENC", "nSigs > nPubKeys"],
-["NOP 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL", "Tests for Script.IsPushOnly()"],
-["NOP1 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL"],
+["NOP 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL", "P2SH,STRICTENC", "Tests for Script.IsPushOnly()"],
+["NOP1 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL", "P2SH,STRICTENC"],
-["0 0x01 0x50", "HASH160 0x14 0xece424a6bb6ddf4db592c0faed60685047a361b1 EQUAL", "OP_RESERVED in P2SH should fail"],
-["0 0x01 VER", "HASH160 0x14 0x0f4d7845db968f2a81b530b6f3c1d6246d4c7e01 EQUAL", "OP_VER in P2SH should fail"],
+["0 0x01 0x50", "HASH160 0x14 0xece424a6bb6ddf4db592c0faed60685047a361b1 EQUAL", "P2SH,STRICTENC", "OP_RESERVED in P2SH should fail"],
+["0 0x01 VER", "HASH160 0x14 0x0f4d7845db968f2a81b530b6f3c1d6246d4c7e01 EQUAL", "P2SH,STRICTENC", "OP_VER in P2SH should fail"],
+
+["0x00", "'00' EQUAL", "P2SH,STRICTENC", "Basic OP_0 execution"],
+
+["0x48 0x3045022100ea4d62e1fb351ad977596457bb01dfce58e050541784277bd825c33bd98c2a9502203003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkeyhash with wrong signature"],
+["0x47 0x304402207d09de5e34968c3f8b27d8217f173629f1106ee5216aa11d6b1f9813b3a214060220610a6ed25c704f901c6278f4f57fb11eadefdf0b22df298cfb6ce7ea84c86bf401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkeyhash using an anyonecanpay sighash"],
+["0x47 0x3044022028686fb3c8d3e5068cc9924c494fb5026df201d23340896da62fe9bb73fd9d5f02202a239609524959c4ca3651fd0cc48245b0b240862146fc579f3a962a4f46942b01", "0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkey with wrong signature"],
+["0x47 0x3044022054cb0a3fca8694a0c231848ed9f965078148fd653e49dd4b6981fadac0f5ba0702204085be5af427d4561f13a07fd5a1c5ab0ff02126e9ba191448f5a9dae0da585301 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 0x19 0x76a914751e76e8199196d454941c45d1b3a323f1433bd688ac", "HASH160 0x14 0xcd7b44d0b03f2d026d1e586d7ae18903b0d385f6 EQUAL", "P2SH,STRICTENC", "P2SH with a pay to pubkeyhash inside with wrong signature"],
+["0 0x48 0x3045022100e1c4e8800bd00c9ec3cd3df0e53e63bc5e8c018d0b68099a652f0b121f1a7e020220108dab275be7d1358530d3451d48aed747af77cc54e0423cbae5c572b2e1abb801", "1 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 1 CHECKMULTISIG", "P2SH,STRICTENC", "Raw multisig with one pubkey with wrong signature"],
+["0x49 0x304602220000ea4d62e1fb351ad977596457bb01dfce58e050541774277bd825c33bd98c2a9502203003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkeyhash with non-DER signature (too much R padding)"],
+["0x47 0x30440220ea4d62e1fb351ad977596457bb01dfce58e050541774277bd825c33bd98c2a9502203003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkeyhash with non-DER signature (too little R padding)"],
+["0x49 0x3046022100ea4d62e1fb351ad977596457bb01dfce58e050541774277bd825c33bd98c2a950221003003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkeyhash with non-DER signature (too much S padding)"],
+["0x48 0x3045022100e6eda3fd34862078233463cae19f0b47995e3f892102e5b175175e92a9163cc402204bf58445819093638481084322b61a2d49b68c96fd6fea17ed494722d0d67b4f01", "0x41 0x0679be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG", "P2SH,STRICTENC", "Pay to pubkey with hybrid pubkey encoding"],
+["0x48 0x304502203b56d65863e0cdb89313043c2402f46f518c31658648151b01ec6b5b6c89206a022100d71efefb4c24fab36abb44ade106963d8114c5af1bda033faa1923f54ec4ea6a01", "0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 CHECKSIG", "P2SH,STRICTENC,LOW_S", "Pay to pubkey with high S"],
+["0x47 0x3044022054cb0a3fca8694a0c231848fd9f965078148fd653e49dd4b6980fadac0f5ba0702204085be5af427d4561f13a07fd5a1c5ab0ff02126e9ba191448f5a9dae0da585301 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 0x19 0x76a914751e76e8199196d454941c45d1b3a323f1433bd688ac", "HASH160 0x14 0xcd7b44d0b03f2d026d1e586d7ae18903b0d385f6 EQUAL", "P2SH,STRICTENC", "P2SH with a pay to pubkeyhash inside with invalid signature"],
+["1 0x48 0x3045022100e1c4e8800bd00c9ec3cd3de0e53e63bc5e8c018d0b68099a652f0b121f1a7e020220108dab275be7d1358530d3451d48aed747af77cc54e0423cbae5c572b2e1abb801", "1 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 1 CHECKMULTISIG", "P2SH,STRICTENC,NULLDUMMY", "Raw multisig with one pubkey with non-zero dummy"],
+
+["The End"]
-["0x00", "'00' EQUAL", "Basic OP_0 execution"]
]
diff --git a/src/test/data/script_valid.json b/src/test/data/script_valid.json
index 082c65efed..e0b527996c 100644
--- a/src/test/data/script_valid.json
+++ b/src/test/data/script_valid.json
@@ -1,510 +1,546 @@
[
-["", "DEPTH 0 EQUAL", "Test the test: we should have an empty stack after scriptSig evaluation"],
-[" ", "DEPTH 0 EQUAL", "and multiple spaces should not change that."],
-[" ", "DEPTH 0 EQUAL"],
-[" ", "DEPTH 0 EQUAL"],
-["1 2", "2 EQUALVERIFY 1 EQUAL", "Similarly whitespace around and between symbols"],
-["1 2", "2 EQUALVERIFY 1 EQUAL"],
-[" 1 2", "2 EQUALVERIFY 1 EQUAL"],
-["1 2 ", "2 EQUALVERIFY 1 EQUAL"],
-[" 1 2 ", "2 EQUALVERIFY 1 EQUAL"],
-
-["1", ""],
-["0x02 0x01 0x00", "", "all bytes are significant, not only the last one"],
-["0x09 0x00000000 0x00000000 0x10", "", "equals zero when cast to Int64"],
-
-["0x01 0x0b", "11 EQUAL", "push 1 byte"],
-["0x02 0x417a", "'Az' EQUAL"],
+["
+Format is: [scriptPubKey, scriptSig, flags, ... comments]
+It is evaluated as if there was a crediting coinbase transaction with two 0
+pushes as scriptSig, and one output of 0 satoshi and given scriptPubKey,
+followed by a spending transaction which spends this output as only input (and
+correct prevout hash), using the given scriptSig. All nLockTimes are 0, all
+nSequences are max.
+"],
+
+["", "DEPTH 0 EQUAL", "P2SH,STRICTENC", "Test the test: we should have an empty stack after scriptSig evaluation"],
+[" ", "DEPTH 0 EQUAL", "P2SH,STRICTENC", "and multiple spaces should not change that."],
+[" ", "DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+[" ", "DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["1 2", "2 EQUALVERIFY 1 EQUAL", "P2SH,STRICTENC", "Similarly whitespace around and between symbols"],
+["1 2", "2 EQUALVERIFY 1 EQUAL", "P2SH,STRICTENC"],
+[" 1 2", "2 EQUALVERIFY 1 EQUAL", "P2SH,STRICTENC"],
+["1 2 ", "2 EQUALVERIFY 1 EQUAL", "P2SH,STRICTENC"],
+[" 1 2 ", "2 EQUALVERIFY 1 EQUAL", "P2SH,STRICTENC"],
+
+["1", "", "P2SH,STRICTENC"],
+["0x02 0x01 0x00", "", "P2SH,STRICTENC", "all bytes are significant, not only the last one"],
+["0x09 0x00000000 0x00000000 0x10", "", "P2SH,STRICTENC", "equals zero when cast to Int64"],
+
+["0x01 0x0b", "11 EQUAL", "P2SH,STRICTENC", "push 1 byte"],
+["0x02 0x417a", "'Az' EQUAL", "P2SH,STRICTENC"],
["0x4b 0x417a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a",
- "'Azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' EQUAL", "push 75 bytes"],
-
-["0x4c 0x01 0x07","7 EQUAL", "0x4c is OP_PUSHDATA1"],
-["0x4d 0x0100 0x08","8 EQUAL", "0x4d is OP_PUSHDATA2"],
-["0x4e 0x01000000 0x09","9 EQUAL", "0x4e is OP_PUSHDATA4"],
-
-["0x4c 0x00","0 EQUAL"],
-["0x4d 0x0000","0 EQUAL"],
-["0x4e 0x00000000","0 EQUAL"],
-["0x4f 1000 ADD","999 EQUAL"],
-["0", "IF 0x50 ENDIF 1", "0x50 is reserved (ok if not executed)"],
-["0x51", "0x5f ADD 0x60 EQUAL", "0x51 through 0x60 push 1 through 16 onto stack"],
-["1","NOP"],
-["0", "IF VER ELSE 1 ENDIF", "VER non-functional (ok if not executed)"],
-["0", "IF RESERVED RESERVED1 RESERVED2 ELSE 1 ENDIF", "RESERVED ok in un-executed IF"],
-
-["1", "DUP IF ENDIF"],
-["1", "IF 1 ENDIF"],
-["1", "DUP IF ELSE ENDIF"],
-["1", "IF 1 ELSE ENDIF"],
-["0", "IF ELSE 1 ENDIF"],
-
-["1 1", "IF IF 1 ELSE 0 ENDIF ENDIF"],
-["1 0", "IF IF 1 ELSE 0 ENDIF ENDIF"],
-["1 1", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-["0 0", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-
-["1 0", "NOTIF IF 1 ELSE 0 ENDIF ENDIF"],
-["1 1", "NOTIF IF 1 ELSE 0 ENDIF ENDIF"],
-["1 0", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-["0 1", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-
-["0", "IF 0 ELSE 1 ELSE 0 ENDIF", "Multiple ELSE's are valid and executed inverts on each ELSE encountered"],
-["1", "IF 1 ELSE 0 ELSE ENDIF"],
-["1", "IF ELSE 0 ELSE 1 ENDIF"],
-["1", "IF 1 ELSE 0 ELSE 1 ENDIF ADD 2 EQUAL"],
-["'' 1", "IF SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ENDIF 0x14 0x68ca4fec736264c13b859bac43d5173df6871682 EQUAL"],
-
-["1", "NOTIF 0 ELSE 1 ELSE 0 ENDIF", "Multiple ELSE's are valid and execution inverts on each ELSE encountered"],
-["0", "NOTIF 1 ELSE 0 ELSE ENDIF"],
-["0", "NOTIF ELSE 0 ELSE 1 ENDIF"],
-["0", "NOTIF 1 ELSE 0 ELSE 1 ENDIF ADD 2 EQUAL"],
-["'' 0", "NOTIF SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ENDIF 0x14 0x68ca4fec736264c13b859bac43d5173df6871682 EQUAL"],
-
-["0", "IF 1 IF RETURN ELSE RETURN ELSE RETURN ENDIF ELSE 1 IF 1 ELSE RETURN ELSE 1 ENDIF ELSE RETURN ENDIF ADD 2 EQUAL", "Nested ELSE ELSE"],
-["1", "NOTIF 0 NOTIF RETURN ELSE RETURN ELSE RETURN ENDIF ELSE 0 NOTIF 1 ELSE RETURN ELSE 1 ENDIF ELSE RETURN ENDIF ADD 2 EQUAL"],
-
-["0", "IF RETURN ENDIF 1", "RETURN only works if executed"],
-
-["1 1", "VERIFY"],
-["1 0x05 0x01 0x00 0x00 0x00 0x00", "VERIFY", "values >4 bytes can be cast to boolean"],
-
-["10 0 11 TOALTSTACK DROP FROMALTSTACK", "ADD 21 EQUAL"],
-["'gavin_was_here' TOALTSTACK 11 FROMALTSTACK", "'gavin_was_here' EQUALVERIFY 11 EQUAL"],
-
-["0 IFDUP", "DEPTH 1 EQUALVERIFY 0 EQUAL"],
-["1 IFDUP", "DEPTH 2 EQUALVERIFY 1 EQUALVERIFY 1 EQUAL"],
-["0 DROP", "DEPTH 0 EQUAL"],
-["0", "DUP 1 ADD 1 EQUALVERIFY 0 EQUAL"],
-["0 1", "NIP"],
-["1 0", "OVER DEPTH 3 EQUALVERIFY"],
-["22 21 20", "0 PICK 20 EQUALVERIFY DEPTH 3 EQUAL"],
-["22 21 20", "1 PICK 21 EQUALVERIFY DEPTH 3 EQUAL"],
-["22 21 20", "2 PICK 22 EQUALVERIFY DEPTH 3 EQUAL"],
-["22 21 20", "0 ROLL 20 EQUALVERIFY DEPTH 2 EQUAL"],
-["22 21 20", "1 ROLL 21 EQUALVERIFY DEPTH 2 EQUAL"],
-["22 21 20", "2 ROLL 22 EQUALVERIFY DEPTH 2 EQUAL"],
-["22 21 20", "ROT 22 EQUAL"],
-["22 21 20", "ROT DROP 20 EQUAL"],
-["22 21 20", "ROT DROP DROP 21 EQUAL"],
-["22 21 20", "ROT ROT 21 EQUAL"],
-["22 21 20", "ROT ROT ROT 20 EQUAL"],
-["25 24 23 22 21 20", "2ROT 24 EQUAL"],
-["25 24 23 22 21 20", "2ROT DROP 25 EQUAL"],
-["25 24 23 22 21 20", "2ROT 2DROP 20 EQUAL"],
-["25 24 23 22 21 20", "2ROT 2DROP DROP 21 EQUAL"],
-["25 24 23 22 21 20", "2ROT 2DROP 2DROP 22 EQUAL"],
-["25 24 23 22 21 20", "2ROT 2DROP 2DROP DROP 23 EQUAL"],
-["25 24 23 22 21 20", "2ROT 2ROT 22 EQUAL"],
-["25 24 23 22 21 20", "2ROT 2ROT 2ROT 20 EQUAL"],
-["1 0", "SWAP 1 EQUALVERIFY 0 EQUAL"],
-["0 1", "TUCK DEPTH 3 EQUALVERIFY SWAP 2DROP"],
-["13 14", "2DUP ROT EQUALVERIFY EQUAL"],
-["-1 0 1 2", "3DUP DEPTH 7 EQUALVERIFY ADD ADD 3 EQUALVERIFY 2DROP 0 EQUALVERIFY"],
-["1 2 3 5", "2OVER ADD ADD 8 EQUALVERIFY ADD ADD 6 EQUAL"],
-["1 3 5 7", "2SWAP ADD 4 EQUALVERIFY ADD 12 EQUAL"],
-["0", "SIZE 0 EQUAL"],
-["1", "SIZE 1 EQUAL"],
-["127", "SIZE 1 EQUAL"],
-["128", "SIZE 2 EQUAL"],
-["32767", "SIZE 2 EQUAL"],
-["32768", "SIZE 3 EQUAL"],
-["8388607", "SIZE 3 EQUAL"],
-["8388608", "SIZE 4 EQUAL"],
-["2147483647", "SIZE 4 EQUAL"],
-["2147483648", "SIZE 5 EQUAL"],
-["549755813887", "SIZE 5 EQUAL"],
-["549755813888", "SIZE 6 EQUAL"],
-["9223372036854775807", "SIZE 8 EQUAL"],
-["-1", "SIZE 1 EQUAL"],
-["-127", "SIZE 1 EQUAL"],
-["-128", "SIZE 2 EQUAL"],
-["-32767", "SIZE 2 EQUAL"],
-["-32768", "SIZE 3 EQUAL"],
-["-8388607", "SIZE 3 EQUAL"],
-["-8388608", "SIZE 4 EQUAL"],
-["-2147483647", "SIZE 4 EQUAL"],
-["-2147483648", "SIZE 5 EQUAL"],
-["-549755813887", "SIZE 5 EQUAL"],
-["-549755813888", "SIZE 6 EQUAL"],
-["-9223372036854775807", "SIZE 8 EQUAL"],
-["'abcdefghijklmnopqrstuvwxyz'", "SIZE 26 EQUAL"],
-
-["42", "SIZE 1 EQUALVERIFY 42 EQUAL", "SIZE does not consume argument"],
-
-["2 -2 ADD", "0 EQUAL"],
-["2147483647 -2147483647 ADD", "0 EQUAL"],
-["-1 -1 ADD", "-2 EQUAL"],
-
-["0 0","EQUAL"],
-["1 1 ADD", "2 EQUAL"],
-["1 1ADD", "2 EQUAL"],
-["111 1SUB", "110 EQUAL"],
-["111 1 ADD 12 SUB", "100 EQUAL"],
-["0 ABS", "0 EQUAL"],
-["16 ABS", "16 EQUAL"],
-["-16 ABS", "-16 NEGATE EQUAL"],
-["0 NOT", "NOP"],
-["1 NOT", "0 EQUAL"],
-["11 NOT", "0 EQUAL"],
-["0 0NOTEQUAL", "0 EQUAL"],
-["1 0NOTEQUAL", "1 EQUAL"],
-["111 0NOTEQUAL", "1 EQUAL"],
-["-111 0NOTEQUAL", "1 EQUAL"],
-["1 1 BOOLAND", "NOP"],
-["1 0 BOOLAND", "NOT"],
-["0 1 BOOLAND", "NOT"],
-["0 0 BOOLAND", "NOT"],
-["16 17 BOOLAND", "NOP"],
-["1 1 BOOLOR", "NOP"],
-["1 0 BOOLOR", "NOP"],
-["0 1 BOOLOR", "NOP"],
-["0 0 BOOLOR", "NOT"],
-["16 17 BOOLOR", "NOP"],
-["11 10 1 ADD", "NUMEQUAL"],
-["11 10 1 ADD", "NUMEQUALVERIFY 1"],
-["11 10 1 ADD", "NUMNOTEQUAL NOT"],
-["111 10 1 ADD", "NUMNOTEQUAL"],
-["11 10", "LESSTHAN NOT"],
-["4 4", "LESSTHAN NOT"],
-["10 11", "LESSTHAN"],
-["-11 11", "LESSTHAN"],
-["-11 -10", "LESSTHAN"],
-["11 10", "GREATERTHAN"],
-["4 4", "GREATERTHAN NOT"],
-["10 11", "GREATERTHAN NOT"],
-["-11 11", "GREATERTHAN NOT"],
-["-11 -10", "GREATERTHAN NOT"],
-["11 10", "LESSTHANOREQUAL NOT"],
-["4 4", "LESSTHANOREQUAL"],
-["10 11", "LESSTHANOREQUAL"],
-["-11 11", "LESSTHANOREQUAL"],
-["-11 -10", "LESSTHANOREQUAL"],
-["11 10", "GREATERTHANOREQUAL"],
-["4 4", "GREATERTHANOREQUAL"],
-["10 11", "GREATERTHANOREQUAL NOT"],
-["-11 11", "GREATERTHANOREQUAL NOT"],
-["-11 -10", "GREATERTHANOREQUAL NOT"],
-["1 0 MIN", "0 NUMEQUAL"],
-["0 1 MIN", "0 NUMEQUAL"],
-["-1 0 MIN", "-1 NUMEQUAL"],
-["0 -2147483647 MIN", "-2147483647 NUMEQUAL"],
-["2147483647 0 MAX", "2147483647 NUMEQUAL"],
-["0 100 MAX", "100 NUMEQUAL"],
-["-100 0 MAX", "0 NUMEQUAL"],
-["0 -2147483647 MAX", "0 NUMEQUAL"],
-["0 0 1", "WITHIN"],
-["1 0 1", "WITHIN NOT"],
-["0 -2147483647 2147483647", "WITHIN"],
-["-1 -100 100", "WITHIN"],
-["11 -100 100", "WITHIN"],
-["-2147483647 -100 100", "WITHIN NOT"],
-["2147483647 -100 100", "WITHIN NOT"],
-
-["2147483647 2147483647 SUB", "0 EQUAL"],
-["2147483647 DUP ADD", "4294967294 EQUAL", ">32 bit EQUAL is valid"],
-["2147483647 NEGATE DUP ADD", "-4294967294 EQUAL"],
-
-["''", "RIPEMD160 0x14 0x9c1185a5c5e9fc54612808977ee8f548b2258d31 EQUAL"],
-["'a'", "RIPEMD160 0x14 0x0bdc9d2d256b3ee9daae347be6f4dc835a467ffe EQUAL"],
-["'abcdefghijklmnopqrstuvwxyz'", "RIPEMD160 0x14 0xf71c27109c692c1b56bbdceb5b9d2865b3708dbc EQUAL"],
-["''", "SHA1 0x14 0xda39a3ee5e6b4b0d3255bfef95601890afd80709 EQUAL"],
-["'a'", "SHA1 0x14 0x86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 EQUAL"],
-["'abcdefghijklmnopqrstuvwxyz'", "SHA1 0x14 0x32d10c7b8cf96570ca04ce37f2a19d84240d3a89 EQUAL"],
-["''", "SHA256 0x20 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 EQUAL"],
-["'a'", "SHA256 0x20 0xca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb EQUAL"],
-["'abcdefghijklmnopqrstuvwxyz'", "SHA256 0x20 0x71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73 EQUAL"],
-["''", "DUP HASH160 SWAP SHA256 RIPEMD160 EQUAL"],
-["''", "DUP HASH256 SWAP SHA256 SHA256 EQUAL"],
-["''", "NOP HASH160 0x14 0xb472a266d0bd89c13706a4132ccfb16f7c3b9fcb EQUAL"],
-["'a'", "HASH160 NOP 0x14 0x994355199e516ff76c4fa4aab39337b9d84cf12b EQUAL"],
-["'abcdefghijklmnopqrstuvwxyz'", "HASH160 0x4c 0x14 0xc286a1af0947f58d1ad787385b1c2c4a976f9e71 EQUAL"],
-["''", "HASH256 0x20 0x5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456 EQUAL"],
-["'a'", "HASH256 0x20 0xbf5d3affb73efd2ec6c36ad3112dd933efed63c4e1cbffcfa88e2759c144f2d8 EQUAL"],
-["'abcdefghijklmnopqrstuvwxyz'", "HASH256 0x4c 0x20 0xca139bc10c2f660da42666f72e89a225936fc60f193c161124a672050c434671 EQUAL"],
-
-
-["1","NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL"],
-["'NOP_1_to_10' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_10' EQUAL"],
-
-["0", "IF 0xba ELSE 1 ENDIF", "opcodes above NOP10 invalid if executed"],
-["0", "IF 0xbb ELSE 1 ENDIF"],
-["0", "IF 0xbc ELSE 1 ENDIF"],
-["0", "IF 0xbd ELSE 1 ENDIF"],
-["0", "IF 0xbe ELSE 1 ENDIF"],
-["0", "IF 0xbf ELSE 1 ENDIF"],
-["0", "IF 0xc0 ELSE 1 ENDIF"],
-["0", "IF 0xc1 ELSE 1 ENDIF"],
-["0", "IF 0xc2 ELSE 1 ENDIF"],
-["0", "IF 0xc3 ELSE 1 ENDIF"],
-["0", "IF 0xc4 ELSE 1 ENDIF"],
-["0", "IF 0xc5 ELSE 1 ENDIF"],
-["0", "IF 0xc6 ELSE 1 ENDIF"],
-["0", "IF 0xc7 ELSE 1 ENDIF"],
-["0", "IF 0xc8 ELSE 1 ENDIF"],
-["0", "IF 0xc9 ELSE 1 ENDIF"],
-["0", "IF 0xca ELSE 1 ENDIF"],
-["0", "IF 0xcb ELSE 1 ENDIF"],
-["0", "IF 0xcc ELSE 1 ENDIF"],
-["0", "IF 0xcd ELSE 1 ENDIF"],
-["0", "IF 0xce ELSE 1 ENDIF"],
-["0", "IF 0xcf ELSE 1 ENDIF"],
-["0", "IF 0xd0 ELSE 1 ENDIF"],
-["0", "IF 0xd1 ELSE 1 ENDIF"],
-["0", "IF 0xd2 ELSE 1 ENDIF"],
-["0", "IF 0xd3 ELSE 1 ENDIF"],
-["0", "IF 0xd4 ELSE 1 ENDIF"],
-["0", "IF 0xd5 ELSE 1 ENDIF"],
-["0", "IF 0xd6 ELSE 1 ENDIF"],
-["0", "IF 0xd7 ELSE 1 ENDIF"],
-["0", "IF 0xd8 ELSE 1 ENDIF"],
-["0", "IF 0xd9 ELSE 1 ENDIF"],
-["0", "IF 0xda ELSE 1 ENDIF"],
-["0", "IF 0xdb ELSE 1 ENDIF"],
-["0", "IF 0xdc ELSE 1 ENDIF"],
-["0", "IF 0xdd ELSE 1 ENDIF"],
-["0", "IF 0xde ELSE 1 ENDIF"],
-["0", "IF 0xdf ELSE 1 ENDIF"],
-["0", "IF 0xe0 ELSE 1 ENDIF"],
-["0", "IF 0xe1 ELSE 1 ENDIF"],
-["0", "IF 0xe2 ELSE 1 ENDIF"],
-["0", "IF 0xe3 ELSE 1 ENDIF"],
-["0", "IF 0xe4 ELSE 1 ENDIF"],
-["0", "IF 0xe5 ELSE 1 ENDIF"],
-["0", "IF 0xe6 ELSE 1 ENDIF"],
-["0", "IF 0xe7 ELSE 1 ENDIF"],
-["0", "IF 0xe8 ELSE 1 ENDIF"],
-["0", "IF 0xe9 ELSE 1 ENDIF"],
-["0", "IF 0xea ELSE 1 ENDIF"],
-["0", "IF 0xeb ELSE 1 ENDIF"],
-["0", "IF 0xec ELSE 1 ENDIF"],
-["0", "IF 0xed ELSE 1 ENDIF"],
-["0", "IF 0xee ELSE 1 ENDIF"],
-["0", "IF 0xef ELSE 1 ENDIF"],
-["0", "IF 0xf0 ELSE 1 ENDIF"],
-["0", "IF 0xf1 ELSE 1 ENDIF"],
-["0", "IF 0xf2 ELSE 1 ENDIF"],
-["0", "IF 0xf3 ELSE 1 ENDIF"],
-["0", "IF 0xf4 ELSE 1 ENDIF"],
-["0", "IF 0xf5 ELSE 1 ENDIF"],
-["0", "IF 0xf6 ELSE 1 ENDIF"],
-["0", "IF 0xf7 ELSE 1 ENDIF"],
-["0", "IF 0xf8 ELSE 1 ENDIF"],
-["0", "IF 0xf9 ELSE 1 ENDIF"],
-["0", "IF 0xfa ELSE 1 ENDIF"],
-["0", "IF 0xfb ELSE 1 ENDIF"],
-["0", "IF 0xfc ELSE 1 ENDIF"],
-["0", "IF 0xfd ELSE 1 ENDIF"],
-["0", "IF 0xfe ELSE 1 ENDIF"],
-["0", "IF 0xff ELSE 1 ENDIF"],
+ "'Azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' EQUAL", "P2SH,STRICTENC", "push 75 bytes"],
+
+["0x4c 0x01 0x07","7 EQUAL", "P2SH,STRICTENC", "0x4c is OP_PUSHDATA1"],
+["0x4d 0x0100 0x08","8 EQUAL", "P2SH,STRICTENC", "0x4d is OP_PUSHDATA2"],
+["0x4e 0x01000000 0x09","9 EQUAL", "P2SH,STRICTENC", "0x4e is OP_PUSHDATA4"],
+
+["0x4c 0x00","0 EQUAL", "P2SH,STRICTENC"],
+["0x4d 0x0000","0 EQUAL", "P2SH,STRICTENC"],
+["0x4e 0x00000000","0 EQUAL", "P2SH,STRICTENC"],
+["0x4f 1000 ADD","999 EQUAL", "P2SH,STRICTENC"],
+["0", "IF 0x50 ENDIF 1", "P2SH,STRICTENC", "0x50 is reserved (ok if not executed)"],
+["0x51", "0x5f ADD 0x60 EQUAL", "P2SH,STRICTENC", "0x51 through 0x60 push 1 through 16 onto stack"],
+["1","NOP", "P2SH,STRICTENC"],
+["0", "IF VER ELSE 1 ENDIF", "P2SH,STRICTENC", "VER non-functional (ok if not executed)"],
+["0", "IF RESERVED RESERVED1 RESERVED2 ELSE 1 ENDIF", "P2SH,STRICTENC", "RESERVED ok in un-executed IF"],
+
+["1", "DUP IF ENDIF", "P2SH,STRICTENC"],
+["1", "IF 1 ENDIF", "P2SH,STRICTENC"],
+["1", "DUP IF ELSE ENDIF", "P2SH,STRICTENC"],
+["1", "IF 1 ELSE ENDIF", "P2SH,STRICTENC"],
+["0", "IF ELSE 1 ENDIF", "P2SH,STRICTENC"],
+
+["1 1", "IF IF 1 ELSE 0 ENDIF ENDIF", "P2SH,STRICTENC"],
+["1 0", "IF IF 1 ELSE 0 ENDIF ENDIF", "P2SH,STRICTENC"],
+["1 1", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "P2SH,STRICTENC"],
+["0 0", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "P2SH,STRICTENC"],
+
+["1 0", "NOTIF IF 1 ELSE 0 ENDIF ENDIF", "P2SH,STRICTENC"],
+["1 1", "NOTIF IF 1 ELSE 0 ENDIF ENDIF", "P2SH,STRICTENC"],
+["1 0", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "P2SH,STRICTENC"],
+["0 1", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF", "P2SH,STRICTENC"],
+
+["0", "IF 0 ELSE 1 ELSE 0 ENDIF", "P2SH,STRICTENC", "Multiple ELSE's are valid and executed inverts on each ELSE encountered"],
+["1", "IF 1 ELSE 0 ELSE ENDIF", "P2SH,STRICTENC"],
+["1", "IF ELSE 0 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["1", "IF 1 ELSE 0 ELSE 1 ENDIF ADD 2 EQUAL", "P2SH,STRICTENC"],
+["'' 1", "IF SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ENDIF 0x14 0x68ca4fec736264c13b859bac43d5173df6871682 EQUAL", "P2SH,STRICTENC"],
+
+["1", "NOTIF 0 ELSE 1 ELSE 0 ENDIF", "P2SH,STRICTENC", "Multiple ELSE's are valid and execution inverts on each ELSE encountered"],
+["0", "NOTIF 1 ELSE 0 ELSE ENDIF", "P2SH,STRICTENC"],
+["0", "NOTIF ELSE 0 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "NOTIF 1 ELSE 0 ELSE 1 ENDIF ADD 2 EQUAL", "P2SH,STRICTENC"],
+["'' 0", "NOTIF SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ENDIF 0x14 0x68ca4fec736264c13b859bac43d5173df6871682 EQUAL", "P2SH,STRICTENC"],
+
+["0", "IF 1 IF RETURN ELSE RETURN ELSE RETURN ENDIF ELSE 1 IF 1 ELSE RETURN ELSE 1 ENDIF ELSE RETURN ENDIF ADD 2 EQUAL", "P2SH,STRICTENC", "Nested ELSE ELSE"],
+["1", "NOTIF 0 NOTIF RETURN ELSE RETURN ELSE RETURN ENDIF ELSE 0 NOTIF 1 ELSE RETURN ELSE 1 ENDIF ELSE RETURN ENDIF ADD 2 EQUAL", "P2SH,STRICTENC"],
+
+["0", "IF RETURN ENDIF 1", "P2SH,STRICTENC", "RETURN only works if executed"],
+
+["1 1", "VERIFY", "P2SH,STRICTENC"],
+["1 0x05 0x01 0x00 0x00 0x00 0x00", "VERIFY", "P2SH,STRICTENC", "values >4 bytes can be cast to boolean"],
+
+["10 0 11 TOALTSTACK DROP FROMALTSTACK", "ADD 21 EQUAL", "P2SH,STRICTENC"],
+["'gavin_was_here' TOALTSTACK 11 FROMALTSTACK", "'gavin_was_here' EQUALVERIFY 11 EQUAL", "P2SH,STRICTENC"],
+
+["0 IFDUP", "DEPTH 1 EQUALVERIFY 0 EQUAL", "P2SH,STRICTENC"],
+["1 IFDUP", "DEPTH 2 EQUALVERIFY 1 EQUALVERIFY 1 EQUAL", "P2SH,STRICTENC"],
+["0 DROP", "DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["0", "DUP 1 ADD 1 EQUALVERIFY 0 EQUAL", "P2SH,STRICTENC"],
+["0 1", "NIP", "P2SH,STRICTENC"],
+["1 0", "OVER DEPTH 3 EQUALVERIFY", "P2SH,STRICTENC"],
+["22 21 20", "0 PICK 20 EQUALVERIFY DEPTH 3 EQUAL", "P2SH,STRICTENC"],
+["22 21 20", "1 PICK 21 EQUALVERIFY DEPTH 3 EQUAL", "P2SH,STRICTENC"],
+["22 21 20", "2 PICK 22 EQUALVERIFY DEPTH 3 EQUAL", "P2SH,STRICTENC"],
+["22 21 20", "0 ROLL 20 EQUALVERIFY DEPTH 2 EQUAL", "P2SH,STRICTENC"],
+["22 21 20", "1 ROLL 21 EQUALVERIFY DEPTH 2 EQUAL", "P2SH,STRICTENC"],
+["22 21 20", "2 ROLL 22 EQUALVERIFY DEPTH 2 EQUAL", "P2SH,STRICTENC"],
+["22 21 20", "ROT 22 EQUAL", "P2SH,STRICTENC"],
+["22 21 20", "ROT DROP 20 EQUAL", "P2SH,STRICTENC"],
+["22 21 20", "ROT DROP DROP 21 EQUAL", "P2SH,STRICTENC"],
+["22 21 20", "ROT ROT 21 EQUAL", "P2SH,STRICTENC"],
+["22 21 20", "ROT ROT ROT 20 EQUAL", "P2SH,STRICTENC"],
+["25 24 23 22 21 20", "2ROT 24 EQUAL", "P2SH,STRICTENC"],
+["25 24 23 22 21 20", "2ROT DROP 25 EQUAL", "P2SH,STRICTENC"],
+["25 24 23 22 21 20", "2ROT 2DROP 20 EQUAL", "P2SH,STRICTENC"],
+["25 24 23 22 21 20", "2ROT 2DROP DROP 21 EQUAL", "P2SH,STRICTENC"],
+["25 24 23 22 21 20", "2ROT 2DROP 2DROP 22 EQUAL", "P2SH,STRICTENC"],
+["25 24 23 22 21 20", "2ROT 2DROP 2DROP DROP 23 EQUAL", "P2SH,STRICTENC"],
+["25 24 23 22 21 20", "2ROT 2ROT 22 EQUAL", "P2SH,STRICTENC"],
+["25 24 23 22 21 20", "2ROT 2ROT 2ROT 20 EQUAL", "P2SH,STRICTENC"],
+["1 0", "SWAP 1 EQUALVERIFY 0 EQUAL", "P2SH,STRICTENC"],
+["0 1", "TUCK DEPTH 3 EQUALVERIFY SWAP 2DROP", "P2SH,STRICTENC"],
+["13 14", "2DUP ROT EQUALVERIFY EQUAL", "P2SH,STRICTENC"],
+["-1 0 1 2", "3DUP DEPTH 7 EQUALVERIFY ADD ADD 3 EQUALVERIFY 2DROP 0 EQUALVERIFY", "P2SH,STRICTENC"],
+["1 2 3 5", "2OVER ADD ADD 8 EQUALVERIFY ADD ADD 6 EQUAL", "P2SH,STRICTENC"],
+["1 3 5 7", "2SWAP ADD 4 EQUALVERIFY ADD 12 EQUAL", "P2SH,STRICTENC"],
+["0", "SIZE 0 EQUAL", "P2SH,STRICTENC"],
+["1", "SIZE 1 EQUAL", "P2SH,STRICTENC"],
+["127", "SIZE 1 EQUAL", "P2SH,STRICTENC"],
+["128", "SIZE 2 EQUAL", "P2SH,STRICTENC"],
+["32767", "SIZE 2 EQUAL", "P2SH,STRICTENC"],
+["32768", "SIZE 3 EQUAL", "P2SH,STRICTENC"],
+["8388607", "SIZE 3 EQUAL", "P2SH,STRICTENC"],
+["8388608", "SIZE 4 EQUAL", "P2SH,STRICTENC"],
+["2147483647", "SIZE 4 EQUAL", "P2SH,STRICTENC"],
+["2147483648", "SIZE 5 EQUAL", "P2SH,STRICTENC"],
+["549755813887", "SIZE 5 EQUAL", "P2SH,STRICTENC"],
+["549755813888", "SIZE 6 EQUAL", "P2SH,STRICTENC"],
+["9223372036854775807", "SIZE 8 EQUAL", "P2SH,STRICTENC"],
+["-1", "SIZE 1 EQUAL", "P2SH,STRICTENC"],
+["-127", "SIZE 1 EQUAL", "P2SH,STRICTENC"],
+["-128", "SIZE 2 EQUAL", "P2SH,STRICTENC"],
+["-32767", "SIZE 2 EQUAL", "P2SH,STRICTENC"],
+["-32768", "SIZE 3 EQUAL", "P2SH,STRICTENC"],
+["-8388607", "SIZE 3 EQUAL", "P2SH,STRICTENC"],
+["-8388608", "SIZE 4 EQUAL", "P2SH,STRICTENC"],
+["-2147483647", "SIZE 4 EQUAL", "P2SH,STRICTENC"],
+["-2147483648", "SIZE 5 EQUAL", "P2SH,STRICTENC"],
+["-549755813887", "SIZE 5 EQUAL", "P2SH,STRICTENC"],
+["-549755813888", "SIZE 6 EQUAL", "P2SH,STRICTENC"],
+["-9223372036854775807", "SIZE 8 EQUAL", "P2SH,STRICTENC"],
+["'abcdefghijklmnopqrstuvwxyz'", "SIZE 26 EQUAL", "P2SH,STRICTENC"],
+
+["42", "SIZE 1 EQUALVERIFY 42 EQUAL", "P2SH,STRICTENC", "SIZE does not consume argument"],
+
+["2 -2 ADD", "0 EQUAL", "P2SH,STRICTENC"],
+["2147483647 -2147483647 ADD", "0 EQUAL", "P2SH,STRICTENC"],
+["-1 -1 ADD", "-2 EQUAL", "P2SH,STRICTENC"],
+
+["0 0","EQUAL", "P2SH,STRICTENC"],
+["1 1 ADD", "2 EQUAL", "P2SH,STRICTENC"],
+["1 1ADD", "2 EQUAL", "P2SH,STRICTENC"],
+["111 1SUB", "110 EQUAL", "P2SH,STRICTENC"],
+["111 1 ADD 12 SUB", "100 EQUAL", "P2SH,STRICTENC"],
+["0 ABS", "0 EQUAL", "P2SH,STRICTENC"],
+["16 ABS", "16 EQUAL", "P2SH,STRICTENC"],
+["-16 ABS", "-16 NEGATE EQUAL", "P2SH,STRICTENC"],
+["0 NOT", "NOP", "P2SH,STRICTENC"],
+["1 NOT", "0 EQUAL", "P2SH,STRICTENC"],
+["11 NOT", "0 EQUAL", "P2SH,STRICTENC"],
+["0 0NOTEQUAL", "0 EQUAL", "P2SH,STRICTENC"],
+["1 0NOTEQUAL", "1 EQUAL", "P2SH,STRICTENC"],
+["111 0NOTEQUAL", "1 EQUAL", "P2SH,STRICTENC"],
+["-111 0NOTEQUAL", "1 EQUAL", "P2SH,STRICTENC"],
+["1 1 BOOLAND", "NOP", "P2SH,STRICTENC"],
+["1 0 BOOLAND", "NOT", "P2SH,STRICTENC"],
+["0 1 BOOLAND", "NOT", "P2SH,STRICTENC"],
+["0 0 BOOLAND", "NOT", "P2SH,STRICTENC"],
+["16 17 BOOLAND", "NOP", "P2SH,STRICTENC"],
+["1 1 BOOLOR", "NOP", "P2SH,STRICTENC"],
+["1 0 BOOLOR", "NOP", "P2SH,STRICTENC"],
+["0 1 BOOLOR", "NOP", "P2SH,STRICTENC"],
+["0 0 BOOLOR", "NOT", "P2SH,STRICTENC"],
+["16 17 BOOLOR", "NOP", "P2SH,STRICTENC"],
+["11 10 1 ADD", "NUMEQUAL", "P2SH,STRICTENC"],
+["11 10 1 ADD", "NUMEQUALVERIFY 1", "P2SH,STRICTENC"],
+["11 10 1 ADD", "NUMNOTEQUAL NOT", "P2SH,STRICTENC"],
+["111 10 1 ADD", "NUMNOTEQUAL", "P2SH,STRICTENC"],
+["11 10", "LESSTHAN NOT", "P2SH,STRICTENC"],
+["4 4", "LESSTHAN NOT", "P2SH,STRICTENC"],
+["10 11", "LESSTHAN", "P2SH,STRICTENC"],
+["-11 11", "LESSTHAN", "P2SH,STRICTENC"],
+["-11 -10", "LESSTHAN", "P2SH,STRICTENC"],
+["11 10", "GREATERTHAN", "P2SH,STRICTENC"],
+["4 4", "GREATERTHAN NOT", "P2SH,STRICTENC"],
+["10 11", "GREATERTHAN NOT", "P2SH,STRICTENC"],
+["-11 11", "GREATERTHAN NOT", "P2SH,STRICTENC"],
+["-11 -10", "GREATERTHAN NOT", "P2SH,STRICTENC"],
+["11 10", "LESSTHANOREQUAL NOT", "P2SH,STRICTENC"],
+["4 4", "LESSTHANOREQUAL", "P2SH,STRICTENC"],
+["10 11", "LESSTHANOREQUAL", "P2SH,STRICTENC"],
+["-11 11", "LESSTHANOREQUAL", "P2SH,STRICTENC"],
+["-11 -10", "LESSTHANOREQUAL", "P2SH,STRICTENC"],
+["11 10", "GREATERTHANOREQUAL", "P2SH,STRICTENC"],
+["4 4", "GREATERTHANOREQUAL", "P2SH,STRICTENC"],
+["10 11", "GREATERTHANOREQUAL NOT", "P2SH,STRICTENC"],
+["-11 11", "GREATERTHANOREQUAL NOT", "P2SH,STRICTENC"],
+["-11 -10", "GREATERTHANOREQUAL NOT", "P2SH,STRICTENC"],
+["1 0 MIN", "0 NUMEQUAL", "P2SH,STRICTENC"],
+["0 1 MIN", "0 NUMEQUAL", "P2SH,STRICTENC"],
+["-1 0 MIN", "-1 NUMEQUAL", "P2SH,STRICTENC"],
+["0 -2147483647 MIN", "-2147483647 NUMEQUAL", "P2SH,STRICTENC"],
+["2147483647 0 MAX", "2147483647 NUMEQUAL", "P2SH,STRICTENC"],
+["0 100 MAX", "100 NUMEQUAL", "P2SH,STRICTENC"],
+["-100 0 MAX", "0 NUMEQUAL", "P2SH,STRICTENC"],
+["0 -2147483647 MAX", "0 NUMEQUAL", "P2SH,STRICTENC"],
+["0 0 1", "WITHIN", "P2SH,STRICTENC"],
+["1 0 1", "WITHIN NOT", "P2SH,STRICTENC"],
+["0 -2147483647 2147483647", "WITHIN", "P2SH,STRICTENC"],
+["-1 -100 100", "WITHIN", "P2SH,STRICTENC"],
+["11 -100 100", "WITHIN", "P2SH,STRICTENC"],
+["-2147483647 -100 100", "WITHIN NOT", "P2SH,STRICTENC"],
+["2147483647 -100 100", "WITHIN NOT", "P2SH,STRICTENC"],
+
+["2147483647 2147483647 SUB", "0 EQUAL", "P2SH,STRICTENC"],
+["2147483647 DUP ADD", "4294967294 EQUAL", "P2SH,STRICTENC", ">32 bit EQUAL is valid"],
+["2147483647 NEGATE DUP ADD", "-4294967294 EQUAL", "P2SH,STRICTENC"],
+
+["''", "RIPEMD160 0x14 0x9c1185a5c5e9fc54612808977ee8f548b2258d31 EQUAL", "P2SH,STRICTENC"],
+["'a'", "RIPEMD160 0x14 0x0bdc9d2d256b3ee9daae347be6f4dc835a467ffe EQUAL", "P2SH,STRICTENC"],
+["'abcdefghijklmnopqrstuvwxyz'", "RIPEMD160 0x14 0xf71c27109c692c1b56bbdceb5b9d2865b3708dbc EQUAL", "P2SH,STRICTENC"],
+["''", "SHA1 0x14 0xda39a3ee5e6b4b0d3255bfef95601890afd80709 EQUAL", "P2SH,STRICTENC"],
+["'a'", "SHA1 0x14 0x86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 EQUAL", "P2SH,STRICTENC"],
+["'abcdefghijklmnopqrstuvwxyz'", "SHA1 0x14 0x32d10c7b8cf96570ca04ce37f2a19d84240d3a89 EQUAL", "P2SH,STRICTENC"],
+["''", "SHA256 0x20 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 EQUAL", "P2SH,STRICTENC"],
+["'a'", "SHA256 0x20 0xca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb EQUAL", "P2SH,STRICTENC"],
+["'abcdefghijklmnopqrstuvwxyz'", "SHA256 0x20 0x71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73 EQUAL", "P2SH,STRICTENC"],
+["''", "DUP HASH160 SWAP SHA256 RIPEMD160 EQUAL", "P2SH,STRICTENC"],
+["''", "DUP HASH256 SWAP SHA256 SHA256 EQUAL", "P2SH,STRICTENC"],
+["''", "NOP HASH160 0x14 0xb472a266d0bd89c13706a4132ccfb16f7c3b9fcb EQUAL", "P2SH,STRICTENC"],
+["'a'", "HASH160 NOP 0x14 0x994355199e516ff76c4fa4aab39337b9d84cf12b EQUAL", "P2SH,STRICTENC"],
+["'abcdefghijklmnopqrstuvwxyz'", "HASH160 0x4c 0x14 0xc286a1af0947f58d1ad787385b1c2c4a976f9e71 EQUAL", "P2SH,STRICTENC"],
+["''", "HASH256 0x20 0x5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456 EQUAL", "P2SH,STRICTENC"],
+["'a'", "HASH256 0x20 0xbf5d3affb73efd2ec6c36ad3112dd933efed63c4e1cbffcfa88e2759c144f2d8 EQUAL", "P2SH,STRICTENC"],
+["'abcdefghijklmnopqrstuvwxyz'", "HASH256 0x4c 0x20 0xca139bc10c2f660da42666f72e89a225936fc60f193c161124a672050c434671 EQUAL", "P2SH,STRICTENC"],
+
+
+["1","NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL", "P2SH,STRICTENC"],
+["'NOP_1_to_10' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_10' EQUAL", "P2SH,STRICTENC"],
+
+["0", "IF 0xba ELSE 1 ENDIF", "P2SH,STRICTENC", "opcodes above NOP10 invalid if executed"],
+["0", "IF 0xbb ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xbc ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xbd ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xbe ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xbf ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xc0 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xc1 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xc2 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xc3 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xc4 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xc5 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xc6 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xc7 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xc8 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xc9 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xca ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xcb ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xcc ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xcd ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xce ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xcf ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xd0 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xd1 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xd2 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xd3 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xd4 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xd5 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xd6 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xd7 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xd8 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xd9 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xda ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xdb ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xdc ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xdd ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xde ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xdf ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xe0 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xe1 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xe2 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xe3 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xe4 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xe5 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xe6 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xe7 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xe8 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xe9 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xea ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xeb ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xec ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xed ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xee ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xef ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xf0 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xf1 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xf2 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xf3 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xf4 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xf5 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xf6 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xf7 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xf8 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xf9 ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xfa ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xfb ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xfc ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xfd ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xfe ELSE 1 ENDIF", "P2SH,STRICTENC"],
+["0", "IF 0xff ELSE 1 ENDIF", "P2SH,STRICTENC"],
["NOP",
"'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'",
+"P2SH,STRICTENC",
"520 byte push"],
["1",
"0x616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161",
+"P2SH,STRICTENC",
"201 opcodes executed. 0x61 is NOP"],
["1 2 3 4 5 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f",
"1 2 3 4 5 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f",
+"P2SH,STRICTENC",
"1,000 stack size (0x6f is 3DUP)"],
["1 TOALTSTACK 2 TOALTSTACK 3 4 5 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f",
"1 2 3 4 5 6 7 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f",
+"P2SH,STRICTENC",
"1,000 stack size (altstack cleared between scriptSig/scriptPubKey)"],
["'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f",
"'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f 2DUP 0x616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161",
+"P2SH,STRICTENC",
"Max-size (10,000-byte), max-push(520 bytes), max-opcodes(201), max stack size(1,000 items). 0x6f is 3DUP, 0x61 is NOP"],
["0",
"IF 0x5050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050 ENDIF 1",
+"P2SH,STRICTENC",
">201 opcodes, but RESERVED (0x50) doesn't count towards opcode limit."],
-["NOP","1"],
-
-["1", "0x01 0x01 EQUAL", "The following is useful for checking implementations of BN_bn2mpi"],
-["127", "0x01 0x7F EQUAL"],
-["128", "0x02 0x8000 EQUAL", "Leave room for the sign bit"],
-["32767", "0x02 0xFF7F EQUAL"],
-["32768", "0x03 0x008000 EQUAL"],
-["8388607", "0x03 0xFFFF7F EQUAL"],
-["8388608", "0x04 0x00008000 EQUAL"],
-["2147483647", "0x04 0xFFFFFF7F EQUAL"],
-["2147483648", "0x05 0x0000008000 EQUAL"],
-["549755813887", "0x05 0xFFFFFFFF7F EQUAL"],
-["549755813888", "0x06 0xFFFFFFFF7F EQUAL"],
-["9223372036854775807", "0x08 0xFFFFFFFFFFFFFF7F EQUAL"],
-["-1", "0x01 0x81 EQUAL", "Numbers are little-endian with the MSB being a sign bit"],
-["-127", "0x01 0xFF EQUAL"],
-["-128", "0x02 0x8080 EQUAL"],
-["-32767", "0x02 0xFFFF EQUAL"],
-["-32768", "0x03 0x008080 EQUAL"],
-["-8388607", "0x03 0xFFFFFF EQUAL"],
-["-8388608", "0x04 0x00008080 EQUAL"],
-["-2147483647", "0x04 0xFFFFFFFF EQUAL"],
-["-2147483648", "0x05 0x0000008080 EQUAL"],
-["-4294967295", "0x05 0xFFFFFFFF80 EQUAL"],
-["-549755813887", "0x05 0xFFFFFFFFFF EQUAL"],
-["-549755813888", "0x06 0x000000008080 EQUAL"],
-["-9223372036854775807", "0x08 0xFFFFFFFFFFFFFFFF EQUAL"],
-
-["2147483647", "1ADD 2147483648 EQUAL", "We can do math on 4-byte integers, and compare 5-byte ones"],
-["2147483647", "1ADD 1"],
-["-2147483647", "1ADD 1"],
-
-["1", "0x02 0x0100 EQUAL NOT", "Not the same byte array..."],
-["1", "0x02 0x0100 NUMEQUAL", "... but they are numerically equal"],
-["11", "0x4c 0x03 0x0b0000 NUMEQUAL"],
-["0", "0x01 0x80 EQUAL NOT"],
-["0", "0x01 0x80 NUMEQUAL", "Zero numerically equals negative zero"],
-["0", "0x02 0x0080 NUMEQUAL"],
-["0x03 0x000080", "0x04 0x00000080 NUMEQUAL"],
-["0x03 0x100080", "0x04 0x10000080 NUMEQUAL"],
-["0x03 0x100000", "0x04 0x10000000 NUMEQUAL"],
-
-["NOP", "NOP 1", "The following tests check the if(stack.size() < N) tests in each opcode"],
-["1", "IF 1 ENDIF", "They are here to catch copy-and-paste errors"],
-["0", "NOTIF 1 ENDIF", "Most of them are duplicated elsewhere,"],
-["1", "VERIFY 1", "but, hey, more is always better, right?"],
-
-["0", "TOALTSTACK 1"],
-["1", "TOALTSTACK FROMALTSTACK"],
-["0 0", "2DROP 1"],
-["0 1", "2DUP"],
-["0 0 1", "3DUP"],
-["0 1 0 0", "2OVER"],
-["0 1 0 0 0 0", "2ROT"],
-["0 1 0 0", "2SWAP"],
-["1", "IFDUP"],
-["NOP", "DEPTH 1"],
-["0", "DROP 1"],
-["1", "DUP"],
-["0 1", "NIP"],
-["1 0", "OVER"],
-["1 0 0 0 3", "PICK"],
-["1 0", "PICK"],
-["1 0 0 0 3", "ROLL"],
-["1 0", "ROLL"],
-["1 0 0", "ROT"],
-["1 0", "SWAP"],
-["0 1", "TUCK"],
-
-["1", "SIZE"],
-
-["0 0", "EQUAL"],
-["0 0", "EQUALVERIFY 1"],
-
-["0", "1ADD"],
-["2", "1SUB"],
-["-1", "NEGATE"],
-["-1", "ABS"],
-["0", "NOT"],
-["-1", "0NOTEQUAL"],
-
-["1 0", "ADD"],
-["1 0", "SUB"],
-["-1 -1", "BOOLAND"],
-["-1 0", "BOOLOR"],
-["0 0", "NUMEQUAL"],
-["0 0", "NUMEQUALVERIFY 1"],
-["-1 0", "NUMNOTEQUAL"],
-["-1 0", "LESSTHAN"],
-["1 0", "GREATERTHAN"],
-["0 0", "LESSTHANOREQUAL"],
-["0 0", "GREATERTHANOREQUAL"],
-["-1 0", "MIN"],
-["1 0", "MAX"],
-["-1 -1 0", "WITHIN"],
-
-["0", "RIPEMD160"],
-["0", "SHA1"],
-["0", "SHA256"],
-["0", "HASH160"],
-["0", "HASH256"],
-["NOP", "CODESEPARATOR 1"],
-
-["NOP", "NOP1 1"],
-["NOP", "NOP2 1"],
-["NOP", "NOP3 1"],
-["NOP", "NOP4 1"],
-["NOP", "NOP5 1"],
-["NOP", "NOP6 1"],
-["NOP", "NOP7 1"],
-["NOP", "NOP8 1"],
-["NOP", "NOP9 1"],
-["NOP", "NOP10 1"],
-
-["", "0 0 0 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "CHECKMULTISIG is allowed to have zero keys and/or sigs"],
-["", "0 0 0 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 0 1 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "Zero sigs means no sigs are checked"],
-["", "0 0 0 1 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-
-["", "0 0 0 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "CHECKMULTISIG is allowed to have zero keys and/or sigs"],
-["", "0 0 0 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 0 1 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "Zero sigs means no sigs are checked"],
-["", "0 0 0 1 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-
-["", "0 0 'a' 'b' 2 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "Test from up to 20 pubkeys, all not checked"],
-["", "0 0 'a' 'b' 'c' 3 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 4 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 5 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 6 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 7 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 8 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 9 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 10 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 11 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 12 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 13 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 14 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 15 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 16 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 17 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 18 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 19 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG VERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 1 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 2 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 3 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 4 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 5 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 6 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 7 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 8 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 9 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 10 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 11 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 12 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 13 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 14 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 15 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 16 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 17 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 18 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 19 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
-["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY DEPTH 0 EQUAL"],
+["NOP","1", "P2SH,STRICTENC"],
+
+["1", "0x01 0x01 EQUAL", "P2SH,STRICTENC", "The following is useful for checking implementations of BN_bn2mpi"],
+["127", "0x01 0x7F EQUAL", "P2SH,STRICTENC"],
+["128", "0x02 0x8000 EQUAL", "P2SH,STRICTENC", "Leave room for the sign bit"],
+["32767", "0x02 0xFF7F EQUAL", "P2SH,STRICTENC"],
+["32768", "0x03 0x008000 EQUAL", "P2SH,STRICTENC"],
+["8388607", "0x03 0xFFFF7F EQUAL", "P2SH,STRICTENC"],
+["8388608", "0x04 0x00008000 EQUAL", "P2SH,STRICTENC"],
+["2147483647", "0x04 0xFFFFFF7F EQUAL", "P2SH,STRICTENC"],
+["2147483648", "0x05 0x0000008000 EQUAL", "P2SH,STRICTENC"],
+["549755813887", "0x05 0xFFFFFFFF7F EQUAL", "P2SH,STRICTENC"],
+["549755813888", "0x06 0xFFFFFFFF7F EQUAL", "P2SH,STRICTENC"],
+["9223372036854775807", "0x08 0xFFFFFFFFFFFFFF7F EQUAL", "P2SH,STRICTENC"],
+["-1", "0x01 0x81 EQUAL", "P2SH,STRICTENC", "Numbers are little-endian with the MSB being a sign bit"],
+["-127", "0x01 0xFF EQUAL", "P2SH,STRICTENC"],
+["-128", "0x02 0x8080 EQUAL", "P2SH,STRICTENC"],
+["-32767", "0x02 0xFFFF EQUAL", "P2SH,STRICTENC"],
+["-32768", "0x03 0x008080 EQUAL", "P2SH,STRICTENC"],
+["-8388607", "0x03 0xFFFFFF EQUAL", "P2SH,STRICTENC"],
+["-8388608", "0x04 0x00008080 EQUAL", "P2SH,STRICTENC"],
+["-2147483647", "0x04 0xFFFFFFFF EQUAL", "P2SH,STRICTENC"],
+["-2147483648", "0x05 0x0000008080 EQUAL", "P2SH,STRICTENC"],
+["-4294967295", "0x05 0xFFFFFFFF80 EQUAL", "P2SH,STRICTENC"],
+["-549755813887", "0x05 0xFFFFFFFFFF EQUAL", "P2SH,STRICTENC"],
+["-549755813888", "0x06 0x000000008080 EQUAL", "P2SH,STRICTENC"],
+["-9223372036854775807", "0x08 0xFFFFFFFFFFFFFFFF EQUAL", "P2SH,STRICTENC"],
+
+["2147483647", "1ADD 2147483648 EQUAL", "P2SH,STRICTENC", "We can do math on 4-byte integers, and compare 5-byte ones"],
+["2147483647", "1ADD 1", "P2SH,STRICTENC"],
+["-2147483647", "1ADD 1", "P2SH,STRICTENC"],
+
+["1", "0x02 0x0100 EQUAL NOT", "P2SH,STRICTENC", "Not the same byte array..."],
+["1", "0x02 0x0100 NUMEQUAL", "P2SH,STRICTENC", "... but they are numerically equal"],
+["11", "0x4c 0x03 0x0b0000 NUMEQUAL", "P2SH,STRICTENC"],
+["0", "0x01 0x80 EQUAL NOT", "P2SH,STRICTENC"],
+["0", "0x01 0x80 NUMEQUAL", "P2SH,STRICTENC", "Zero numerically equals negative zero"],
+["0", "0x02 0x0080 NUMEQUAL", "P2SH,STRICTENC"],
+["0x03 0x000080", "0x04 0x00000080 NUMEQUAL", "P2SH,STRICTENC"],
+["0x03 0x100080", "0x04 0x10000080 NUMEQUAL", "P2SH,STRICTENC"],
+["0x03 0x100000", "0x04 0x10000000 NUMEQUAL", "P2SH,STRICTENC"],
+
+["NOP", "NOP 1", "P2SH,STRICTENC", "The following tests check the if(stack.size() < N) tests in each opcode"],
+["1", "IF 1 ENDIF", "P2SH,STRICTENC", "They are here to catch copy-and-paste errors"],
+["0", "NOTIF 1 ENDIF", "P2SH,STRICTENC", "Most of them are duplicated elsewhere,"],
+["1", "VERIFY 1", "P2SH,STRICTENC", "but, hey, more is always better, right?"],
+
+["0", "TOALTSTACK 1", "P2SH,STRICTENC"],
+["1", "TOALTSTACK FROMALTSTACK", "P2SH,STRICTENC"],
+["0 0", "2DROP 1", "P2SH,STRICTENC"],
+["0 1", "2DUP", "P2SH,STRICTENC"],
+["0 0 1", "3DUP", "P2SH,STRICTENC"],
+["0 1 0 0", "2OVER", "P2SH,STRICTENC"],
+["0 1 0 0 0 0", "2ROT", "P2SH,STRICTENC"],
+["0 1 0 0", "2SWAP", "P2SH,STRICTENC"],
+["1", "IFDUP", "P2SH,STRICTENC"],
+["NOP", "DEPTH 1", "P2SH,STRICTENC"],
+["0", "DROP 1", "P2SH,STRICTENC"],
+["1", "DUP", "P2SH,STRICTENC"],
+["0 1", "NIP", "P2SH,STRICTENC"],
+["1 0", "OVER", "P2SH,STRICTENC"],
+["1 0 0 0 3", "PICK", "P2SH,STRICTENC"],
+["1 0", "PICK", "P2SH,STRICTENC"],
+["1 0 0 0 3", "ROLL", "P2SH,STRICTENC"],
+["1 0", "ROLL", "P2SH,STRICTENC"],
+["1 0 0", "ROT", "P2SH,STRICTENC"],
+["1 0", "SWAP", "P2SH,STRICTENC"],
+["0 1", "TUCK", "P2SH,STRICTENC"],
+
+["1", "SIZE", "P2SH,STRICTENC"],
+
+["0 0", "EQUAL", "P2SH,STRICTENC"],
+["0 0", "EQUALVERIFY 1", "P2SH,STRICTENC"],
+
+["0", "1ADD", "P2SH,STRICTENC"],
+["2", "1SUB", "P2SH,STRICTENC"],
+["-1", "NEGATE", "P2SH,STRICTENC"],
+["-1", "ABS", "P2SH,STRICTENC"],
+["0", "NOT", "P2SH,STRICTENC"],
+["-1", "0NOTEQUAL", "P2SH,STRICTENC"],
+
+["1 0", "ADD", "P2SH,STRICTENC"],
+["1 0", "SUB", "P2SH,STRICTENC"],
+["-1 -1", "BOOLAND", "P2SH,STRICTENC"],
+["-1 0", "BOOLOR", "P2SH,STRICTENC"],
+["0 0", "NUMEQUAL", "P2SH,STRICTENC"],
+["0 0", "NUMEQUALVERIFY 1", "P2SH,STRICTENC"],
+["-1 0", "NUMNOTEQUAL", "P2SH,STRICTENC"],
+["-1 0", "LESSTHAN", "P2SH,STRICTENC"],
+["1 0", "GREATERTHAN", "P2SH,STRICTENC"],
+["0 0", "LESSTHANOREQUAL", "P2SH,STRICTENC"],
+["0 0", "GREATERTHANOREQUAL", "P2SH,STRICTENC"],
+["-1 0", "MIN", "P2SH,STRICTENC"],
+["1 0", "MAX", "P2SH,STRICTENC"],
+["-1 -1 0", "WITHIN", "P2SH,STRICTENC"],
+
+["0", "RIPEMD160", "P2SH,STRICTENC"],
+["0", "SHA1", "P2SH,STRICTENC"],
+["0", "SHA256", "P2SH,STRICTENC"],
+["0", "HASH160", "P2SH,STRICTENC"],
+["0", "HASH256", "P2SH,STRICTENC"],
+["NOP", "CODESEPARATOR 1", "P2SH,STRICTENC"],
+
+["NOP", "NOP1 1", "P2SH,STRICTENC"],
+["NOP", "NOP2 1", "P2SH,STRICTENC"],
+["NOP", "NOP3 1", "P2SH,STRICTENC"],
+["NOP", "NOP4 1", "P2SH,STRICTENC"],
+["NOP", "NOP5 1", "P2SH,STRICTENC"],
+["NOP", "NOP6 1", "P2SH,STRICTENC"],
+["NOP", "NOP7 1", "P2SH,STRICTENC"],
+["NOP", "NOP8 1", "P2SH,STRICTENC"],
+["NOP", "NOP9 1", "P2SH,STRICTENC"],
+["NOP", "NOP10 1", "P2SH,STRICTENC"],
+
+["", "0 0 0 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC", "CHECKMULTISIG is allowed to have zero keys and/or sigs"],
+["", "0 0 0 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 0 1 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC", "Zero sigs means no sigs are checked"],
+["", "0 0 0 1 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+
+["", "0 0 0 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC", "CHECKMULTISIG is allowed to have zero keys and/or sigs"],
+["", "0 0 0 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 0 1 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC", "Zero sigs means no sigs are checked"],
+["", "0 0 0 1 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+
+["", "0 0 'a' 'b' 2 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC", "Test from up to 20 pubkeys, all not checked"],
+["", "0 0 'a' 'b' 'c' 3 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 4 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 5 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 6 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 7 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 8 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 9 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 10 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 11 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 12 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 13 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 14 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 15 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 16 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 17 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 18 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 19 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG VERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 1 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 2 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 3 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 4 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 5 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 6 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 7 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 8 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 9 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 10 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 11 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 12 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 13 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 14 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 15 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 16 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 17 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 18 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 19 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
+["", "0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY DEPTH 0 EQUAL", "P2SH,STRICTENC"],
["",
"0 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG 0 0 CHECKMULTISIG",
+"P2SH,STRICTENC",
"nOpCount is incremented by the number of keys evaluated in addition to the usual one op per op. In this case we have zero keys, so we can execute 201 CHECKMULTISIGS"],
["1",
-"0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY"],
+"0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY 0 0 0 CHECKMULTISIGVERIFY",
+"P2SH,STRICTENC"],
["",
"NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIG",
+"P2SH,STRICTENC",
"Even though there are no signatures being checked nOpCount is incremented by the number of keys."],
["1",
-"NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY"],
+"NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY 0 0 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 20 CHECKMULTISIGVERIFY",
+"P2SH,STRICTENC"],
-["0 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL", "Very basic P2SH"],
-["0x4c 0 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL"],
+["0 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL", "P2SH,STRICTENC", "Very basic P2SH"],
+["0x4c 0 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL", "P2SH,STRICTENC"],
["0x40 0x42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242",
"0x4d 0x4000 0x42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242 EQUAL",
+"P2SH,STRICTENC",
"Basic PUSH signedness check"],
["0x4c 0x40 0x42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242",
"0x4d 0x4000 0x42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242 EQUAL",
+"P2SH,STRICTENC",
"Basic PUSHDATA1 signedness check"],
-["0x00", "SIZE 0 EQUAL", "Basic OP_0 execution"]
+["0x00", "SIZE 0 EQUAL", "P2SH,STRICTENC", "Basic OP_0 execution"],
+
+["0x48 0x3045022100ea4d62e1fb351ad977596457bb01dfce58e050541774277bd825c33bd98c2a9502203003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkeyhash"],
+["0x47 0x304402207d09de5e34968c3f8b27d8217f173629f1106ee5216aa11d6b1f9813b3a214060220610a6ed25c704f901c6278f4f57fb11eadefdf0b22df298cfb6ce7ea84c86bf481 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH,STRICTENC", "Anyonecanpay pay to pubkeyhash"],
+["0x47 0x3044022028686fb3c8d3e5069cc9924c494fb5026df201d23340896da62fe9bb73fd9d5f02202a239609524959c4ca3651fd0cc48245b0b240862146fc579f3a962a4f46942b01", "0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkey"],
+["0x47 0x3044022054cb0a3fca8694a0c231848ed9f965078148fd653e49dd4b6980fadac0f5ba0702204085be5af427d4561f13a07fd5a1c5ab0ff02126e9ba191448f5a9dae0da585301 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 0x19 0x76a914751e76e8199196d454941c45d1b3a323f1433bd688ac", "HASH160 0x14 0xcd7b44d0b03f2d026d1e586d7ae18903b0d385f6 EQUAL", "P2SH,STRICTENC", "P2SH with a pay to pubkeyhash inside"],
+["0 0x48 0x3045022100e1c4e8800bd00c9ec3cd3de0e53e63bc5e8c018d0b68099a652f0b121f1a7e020220108dab275be7d1358530d3451d48aed747af77cc54e0423cbae5c572b2e1abb801", "1 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 1 CHECKMULTISIG", "P2SH,STRICTENC", "Raw multisig with one pubkey"],
+["0x49 0x304602220000ea4d62e1fb351ad977596457bb01dfce58e050541774277bd825c33bd98c2a9502203003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH", "Normal pay to pubkeyhash with non-DER signature (too much R padding)"],
+["0x47 0x30440220ea4d62e1fb351ad977596457bb01dfce58e050541774277bd825c33bd98c2a9502203003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH", "Normal pay to pubkeyhash with non-DER signature (too little R padding)"],
+["0x49 0x3046022100ea4d62e1fb351ad977596457bb01dfce58e050541774277bd825c33bd98c2a950221003003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH", "Normal pay to pubkeyhash with non-DER signature (too much S padding)"],
+["0x48 0x3045022100e6eda3fd34862078233463cae19f0b47995e3f892102e5b175175e92a9163cc402204bf58445819093638481084322b61a2d49b68c96fd6fea17ed494722d0d67b4f01", "0x41 0x0679be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG", "P2SH", "Pay to pubkey with hybrid pubkey encoding"],
+["0x48 0x304502203b56d65863e0cdb89313043c2402f46f518c31658648151b01ec6b5b6c89206a022100d71efefb4c24fab36abb44ade106963d8114c5af1bda033faa1923f54ec4ea6a01", "0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 CHECKSIG", "P2SH,STRICTENC", "Pay to pubkey with high S"],
+["0x47 0x3044022054cb0a3fca8694a0c231848fd9f965078148fd653e49dd4b6980fadac0f5ba0702204085be5af427d4561f13a07fd5a1c5ab0ff02126e9ba191448f5a9dae0da585301 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 0x19 0x76a914751e76e8199196d454941c45d1b3a323f1433bd688ac", "HASH160 0x14 0xcd7b44d0b03f2d026d1e586d7ae18903b0d385f6 EQUAL", "STRICTENC", "P2SH with a pay to pubkeyhash inside with invalid signature"],
+["1 0x48 0x3045022100e1c4e8800bd00c9ec3cd3de0e53e63bc5e8c018d0b68099a652f0b121f1a7e020220108dab275be7d1358530d3451d48aed747af77cc54e0423cbae5c572b2e1abb801", "1 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 1 CHECKMULTISIG", "P2SH,STRICTENC", "Raw multisig with one pubkey with non-zero dummy"],
+
+["The End"]
]
diff --git a/src/test/data/txcreate2.hex b/src/test/data/txcreate2.hex
new file mode 100644
index 0000000000..5243c2d02e
--- /dev/null
+++ b/src/test/data/txcreate2.hex
@@ -0,0 +1 @@
+01000000000100000000000000000000000000
diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp
index 47977cf295..9e4669eba9 100644
--- a/src/test/miner_tests.cpp
+++ b/src/test/miner_tests.cpp
@@ -170,7 +170,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
tx.vin[0].scriptSig = CScript() << OP_1;
tx.vout[0].nValue = 4900000000LL;
script = CScript() << OP_0;
- tx.vout[0].scriptPubKey.SetDestination(script.GetID());
+ tx.vout[0].scriptPubKey = GetScriptForDestination(script.GetID());
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
tx.vin[0].prevout.hash = hash;
diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp
index 6c5afa130c..cb37740068 100644
--- a/src/test/multisig_tests.cpp
+++ b/src/test/multisig_tests.cpp
@@ -8,9 +8,12 @@
#include "script/script.h"
#include "script/interpreter.h"
#include "script/sign.h"
-#include "scriptutils.h"
#include "uint256.h"
+#ifdef ENABLE_WALLET
+#include "wallet_ismine.h"
+#endif
+
#include <boost/assign/std/vector.hpp>
#include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp>
@@ -79,19 +82,19 @@ BOOST_AUTO_TEST_CASE(multisig_verify)
keys.clear();
keys += key[0],key[1]; // magic operator+= from boost.assign
s = sign_multisig(a_and_b, keys, txTo[0], 0);
- BOOST_CHECK(VerifyScript(s, a_and_b, txTo[0], 0, flags, 0));
+ BOOST_CHECK(VerifyScript(s, a_and_b, txTo[0], 0, flags));
for (int i = 0; i < 4; i++)
{
keys.clear();
keys += key[i];
s = sign_multisig(a_and_b, keys, txTo[0], 0);
- BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, txTo[0], 0, flags, 0), strprintf("a&b 1: %d", i));
+ BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, txTo[0], 0, flags), strprintf("a&b 1: %d", i));
keys.clear();
keys += key[1],key[i];
s = sign_multisig(a_and_b, keys, txTo[0], 0);
- BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, txTo[0], 0, flags, 0), strprintf("a&b 2: %d", i));
+ BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, txTo[0], 0, flags), strprintf("a&b 2: %d", i));
}
// Test a OR b:
@@ -101,16 +104,16 @@ BOOST_AUTO_TEST_CASE(multisig_verify)
keys += key[i];
s = sign_multisig(a_or_b, keys, txTo[1], 0);
if (i == 0 || i == 1)
- BOOST_CHECK_MESSAGE(VerifyScript(s, a_or_b, txTo[1], 0, flags, 0), strprintf("a|b: %d", i));
+ BOOST_CHECK_MESSAGE(VerifyScript(s, a_or_b, txTo[1], 0, flags), strprintf("a|b: %d", i));
else
- BOOST_CHECK_MESSAGE(!VerifyScript(s, a_or_b, txTo[1], 0, flags, 0), strprintf("a|b: %d", i));
+ BOOST_CHECK_MESSAGE(!VerifyScript(s, a_or_b, txTo[1], 0, flags), strprintf("a|b: %d", i));
}
s.clear();
s << OP_0 << OP_0;
- BOOST_CHECK(!VerifyScript(s, a_or_b, txTo[1], 0, flags, 0));
+ BOOST_CHECK(!VerifyScript(s, a_or_b, txTo[1], 0, flags));
s.clear();
s << OP_0 << OP_1;
- BOOST_CHECK(!VerifyScript(s, a_or_b, txTo[1], 0, flags, 0));
+ BOOST_CHECK(!VerifyScript(s, a_or_b, txTo[1], 0, flags));
for (int i = 0; i < 4; i++)
@@ -120,9 +123,9 @@ BOOST_AUTO_TEST_CASE(multisig_verify)
keys += key[i],key[j];
s = sign_multisig(escrow, keys, txTo[2], 0);
if (i < j && i < 3 && j < 3)
- BOOST_CHECK_MESSAGE(VerifyScript(s, escrow, txTo[2], 0, flags, 0), strprintf("escrow 1: %d %d", i, j));
+ BOOST_CHECK_MESSAGE(VerifyScript(s, escrow, txTo[2], 0, flags), strprintf("escrow 1: %d %d", i, j));
else
- BOOST_CHECK_MESSAGE(!VerifyScript(s, escrow, txTo[2], 0, flags, 0), strprintf("escrow 2: %d %d", i, j));
+ BOOST_CHECK_MESSAGE(!VerifyScript(s, escrow, txTo[2], 0, flags), strprintf("escrow 2: %d %d", i, j));
}
}
@@ -195,8 +198,10 @@ BOOST_AUTO_TEST_CASE(multisig_Solver1)
CTxDestination addr;
BOOST_CHECK(ExtractDestination(s, addr));
BOOST_CHECK(addr == keyaddr[0]);
+#ifdef ENABLE_WALLET
BOOST_CHECK(IsMine(keystore, s));
BOOST_CHECK(!IsMine(emptykeystore, s));
+#endif
}
{
vector<valtype> solutions;
@@ -208,8 +213,10 @@ BOOST_AUTO_TEST_CASE(multisig_Solver1)
CTxDestination addr;
BOOST_CHECK(ExtractDestination(s, addr));
BOOST_CHECK(addr == keyaddr[0]);
+#ifdef ENABLE_WALLET
BOOST_CHECK(IsMine(keystore, s));
BOOST_CHECK(!IsMine(emptykeystore, s));
+#endif
}
{
vector<valtype> solutions;
@@ -220,9 +227,11 @@ BOOST_AUTO_TEST_CASE(multisig_Solver1)
BOOST_CHECK_EQUAL(solutions.size(), 4U);
CTxDestination addr;
BOOST_CHECK(!ExtractDestination(s, addr));
+#ifdef ENABLE_WALLET
BOOST_CHECK(IsMine(keystore, s));
BOOST_CHECK(!IsMine(emptykeystore, s));
BOOST_CHECK(!IsMine(partialkeystore, s));
+#endif
}
{
vector<valtype> solutions;
@@ -237,9 +246,11 @@ BOOST_AUTO_TEST_CASE(multisig_Solver1)
BOOST_CHECK(addrs[0] == keyaddr[0]);
BOOST_CHECK(addrs[1] == keyaddr[1]);
BOOST_CHECK(nRequired == 1);
+#ifdef ENABLE_WALLET
BOOST_CHECK(IsMine(keystore, s));
BOOST_CHECK(!IsMine(emptykeystore, s));
BOOST_CHECK(!IsMine(partialkeystore, s));
+#endif
}
{
vector<valtype> solutions;
diff --git a/src/test/script_P2SH_tests.cpp b/src/test/script_P2SH_tests.cpp
index b7e7487bb2..e6cf00c2d0 100644
--- a/src/test/script_P2SH_tests.cpp
+++ b/src/test/script_P2SH_tests.cpp
@@ -7,7 +7,10 @@
#include "main.h"
#include "script/script.h"
#include "script/sign.h"
-#include "scriptutils.h"
+
+#ifdef ENABLE_WALLET
+#include "wallet_ismine.h"
+#endif
#include <vector>
@@ -39,7 +42,7 @@ Verify(const CScript& scriptSig, const CScript& scriptPubKey, bool fStrict)
txTo.vin[0].scriptSig = scriptSig;
txTo.vout[0].nValue = 1;
- return VerifyScript(scriptSig, scriptPubKey, txTo, 0, fStrict ? SCRIPT_VERIFY_P2SH : SCRIPT_VERIFY_NONE, 0);
+ return VerifyScript(scriptSig, scriptPubKey, txTo, 0, fStrict ? SCRIPT_VERIFY_P2SH : SCRIPT_VERIFY_NONE);
}
@@ -65,14 +68,14 @@ BOOST_AUTO_TEST_CASE(sign)
// different keys, straight/P2SH, pubkey/pubkeyhash
CScript standardScripts[4];
standardScripts[0] << key[0].GetPubKey() << OP_CHECKSIG;
- standardScripts[1].SetDestination(key[1].GetPubKey().GetID());
+ standardScripts[1] = GetScriptForDestination(key[1].GetPubKey().GetID());
standardScripts[2] << key[1].GetPubKey() << OP_CHECKSIG;
- standardScripts[3].SetDestination(key[2].GetPubKey().GetID());
+ standardScripts[3] = GetScriptForDestination(key[2].GetPubKey().GetID());
CScript evalScripts[4];
for (int i = 0; i < 4; i++)
{
keystore.AddCScript(standardScripts[i]);
- evalScripts[i].SetDestination(standardScripts[i].GetID());
+ evalScripts[i] = GetScriptForDestination(standardScripts[i].GetID());
}
CMutableTransaction txFrom; // Funding transaction:
@@ -95,7 +98,9 @@ BOOST_AUTO_TEST_CASE(sign)
txTo[i].vin[0].prevout.n = i;
txTo[i].vin[0].prevout.hash = txFrom.GetHash();
txTo[i].vout[0].nValue = 1;
+#ifdef ENABLE_WALLET
BOOST_CHECK_MESSAGE(IsMine(keystore, txFrom.vout[i].scriptPubKey), strprintf("IsMine %d", i));
+#endif
}
for (int i = 0; i < 8; i++)
{
@@ -108,7 +113,7 @@ BOOST_AUTO_TEST_CASE(sign)
{
CScript sigSave = txTo[i].vin[0].scriptSig;
txTo[i].vin[0].scriptSig = txTo[j].vin[0].scriptSig;
- bool sigOK = VerifySignature(CCoins(txFrom, 0), txTo[i], 0, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC, 0);
+ bool sigOK = CScriptCheck(CCoins(txFrom, 0), txTo[i], 0, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC)();
if (i == j)
BOOST_CHECK_MESSAGE(sigOK, strprintf("VerifySignature %d %d", i, j));
else
@@ -124,8 +129,7 @@ BOOST_AUTO_TEST_CASE(norecurse)
CScript invalidAsScript;
invalidAsScript << OP_INVALIDOPCODE << OP_INVALIDOPCODE;
- CScript p2sh;
- p2sh.SetDestination(invalidAsScript.GetID());
+ CScript p2sh = GetScriptForDestination(invalidAsScript.GetID());
CScript scriptSig;
scriptSig << Serialize(invalidAsScript);
@@ -135,8 +139,7 @@ BOOST_AUTO_TEST_CASE(norecurse)
// Try to recur, and verification should succeed because
// the inner HASH160 <> EQUAL should only check the hash:
- CScript p2sh2;
- p2sh2.SetDestination(p2sh.GetID());
+ CScript p2sh2 = GetScriptForDestination(p2sh.GetID());
CScript scriptSig2;
scriptSig2 << Serialize(invalidAsScript) << Serialize(p2sh);
@@ -158,15 +161,15 @@ BOOST_AUTO_TEST_CASE(set)
}
CScript inner[4];
- inner[0].SetDestination(key[0].GetPubKey().GetID());
- inner[1].SetMultisig(2, std::vector<CPubKey>(keys.begin(), keys.begin()+2));
- inner[2].SetMultisig(1, std::vector<CPubKey>(keys.begin(), keys.begin()+2));
- inner[3].SetMultisig(2, std::vector<CPubKey>(keys.begin(), keys.begin()+3));
+ inner[0] = GetScriptForDestination(key[0].GetPubKey().GetID());
+ inner[1] = GetScriptForMultisig(2, std::vector<CPubKey>(keys.begin(), keys.begin()+2));
+ inner[2] = GetScriptForMultisig(1, std::vector<CPubKey>(keys.begin(), keys.begin()+2));
+ inner[3] = GetScriptForMultisig(2, std::vector<CPubKey>(keys.begin(), keys.begin()+3));
CScript outer[4];
for (int i = 0; i < 4; i++)
{
- outer[i].SetDestination(inner[i].GetID());
+ outer[i] = GetScriptForDestination(inner[i].GetID());
keystore.AddCScript(inner[i]);
}
@@ -189,7 +192,9 @@ BOOST_AUTO_TEST_CASE(set)
txTo[i].vin[0].prevout.hash = txFrom.GetHash();
txTo[i].vout[0].nValue = 1*CENT;
txTo[i].vout[0].scriptPubKey = inner[i];
+#ifdef ENABLE_WALLET
BOOST_CHECK_MESSAGE(IsMine(keystore, txFrom.vout[i].scriptPubKey), strprintf("IsMine %d", i));
+#endif
}
for (int i = 0; i < 4; i++)
{
@@ -237,8 +242,7 @@ BOOST_AUTO_TEST_CASE(switchover)
CScript scriptSig;
scriptSig << Serialize(notValid);
- CScript fund;
- fund.SetDestination(notValid.GetID());
+ CScript fund = GetScriptForDestination(notValid.GetID());
// Validation should succeed under old rules (hash is correct):
@@ -267,11 +271,11 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
txFrom.vout.resize(7);
// First three are standard:
- CScript pay1; pay1.SetDestination(key[0].GetPubKey().GetID());
+ CScript pay1 = GetScriptForDestination(key[0].GetPubKey().GetID());
keystore.AddCScript(pay1);
- CScript pay1of3; pay1of3.SetMultisig(1, keys);
+ CScript pay1of3 = GetScriptForMultisig(1, keys);
- txFrom.vout[0].scriptPubKey.SetDestination(pay1.GetID()); // P2SH (OP_CHECKSIG)
+ txFrom.vout[0].scriptPubKey = GetScriptForDestination(pay1.GetID()); // P2SH (OP_CHECKSIG)
txFrom.vout[0].nValue = 1000;
txFrom.vout[1].scriptPubKey = pay1; // ordinary OP_CHECKSIG
txFrom.vout[1].nValue = 2000;
@@ -286,7 +290,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
oneAndTwo << OP_2 << key[3].GetPubKey() << key[4].GetPubKey() << key[5].GetPubKey();
oneAndTwo << OP_3 << OP_CHECKMULTISIG;
keystore.AddCScript(oneAndTwo);
- txFrom.vout[3].scriptPubKey.SetDestination(oneAndTwo.GetID());
+ txFrom.vout[3].scriptPubKey = GetScriptForDestination(oneAndTwo.GetID());
txFrom.vout[3].nValue = 4000;
// vout[4] is max sigops:
@@ -295,17 +299,17 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
fifteenSigops << key[i%3].GetPubKey();
fifteenSigops << OP_15 << OP_CHECKMULTISIG;
keystore.AddCScript(fifteenSigops);
- txFrom.vout[4].scriptPubKey.SetDestination(fifteenSigops.GetID());
+ txFrom.vout[4].scriptPubKey = GetScriptForDestination(fifteenSigops.GetID());
txFrom.vout[4].nValue = 5000;
// vout[5/6] are non-standard because they exceed MAX_P2SH_SIGOPS
CScript sixteenSigops; sixteenSigops << OP_16 << OP_CHECKMULTISIG;
keystore.AddCScript(sixteenSigops);
- txFrom.vout[5].scriptPubKey.SetDestination(fifteenSigops.GetID());
+ txFrom.vout[5].scriptPubKey = GetScriptForDestination(fifteenSigops.GetID());
txFrom.vout[5].nValue = 5000;
CScript twentySigops; twentySigops << OP_CHECKMULTISIG;
keystore.AddCScript(twentySigops);
- txFrom.vout[6].scriptPubKey.SetDestination(twentySigops.GetID());
+ txFrom.vout[6].scriptPubKey = GetScriptForDestination(twentySigops.GetID());
txFrom.vout[6].nValue = 6000;
@@ -313,7 +317,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
CMutableTransaction txTo;
txTo.vout.resize(1);
- txTo.vout[0].scriptPubKey.SetDestination(key[1].GetPubKey().GetID());
+ txTo.vout[0].scriptPubKey = GetScriptForDestination(key[1].GetPubKey().GetID());
txTo.vin.resize(5);
for (int i = 0; i < 5; i++)
@@ -345,7 +349,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
CMutableTransaction txToNonStd1;
txToNonStd1.vout.resize(1);
- txToNonStd1.vout[0].scriptPubKey.SetDestination(key[1].GetPubKey().GetID());
+ txToNonStd1.vout[0].scriptPubKey = GetScriptForDestination(key[1].GetPubKey().GetID());
txToNonStd1.vout[0].nValue = 1000;
txToNonStd1.vin.resize(1);
txToNonStd1.vin[0].prevout.n = 5;
@@ -357,7 +361,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
CMutableTransaction txToNonStd2;
txToNonStd2.vout.resize(1);
- txToNonStd2.vout[0].scriptPubKey.SetDestination(key[1].GetPubKey().GetID());
+ txToNonStd2.vout[0].scriptPubKey = GetScriptForDestination(key[1].GetPubKey().GetID());
txToNonStd2.vout[0].nValue = 1000;
txToNonStd2.vin.resize(1);
txToNonStd2.vin[0].prevout.n = 6;
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index 88efc38964..178b35fa2d 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -35,6 +35,8 @@ using namespace boost::algorithm;
static const unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC;
+unsigned int ParseScriptFlags(string strFlags);
+
Array
read_json(const std::string& jsondata)
{
@@ -50,11 +52,46 @@ read_json(const std::string& jsondata)
BOOST_AUTO_TEST_SUITE(script_tests)
+CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey)
+{
+ CMutableTransaction txCredit;
+ txCredit.nVersion = 1;
+ txCredit.nLockTime = 0;
+ txCredit.vin.resize(1);
+ txCredit.vout.resize(1);
+ txCredit.vin[0].prevout.SetNull();
+ txCredit.vin[0].scriptSig = CScript() << CScriptNum(0) << CScriptNum(0);
+ txCredit.vin[0].nSequence = std::numeric_limits<unsigned int>::max();
+ txCredit.vout[0].scriptPubKey = scriptPubKey;
+ txCredit.vout[0].nValue = 0;
+
+ return txCredit;
+}
+
+CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CScript& scriptPubKey)
+{
+ CMutableTransaction txCredit = BuildCreditingTransaction(scriptPubKey);
+
+ CMutableTransaction txSpend;
+ txSpend.nVersion = 1;
+ txSpend.nLockTime = 0;
+ txSpend.vin.resize(1);
+ txSpend.vout.resize(1);
+ txSpend.vin[0].prevout.hash = txCredit.GetHash();
+ txSpend.vin[0].prevout.n = 0;
+ txSpend.vin[0].scriptSig = scriptSig;
+ txSpend.vin[0].nSequence = std::numeric_limits<unsigned int>::max();
+ txSpend.vout[0].scriptPubKey = CScript();
+ txSpend.vout[0].nValue = 0;
+
+ return txSpend;
+}
+
BOOST_AUTO_TEST_CASE(script_valid)
{
// Read tests from test/data/script_valid.json
// Format is an array of arrays
- // Inner arrays are [ "scriptSig", "scriptPubKey" ]
+ // Inner arrays are [ "scriptSig", "scriptPubKey", "flags" ]
// ... where scriptSig and scriptPubKey are stringified
// scripts.
Array tests = read_json(std::string(json_tests::script_valid, json_tests::script_valid + sizeof(json_tests::script_valid)));
@@ -63,18 +100,21 @@ BOOST_AUTO_TEST_CASE(script_valid)
{
Array test = tv.get_array();
string strTest = write_string(tv, false);
- if (test.size() < 2) // Allow size > 2; extra stuff ignored (useful for comments)
+ if (test.size() < 3) // Allow size > 3; extra stuff ignored (useful for comments)
{
- BOOST_ERROR("Bad test: " << strTest);
+ if (test.size() != 1) {
+ BOOST_ERROR("Bad test: " << strTest);
+ }
continue;
}
string scriptSigString = test[0].get_str();
CScript scriptSig = ParseScript(scriptSigString);
string scriptPubKeyString = test[1].get_str();
CScript scriptPubKey = ParseScript(scriptPubKeyString);
+ unsigned int scriptflags = ParseScriptFlags(test[2].get_str());
CTransaction tx;
- BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, tx, 0, flags, SIGHASH_NONE), strTest);
+ BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, BuildSpendingTransaction(scriptSig, scriptPubKey), 0, scriptflags), strTest);
}
}
@@ -87,18 +127,21 @@ BOOST_AUTO_TEST_CASE(script_invalid)
{
Array test = tv.get_array();
string strTest = write_string(tv, false);
- if (test.size() < 2) // Allow size > 2; extra stuff ignored (useful for comments)
+ if (test.size() < 3) // Allow size > 3; extra stuff ignored (useful for comments)
{
- BOOST_ERROR("Bad test: " << strTest);
+ if (test.size() != 1) {
+ BOOST_ERROR("Bad test: " << strTest);
+ }
continue;
}
string scriptSigString = test[0].get_str();
CScript scriptSig = ParseScript(scriptSigString);
string scriptPubKeyString = test[1].get_str();
CScript scriptPubKey = ParseScript(scriptPubKeyString);
+ unsigned int scriptflags = ParseScriptFlags(test[2].get_str());
CTransaction tx;
- BOOST_CHECK_MESSAGE(!VerifyScript(scriptSig, scriptPubKey, tx, 0, flags, SIGHASH_NONE), strTest);
+ BOOST_CHECK_MESSAGE(!VerifyScript(scriptSig, scriptPubKey, BuildSpendingTransaction(scriptSig, scriptPubKey), 0, scriptflags), strTest);
}
}
@@ -112,18 +155,18 @@ BOOST_AUTO_TEST_CASE(script_PushData)
static const unsigned char pushdata4[] = { OP_PUSHDATA4, 1, 0, 0, 0, 0x5a };
vector<vector<unsigned char> > directStack;
- BOOST_CHECK(EvalScript(directStack, CScript(&direct[0], &direct[sizeof(direct)]), CTransaction(), 0, true, 0));
+ BOOST_CHECK(EvalScript(directStack, CScript(&direct[0], &direct[sizeof(direct)]), CTransaction(), 0, true));
vector<vector<unsigned char> > pushdata1Stack;
- BOOST_CHECK(EvalScript(pushdata1Stack, CScript(&pushdata1[0], &pushdata1[sizeof(pushdata1)]), CTransaction(), 0, true, 0));
+ BOOST_CHECK(EvalScript(pushdata1Stack, CScript(&pushdata1[0], &pushdata1[sizeof(pushdata1)]), CTransaction(), 0, true));
BOOST_CHECK(pushdata1Stack == directStack);
vector<vector<unsigned char> > pushdata2Stack;
- BOOST_CHECK(EvalScript(pushdata2Stack, CScript(&pushdata2[0], &pushdata2[sizeof(pushdata2)]), CTransaction(), 0, true, 0));
+ BOOST_CHECK(EvalScript(pushdata2Stack, CScript(&pushdata2[0], &pushdata2[sizeof(pushdata2)]), CTransaction(), 0, true));
BOOST_CHECK(pushdata2Stack == directStack);
vector<vector<unsigned char> > pushdata4Stack;
- BOOST_CHECK(EvalScript(pushdata4Stack, CScript(&pushdata4[0], &pushdata4[sizeof(pushdata4)]), CTransaction(), 0, true, 0));
+ BOOST_CHECK(EvalScript(pushdata4Stack, CScript(&pushdata4[0], &pushdata4[sizeof(pushdata4)]), CTransaction(), 0, true));
BOOST_CHECK(pushdata4Stack == directStack);
}
@@ -181,15 +224,15 @@ BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG12)
txTo12.vout[0].nValue = 1;
CScript goodsig1 = sign_multisig(scriptPubKey12, key1, txTo12);
- BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, flags, 0));
+ BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, flags));
txTo12.vout[0].nValue = 2;
- BOOST_CHECK(!VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, flags, 0));
+ BOOST_CHECK(!VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, flags));
CScript goodsig2 = sign_multisig(scriptPubKey12, key2, txTo12);
- BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey12, txTo12, 0, flags, 0));
+ BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey12, txTo12, 0, flags));
CScript badsig1 = sign_multisig(scriptPubKey12, key3, txTo12);
- BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey12, txTo12, 0, flags, 0));
+ BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey12, txTo12, 0, flags));
}
BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG23)
@@ -217,46 +260,46 @@ BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG23)
std::vector<CKey> keys;
keys.push_back(key1); keys.push_back(key2);
CScript goodsig1 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey23, txTo23, 0, flags, 0));
+ BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey23, txTo23, 0, flags));
keys.clear();
keys.push_back(key1); keys.push_back(key3);
CScript goodsig2 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey23, txTo23, 0, flags, 0));
+ BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey23, txTo23, 0, flags));
keys.clear();
keys.push_back(key2); keys.push_back(key3);
CScript goodsig3 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(VerifyScript(goodsig3, scriptPubKey23, txTo23, 0, flags, 0));
+ BOOST_CHECK(VerifyScript(goodsig3, scriptPubKey23, txTo23, 0, flags));
keys.clear();
keys.push_back(key2); keys.push_back(key2); // Can't re-use sig
CScript badsig1 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, txTo23, 0, flags, 0));
+ BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, txTo23, 0, flags));
keys.clear();
keys.push_back(key2); keys.push_back(key1); // sigs must be in correct order
CScript badsig2 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(!VerifyScript(badsig2, scriptPubKey23, txTo23, 0, flags, 0));
+ BOOST_CHECK(!VerifyScript(badsig2, scriptPubKey23, txTo23, 0, flags));
keys.clear();
keys.push_back(key3); keys.push_back(key2); // sigs must be in correct order
CScript badsig3 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(!VerifyScript(badsig3, scriptPubKey23, txTo23, 0, flags, 0));
+ BOOST_CHECK(!VerifyScript(badsig3, scriptPubKey23, txTo23, 0, flags));
keys.clear();
keys.push_back(key4); keys.push_back(key2); // sigs must match pubkeys
CScript badsig4 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(!VerifyScript(badsig4, scriptPubKey23, txTo23, 0, flags, 0));
+ BOOST_CHECK(!VerifyScript(badsig4, scriptPubKey23, txTo23, 0, flags));
keys.clear();
keys.push_back(key1); keys.push_back(key4); // sigs must match pubkeys
CScript badsig5 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(!VerifyScript(badsig5, scriptPubKey23, txTo23, 0, flags, 0));
+ BOOST_CHECK(!VerifyScript(badsig5, scriptPubKey23, txTo23, 0, flags));
keys.clear(); // Must have signatures
CScript badsig6 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(!VerifyScript(badsig6, scriptPubKey23, txTo23, 0, flags, 0));
+ BOOST_CHECK(!VerifyScript(badsig6, scriptPubKey23, txTo23, 0, flags));
}
BOOST_AUTO_TEST_CASE(script_combineSigs)
@@ -276,7 +319,7 @@ BOOST_AUTO_TEST_CASE(script_combineSigs)
CMutableTransaction txFrom;
txFrom.vout.resize(1);
- txFrom.vout[0].scriptPubKey.SetDestination(keys[0].GetPubKey().GetID());
+ txFrom.vout[0].scriptPubKey = GetScriptForDestination(keys[0].GetPubKey().GetID());
CScript& scriptPubKey = txFrom.vout[0].scriptPubKey;
CMutableTransaction txTo;
txTo.vin.resize(1);
@@ -305,7 +348,7 @@ BOOST_AUTO_TEST_CASE(script_combineSigs)
// P2SH, single-signature case:
CScript pkSingle; pkSingle << keys[0].GetPubKey() << OP_CHECKSIG;
keystore.AddCScript(pkSingle);
- scriptPubKey.SetDestination(pkSingle.GetID());
+ scriptPubKey = GetScriptForDestination(pkSingle.GetID());
SignSignature(keystore, txFrom, txTo, 0);
combined = CombineSignatures(scriptPubKey, txTo, 0, scriptSig, empty);
BOOST_CHECK(combined == scriptSig);
@@ -323,7 +366,7 @@ BOOST_AUTO_TEST_CASE(script_combineSigs)
BOOST_CHECK(combined == scriptSig);
// Hardest case: Multisig 2-of-3
- scriptPubKey.SetMultisig(2, pubkeys);
+ scriptPubKey = GetScriptForMultisig(2, pubkeys);
keystore.AddCScript(scriptPubKey);
SignSignature(keystore, txFrom, txTo, 0);
combined = CombineSignatures(scriptPubKey, txTo, 0, scriptSig, empty);
diff --git a/src/test/sigopcount_tests.cpp b/src/test/sigopcount_tests.cpp
index 2d10c356ac..62a6cd63d6 100644
--- a/src/test/sigopcount_tests.cpp
+++ b/src/test/sigopcount_tests.cpp
@@ -4,6 +4,7 @@
#include "key.h"
#include "script/script.h"
+#include "script/standard.h"
#include "uint256.h"
#include <vector>
@@ -37,8 +38,7 @@ BOOST_AUTO_TEST_CASE(GetSigOpCount)
BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 3U);
BOOST_CHECK_EQUAL(s1.GetSigOpCount(false), 21U);
- CScript p2sh;
- p2sh.SetDestination(s1.GetID());
+ CScript p2sh = GetScriptForDestination(s1.GetID());
CScript scriptSig;
scriptSig << OP_0 << Serialize(s1);
BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(scriptSig), 3U);
@@ -50,12 +50,11 @@ BOOST_AUTO_TEST_CASE(GetSigOpCount)
k.MakeNewKey(true);
keys.push_back(k.GetPubKey());
}
- CScript s2;
- s2.SetMultisig(1, keys);
+ CScript s2 = GetScriptForMultisig(1, keys);
BOOST_CHECK_EQUAL(s2.GetSigOpCount(true), 3U);
BOOST_CHECK_EQUAL(s2.GetSigOpCount(false), 20U);
- p2sh.SetDestination(s2.GetID());
+ p2sh = GetScriptForDestination(s2.GetID());
BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(true), 0U);
BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(false), 0U);
CScript scriptSig2;
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
index 943568e89d..41d8ee9f19 100644
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -26,7 +26,7 @@ using namespace boost::algorithm;
// In script_tests.cpp
extern Array read_json(const std::string& jsondata);
-unsigned int ParseFlags(string strFlags){
+unsigned int ParseScriptFlags(string strFlags){
unsigned int flags = 0;
vector<string> words;
split(words, strFlags, is_any_of(","));
@@ -119,9 +119,9 @@ BOOST_AUTO_TEST_CASE(tx_valid)
break;
}
- unsigned int verify_flags = ParseFlags(test[2].get_str());
+ unsigned int verify_flags = ParseScriptFlags(test[2].get_str());
BOOST_CHECK_MESSAGE(VerifyScript(tx.vin[i].scriptSig, mapprevOutScriptPubKeys[tx.vin[i].prevout],
- tx, i, verify_flags, 0),
+ tx, i, verify_flags),
strTest);
}
}
@@ -192,9 +192,9 @@ BOOST_AUTO_TEST_CASE(tx_invalid)
break;
}
- unsigned int verify_flags = ParseFlags(test[2].get_str());
+ unsigned int verify_flags = ParseScriptFlags(test[2].get_str());
fValid = VerifyScript(tx.vin[i].scriptSig, mapprevOutScriptPubKeys[tx.vin[i].prevout],
- tx, i, verify_flags, 0);
+ tx, i, verify_flags);
}
BOOST_CHECK_MESSAGE(!fValid, strTest);
@@ -248,9 +248,9 @@ SetupDummyInputs(CBasicKeyStore& keystoreRet, CCoinsView & coinsRet)
dummyTransactions[1].vout.resize(2);
dummyTransactions[1].vout[0].nValue = 21*CENT;
- dummyTransactions[1].vout[0].scriptPubKey.SetDestination(key[2].GetPubKey().GetID());
+ dummyTransactions[1].vout[0].scriptPubKey = GetScriptForDestination(key[2].GetPubKey().GetID());
dummyTransactions[1].vout[1].nValue = 22*CENT;
- dummyTransactions[1].vout[1].scriptPubKey.SetDestination(key[3].GetPubKey().GetID());
+ dummyTransactions[1].vout[1].scriptPubKey = GetScriptForDestination(key[3].GetPubKey().GetID());
coinsRet.SetCoins(dummyTransactions[1].GetHash(), CCoins(dummyTransactions[1], 0));
return dummyTransactions;
@@ -307,7 +307,7 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
t.vout[0].nValue = 90*CENT;
CKey key;
key.MakeNewKey(true);
- t.vout[0].scriptPubKey.SetDestination(key.GetPubKey().GetID());
+ t.vout[0].scriptPubKey = GetScriptForDestination(key.GetPubKey().GetID());
string reason;
BOOST_CHECK(IsStandardTx(t, reason));
diff --git a/src/threadsafety.h b/src/threadsafety.h
index 9ee39372e1..7515d050e7 100644
--- a/src/threadsafety.h
+++ b/src/threadsafety.h
@@ -13,24 +13,24 @@
// See http://clang.llvm.org/docs/LanguageExtensions.html#threadsafety
// for documentation. The clang compiler can do advanced static analysis
// of locking when given the -Wthread-safety option.
-#define LOCKABLE __attribute__ ((lockable))
-#define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
-#define GUARDED_BY(x) __attribute__ ((guarded_by(x)))
-#define GUARDED_VAR __attribute__ ((guarded_var))
-#define PT_GUARDED_BY(x) __attribute__ ((pt_guarded_by(x)))
-#define PT_GUARDED_VAR __attribute__ ((pt_guarded_var))
-#define ACQUIRED_AFTER(...) __attribute__ ((acquired_after(__VA_ARGS__)))
-#define ACQUIRED_BEFORE(...) __attribute__ ((acquired_before(__VA_ARGS__)))
-#define EXCLUSIVE_LOCK_FUNCTION(...) __attribute__ ((exclusive_lock_function(__VA_ARGS__)))
-#define SHARED_LOCK_FUNCTION(...) __attribute__ ((shared_lock_function(__VA_ARGS__)))
-#define EXCLUSIVE_TRYLOCK_FUNCTION(...) __attribute__ ((exclusive_trylock_function(__VA_ARGS__)))
-#define SHARED_TRYLOCK_FUNCTION(...) __attribute__ ((shared_trylock_function(__VA_ARGS__)))
-#define UNLOCK_FUNCTION(...) __attribute__ ((unlock_function(__VA_ARGS__)))
-#define LOCK_RETURNED(x) __attribute__ ((lock_returned(x)))
-#define LOCKS_EXCLUDED(...) __attribute__ ((locks_excluded(__VA_ARGS__)))
-#define EXCLUSIVE_LOCKS_REQUIRED(...) __attribute__ ((exclusive_locks_required(__VA_ARGS__)))
-#define SHARED_LOCKS_REQUIRED(...) __attribute__ ((shared_locks_required(__VA_ARGS__)))
-#define NO_THREAD_SAFETY_ANALYSIS __attribute__ ((no_thread_safety_analysis))
+#define LOCKABLE __attribute__((lockable))
+#define SCOPED_LOCKABLE __attribute__((scoped_lockable))
+#define GUARDED_BY(x) __attribute__((guarded_by(x)))
+#define GUARDED_VAR __attribute__((guarded_var))
+#define PT_GUARDED_BY(x) __attribute__((pt_guarded_by(x)))
+#define PT_GUARDED_VAR __attribute__((pt_guarded_var))
+#define ACQUIRED_AFTER(...) __attribute__((acquired_after(__VA_ARGS__)))
+#define ACQUIRED_BEFORE(...) __attribute__((acquired_before(__VA_ARGS__)))
+#define EXCLUSIVE_LOCK_FUNCTION(...) __attribute__((exclusive_lock_function(__VA_ARGS__)))
+#define SHARED_LOCK_FUNCTION(...) __attribute__((shared_lock_function(__VA_ARGS__)))
+#define EXCLUSIVE_TRYLOCK_FUNCTION(...) __attribute__((exclusive_trylock_function(__VA_ARGS__)))
+#define SHARED_TRYLOCK_FUNCTION(...) __attribute__((shared_trylock_function(__VA_ARGS__)))
+#define UNLOCK_FUNCTION(...) __attribute__((unlock_function(__VA_ARGS__)))
+#define LOCK_RETURNED(x) __attribute__((lock_returned(x)))
+#define LOCKS_EXCLUDED(...) __attribute__((locks_excluded(__VA_ARGS__)))
+#define EXCLUSIVE_LOCKS_REQUIRED(...) __attribute__((exclusive_locks_required(__VA_ARGS__)))
+#define SHARED_LOCKS_REQUIRED(...) __attribute__((shared_locks_required(__VA_ARGS__)))
+#define NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis))
#else
#define LOCKABLE
#define SCOPED_LOCKABLE
@@ -50,6 +50,6 @@
#define EXCLUSIVE_LOCKS_REQUIRED(...)
#define SHARED_LOCKS_REQUIRED(...)
#define NO_THREAD_SAFETY_ANALYSIS
-#endif // __GNUC__
+#endif // __GNUC__
-#endif // BITCOIN_THREADSAFETY_H
+#endif // BITCOIN_THREADSAFETY_H
diff --git a/src/timedata.h b/src/timedata.h
index 9cc47bec13..2c20f4efd5 100644
--- a/src/timedata.h
+++ b/src/timedata.h
@@ -5,25 +5,26 @@
#ifndef BITCOIN_TIMEDATA_H
#define BITCOIN_TIMEDATA_H
-#include <stdint.h>
-#include <vector>
#include <algorithm>
#include <assert.h>
+#include <stdint.h>
+#include <vector>
class CNetAddr;
/** Median filter over a stream of values.
* Returns the median of the last N numbers
*/
-template <typename T> class CMedianFilter
+template <typename T>
+class CMedianFilter
{
private:
std::vector<T> vValues;
std::vector<T> vSorted;
unsigned int nSize;
+
public:
- CMedianFilter(unsigned int size, T initial_value):
- nSize(size)
+ CMedianFilter(unsigned int size, T initial_value) : nSize(size)
{
vValues.reserve(size);
vValues.push_back(initial_value);
@@ -32,8 +33,7 @@ public:
void input(T value)
{
- if(vValues.size() == nSize)
- {
+ if (vValues.size() == nSize) {
vValues.erase(vValues.begin());
}
vValues.push_back(value);
@@ -46,14 +46,13 @@ public:
T median() const
{
int size = vSorted.size();
- assert(size>0);
- if(size & 1) // Odd number of elements
+ assert(size > 0);
+ if (size & 1) // Odd number of elements
{
- return vSorted[size/2];
- }
- else // Even number of elements
+ return vSorted[size / 2];
+ } else // Even number of elements
{
- return (vSorted[size/2-1] + vSorted[size/2]) / 2;
+ return (vSorted[size / 2 - 1] + vSorted[size / 2]) / 2;
}
}
@@ -62,7 +61,7 @@ public:
return vValues.size();
}
- std::vector<T> sorted () const
+ std::vector<T> sorted() const
{
return vSorted;
}
diff --git a/src/txdb.cpp b/src/txdb.cpp
index d4c6007558..79838b6116 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -9,9 +9,10 @@
#include "pow.h"
#include "uint256.h"
-#include <boost/thread.hpp>
#include <stdint.h>
+#include <boost/thread.hpp>
+
using namespace std;
void static BatchWriteCoins(CLevelDBBatch &batch, const uint256 &hash, const CCoins &coins) {
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 238d5bab16..52d07bf6a0 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -3,8 +3,9 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include "core.h"
#include "txmempool.h"
+
+#include "core.h"
#include "util.h"
#include <boost/circular_buffer.hpp>
@@ -12,7 +13,7 @@
using namespace std;
CTxMemPoolEntry::CTxMemPoolEntry():
- nFee(0), nTxSize(0), nTime(0), dPriority(0.0)
+ nFee(0), nTxSize(0), nModSize(0), nTime(0), dPriority(0.0)
{
nHeight = MEMPOOL_HEIGHT;
}
@@ -23,6 +24,8 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransaction& _tx, int64_t _nFee,
tx(_tx), nFee(_nFee), nTime(_nTime), dPriority(_dPriority), nHeight(_nHeight)
{
nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
+
+ nModSize = tx.CalculateModifiedSize(nTxSize);
}
CTxMemPoolEntry::CTxMemPoolEntry(const CTxMemPoolEntry& other)
@@ -34,7 +37,7 @@ double
CTxMemPoolEntry::GetPriority(unsigned int currentHeight) const
{
int64_t nValueIn = tx.GetValueOut()+nFee;
- double deltaPriority = ((double)(currentHeight-nHeight)*nValueIn)/nTxSize;
+ double deltaPriority = ((double)(currentHeight-nHeight)*nValueIn)/nModSize;
double dResult = dPriority + deltaPriority;
return dResult;
}
@@ -509,8 +512,8 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
const CTransaction& tx2 = it2->second.GetTx();
assert(tx2.vout.size() > txin.prevout.n && !tx2.vout[txin.prevout.n].IsNull());
} else {
- const CCoins &coins = pcoins->GetCoins(txin.prevout.hash);
- assert(coins.IsAvailable(txin.prevout.n));
+ const CCoins* coins = pcoins->AccessCoins(txin.prevout.hash);
+ assert(coins && coins->IsAvailable(txin.prevout.n));
}
// Check whether its inputs are marked in mapNextTx.
std::map<COutPoint, CInPoint>::const_iterator it3 = mapNextTx.find(txin.prevout);
@@ -572,7 +575,7 @@ CTxMemPool::WriteFeeEstimates(CAutoFile& fileout) const
fileout << CLIENT_VERSION; // version that wrote the file
minerPolicyEstimator->Write(fileout);
}
- catch (std::exception &e) {
+ catch (const std::exception &) {
LogPrintf("CTxMemPool::WriteFeeEstimates() : unable to write policy estimator data (non-fatal)");
return false;
}
@@ -591,7 +594,7 @@ CTxMemPool::ReadFeeEstimates(CAutoFile& filein)
LOCK(cs);
minerPolicyEstimator->Read(filein, minRelayFee);
}
- catch (std::exception &e) {
+ catch (const std::exception &) {
LogPrintf("CTxMemPool::ReadFeeEstimates() : unable to read policy estimator data (non-fatal)");
return false;
}
@@ -606,7 +609,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256 hash, const string strHash,
deltas.first += dPriorityDelta;
deltas.second += nFeeDelta;
}
- LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", strHash.c_str(), dPriorityDelta, nFeeDelta);
+ LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", strHash, dPriorityDelta, nFeeDelta);
}
void CTxMemPool::ApplyDeltas(const uint256 hash, double &dPriorityDelta, int64_t &nFeeDelta)
@@ -644,4 +647,3 @@ bool CCoinsViewMemPool::GetCoins(const uint256 &txid, CCoins &coins) const {
bool CCoinsViewMemPool::HaveCoins(const uint256 &txid) const {
return mempool.exists(txid) || base->HaveCoins(txid);
}
-
diff --git a/src/txmempool.h b/src/txmempool.h
index 360364d8b0..b9d50ee0bc 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -31,6 +31,7 @@ private:
CTransaction tx;
int64_t nFee; // Cached to avoid expensive parent-transaction lookups
size_t nTxSize; // ... and avoid recomputing tx size
+ size_t nModSize; // ... and modified size for priority
int64_t nTime; // Local time when entering the mempool
double dPriority; // Priority when entering the mempool
unsigned int nHeight; // Chain height when entering the mempool
diff --git a/src/uint256.cpp b/src/uint256.cpp
index feda0ca5a9..79406f2475 100644
--- a/src/uint256.cpp
+++ b/src/uint256.cpp
@@ -10,13 +10,13 @@
#include <stdio.h>
#include <string.h>
-template<unsigned int BITS>
+template <unsigned int BITS>
base_uint<BITS>::base_uint(const std::string& str)
{
SetHex(str);
}
-template<unsigned int BITS>
+template <unsigned int BITS>
base_uint<BITS>::base_uint(const std::vector<unsigned char>& vch)
{
if (vch.size() != sizeof(pn))
@@ -24,7 +24,7 @@ base_uint<BITS>::base_uint(const std::vector<unsigned char>& vch)
memcpy(pn, &vch[0], sizeof(pn));
}
-template<unsigned int BITS>
+template <unsigned int BITS>
base_uint<BITS>& base_uint<BITS>::operator<<=(unsigned int shift)
{
base_uint<BITS> a(*this);
@@ -33,15 +33,15 @@ base_uint<BITS>& base_uint<BITS>::operator<<=(unsigned int shift)
int k = shift / 32;
shift = shift % 32;
for (int i = 0; i < WIDTH; i++) {
- if (i+k+1 < WIDTH && shift != 0)
- pn[i+k+1] |= (a.pn[i] >> (32-shift));
- if (i+k < WIDTH)
- pn[i+k] |= (a.pn[i] << shift);
+ if (i + k + 1 < WIDTH && shift != 0)
+ pn[i + k + 1] |= (a.pn[i] >> (32 - shift));
+ if (i + k < WIDTH)
+ pn[i + k] |= (a.pn[i] << shift);
}
return *this;
}
-template<unsigned int BITS>
+template <unsigned int BITS>
base_uint<BITS>& base_uint<BITS>::operator>>=(unsigned int shift)
{
base_uint<BITS> a(*this);
@@ -50,15 +50,15 @@ base_uint<BITS>& base_uint<BITS>::operator>>=(unsigned int shift)
int k = shift / 32;
shift = shift % 32;
for (int i = 0; i < WIDTH; i++) {
- if (i-k-1 >= 0 && shift != 0)
- pn[i-k-1] |= (a.pn[i] << (32-shift));
- if (i-k >= 0)
- pn[i-k] |= (a.pn[i] >> shift);
+ if (i - k - 1 >= 0 && shift != 0)
+ pn[i - k - 1] |= (a.pn[i] << (32 - shift));
+ if (i - k >= 0)
+ pn[i - k] |= (a.pn[i] >> shift);
}
return *this;
}
-template<unsigned int BITS>
+template <unsigned int BITS>
base_uint<BITS>& base_uint<BITS>::operator*=(uint32_t b32)
{
uint64_t carry = 0;
@@ -70,7 +70,7 @@ base_uint<BITS>& base_uint<BITS>::operator*=(uint32_t b32)
return *this;
}
-template<unsigned int BITS>
+template <unsigned int BITS>
base_uint<BITS>& base_uint<BITS>::operator*=(const base_uint& b)
{
base_uint<BITS> a = *this;
@@ -86,12 +86,12 @@ base_uint<BITS>& base_uint<BITS>::operator*=(const base_uint& b)
return *this;
}
-template<unsigned int BITS>
+template <unsigned int BITS>
base_uint<BITS>& base_uint<BITS>::operator/=(const base_uint& b)
{
- base_uint<BITS> div = b; // make a copy, so we can shift.
+ base_uint<BITS> div = b; // make a copy, so we can shift.
base_uint<BITS> num = *this; // make a copy, so we can subtract.
- *this = 0; // the quotient.
+ *this = 0; // the quotient.
int num_bits = num.bits();
int div_bits = div.bits();
if (div_bits == 0)
@@ -112,9 +112,10 @@ base_uint<BITS>& base_uint<BITS>::operator/=(const base_uint& b)
return *this;
}
-template<unsigned int BITS>
-int base_uint<BITS>::CompareTo(const base_uint<BITS>& b) const {
- for (int i = WIDTH-1; i >= 0; i--) {
+template <unsigned int BITS>
+int base_uint<BITS>::CompareTo(const base_uint<BITS>& b) const
+{
+ for (int i = WIDTH - 1; i >= 0; i--) {
if (pn[i] < b.pn[i])
return -1;
if (pn[i] > b.pn[i])
@@ -123,9 +124,10 @@ int base_uint<BITS>::CompareTo(const base_uint<BITS>& b) const {
return 0;
}
-template<unsigned int BITS>
-bool base_uint<BITS>::EqualTo(uint64_t b) const {
- for (int i = WIDTH-1; i >= 2; i--) {
+template <unsigned int BITS>
+bool base_uint<BITS>::EqualTo(uint64_t b) const
+{
+ for (int i = WIDTH - 1; i >= 2; i--) {
if (pn[i])
return false;
}
@@ -136,7 +138,7 @@ bool base_uint<BITS>::EqualTo(uint64_t b) const {
return true;
}
-template<unsigned int BITS>
+template <unsigned int BITS>
double base_uint<BITS>::getdouble() const
{
double ret = 0.0;
@@ -148,19 +150,19 @@ double base_uint<BITS>::getdouble() const
return ret;
}
-template<unsigned int BITS>
+template <unsigned int BITS>
std::string base_uint<BITS>::GetHex() const
{
- char psz[sizeof(pn)*2 + 1];
+ char psz[sizeof(pn) * 2 + 1];
for (unsigned int i = 0; i < sizeof(pn); i++)
- sprintf(psz + i*2, "%02x", ((unsigned char*)pn)[sizeof(pn) - i - 1]);
- return std::string(psz, psz + sizeof(pn)*2);
+ sprintf(psz + i * 2, "%02x", ((unsigned char*)pn)[sizeof(pn) - i - 1]);
+ return std::string(psz, psz + sizeof(pn) * 2);
}
-template<unsigned int BITS>
+template <unsigned int BITS>
void base_uint<BITS>::SetHex(const char* psz)
{
- memset(pn,0,sizeof(pn));
+ memset(pn, 0, sizeof(pn));
// skip leading spaces
while (isspace(*psz))
@@ -186,28 +188,28 @@ void base_uint<BITS>::SetHex(const char* psz)
}
}
-template<unsigned int BITS>
+template <unsigned int BITS>
void base_uint<BITS>::SetHex(const std::string& str)
{
SetHex(str.c_str());
}
-template<unsigned int BITS>
+template <unsigned int BITS>
std::string base_uint<BITS>::ToString() const
{
return (GetHex());
}
-template<unsigned int BITS>
+template <unsigned int BITS>
unsigned int base_uint<BITS>::bits() const
{
- for (int pos = WIDTH-1; pos >= 0; pos--) {
+ for (int pos = WIDTH - 1; pos >= 0; pos--) {
if (pn[pos]) {
for (int bits = 31; bits > 0; bits--) {
- if (pn[pos] & 1<<bits)
- return 32*pos + bits + 1;
+ if (pn[pos] & 1 << bits)
+ return 32 * pos + bits + 1;
}
- return 32*pos + 1;
+ return 32 * pos + 1;
}
}
return 0;
@@ -249,16 +251,16 @@ template unsigned int base_uint<256>::bits() const;
// This implementation directly uses shifts instead of going
// through an intermediate MPI representation.
-uint256& uint256::SetCompact(uint32_t nCompact, bool *pfNegative, bool *pfOverflow)
+uint256& uint256::SetCompact(uint32_t nCompact, bool* pfNegative, bool* pfOverflow)
{
int nSize = nCompact >> 24;
uint32_t nWord = nCompact & 0x007fffff;
if (nSize <= 3) {
- nWord >>= 8*(3-nSize);
+ nWord >>= 8 * (3 - nSize);
*this = nWord;
} else {
*this = nWord;
- *this <<= 8*(nSize-3);
+ *this <<= 8 * (nSize - 3);
}
if (pfNegative)
*pfNegative = nWord != 0 && (nCompact & 0x00800000) != 0;
@@ -274,9 +276,9 @@ uint32_t uint256::GetCompact(bool fNegative) const
int nSize = (bits() + 7) / 8;
uint32_t nCompact = 0;
if (nSize <= 3) {
- nCompact = GetLow64() << 8*(3-nSize);
+ nCompact = GetLow64() << 8 * (3 - nSize);
} else {
- uint256 bn = *this >> 8*(nSize-3);
+ uint256 bn = *this >> 8 * (nSize - 3);
nCompact = bn.GetLow64();
}
// The 0x00800000 bit denotes the sign.
@@ -295,27 +297,46 @@ uint32_t uint256::GetCompact(bool fNegative) const
static void inline HashMix(uint32_t& a, uint32_t& b, uint32_t& c)
{
// Taken from lookup3, by Bob Jenkins.
- a -= c; a ^= ((c << 4) | (c >> 28)); c += b;
- b -= a; b ^= ((a << 6) | (a >> 26)); a += c;
- c -= b; c ^= ((b << 8) | (b >> 24)); b += a;
- a -= c; a ^= ((c << 16) | (c >> 16)); c += b;
- b -= a; b ^= ((a << 19) | (a >> 13)); a += c;
- c -= b; c ^= ((b << 4) | (b >> 28)); b += a;
+ a -= c;
+ a ^= ((c << 4) | (c >> 28));
+ c += b;
+ b -= a;
+ b ^= ((a << 6) | (a >> 26));
+ a += c;
+ c -= b;
+ c ^= ((b << 8) | (b >> 24));
+ b += a;
+ a -= c;
+ a ^= ((c << 16) | (c >> 16));
+ c += b;
+ b -= a;
+ b ^= ((a << 19) | (a >> 13));
+ a += c;
+ c -= b;
+ c ^= ((b << 4) | (b >> 28));
+ b += a;
}
static void inline HashFinal(uint32_t& a, uint32_t& b, uint32_t& c)
{
// Taken from lookup3, by Bob Jenkins.
- c ^= b; c -= ((b << 14) | (b >> 18));
- a ^= c; a -= ((c << 11) | (c >> 21));
- b ^= a; b -= ((a << 25) | (a >> 7));
- c ^= b; c -= ((b << 16) | (b >> 16));
- a ^= c; a -= ((c << 4) | (c >> 28));
- b ^= a; b -= ((a << 14) | (a >> 18));
- c ^= b; c -= ((b << 24) | (b >> 8));
+ c ^= b;
+ c -= ((b << 14) | (b >> 18));
+ a ^= c;
+ a -= ((c << 11) | (c >> 21));
+ b ^= a;
+ b -= ((a << 25) | (a >> 7));
+ c ^= b;
+ c -= ((b << 16) | (b >> 16));
+ a ^= c;
+ a -= ((c << 4) | (c >> 28));
+ b ^= a;
+ b -= ((a << 14) | (a >> 18));
+ c ^= b;
+ c -= ((b << 24) | (b >> 8));
}
-uint64_t uint256::GetHash(const uint256 &salt) const
+uint64_t uint256::GetHash(const uint256& salt) const
{
uint32_t a, b, c;
a = b = c = 0xdeadbeef + (WIDTH << 2);
diff --git a/src/uint256.h b/src/uint256.h
index 6bb9a59400..28de540226 100644
--- a/src/uint256.h
+++ b/src/uint256.h
@@ -7,10 +7,10 @@
#define BITCOIN_UINT256_H
#include <assert.h>
+#include <cstring>
#include <stdexcept>
#include <stdint.h>
#include <string>
-#include <cstring>
#include <vector>
class uint_error : public std::runtime_error {
diff --git a/src/util.cpp b/src/util.cpp
index 5a4e187f9e..632d0965bf 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -211,6 +211,7 @@ int LogPrintStr(const std::string &str)
{
// print to console
ret = fwrite(str.data(), 1, str.size(), stdout);
+ fflush(stdout);
}
else if (fPrintToDebugLog && AreBaseParamsConfigured())
{
@@ -471,6 +472,7 @@ void ReadConfigFile(map<string, string>& mapSettingsRet,
ClearDatadirCache();
}
+#ifndef WIN32
boost::filesystem::path GetPidFile()
{
boost::filesystem::path pathPidFile(GetArg("-pid", "bitcoind.pid"));
@@ -478,7 +480,6 @@ boost::filesystem::path GetPidFile()
return pathPidFile;
}
-#ifndef WIN32
void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
{
FILE* file = fopen(path.string().c_str(), "w");
@@ -494,7 +495,7 @@ bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
{
#ifdef WIN32
return MoveFileExA(src.string().c_str(), dest.string().c_str(),
- MOVEFILE_REPLACE_EXISTING);
+ MOVEFILE_REPLACE_EXISTING) != 0;
#else
int rc = std::rename(src.string().c_str(), dest.string().c_str());
return (rc == 0);
@@ -617,7 +618,7 @@ void ShrinkDebugFile()
{
// Restart the file with some of the end
std::vector <char> vch(200000,0);
- fseek(file, -vch.size(), SEEK_END);
+ fseek(file, -((long)vch.size()), SEEK_END);
int nBytes = fread(begin_ptr(vch), 1, vch.size(), file);
fclose(file);
diff --git a/src/util.h b/src/util.h
index 6e1f439ff7..4b2415278b 100644
--- a/src/util.h
+++ b/src/util.h
@@ -15,8 +15,8 @@
#endif
#include "compat.h"
-#include "utiltime.h"
#include "tinyformat.h"
+#include "utiltime.h"
#include <exception>
#include <map>
@@ -93,8 +93,8 @@ bool TryCreateDirectory(const boost::filesystem::path& p);
boost::filesystem::path GetDefaultDataDir();
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
boost::filesystem::path GetConfigFile();
-boost::filesystem::path GetPidFile();
#ifndef WIN32
+boost::filesystem::path GetPidFile();
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
#endif
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp
index ef13555104..b9e64c5fe1 100644
--- a/src/utilstrencodings.cpp
+++ b/src/utilstrencodings.cpp
@@ -7,15 +7,16 @@
#include "tinyformat.h"
-#include <boost/foreach.hpp>
#include <errno.h>
#include <limits>
+#include <boost/foreach.hpp>
+
using namespace std;
// safeChars chosen to allow simple messages/URLs/email addresses, but avoid anything
// even possibly remotely dangerous like & or >
-static string safeChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890 .,;_/:?@");
+static string safeChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890 .,;_/:?@()");
string SanitizeString(const string& str)
{
string strResult;
@@ -223,7 +224,7 @@ vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
string DecodeBase64(const string& str)
{
vector<unsigned char> vchRet = DecodeBase64(str.c_str());
- return string((const char*)&vchRet[0], vchRet.size());
+ return (vchRet.size() == 0) ? string() : string((const char*)&vchRet[0], vchRet.size());
}
string EncodeBase32(const unsigned char* pch, size_t len)
@@ -410,7 +411,7 @@ vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
string DecodeBase32(const string& str)
{
vector<unsigned char> vchRet = DecodeBase32(str.c_str());
- return string((const char*)&vchRet[0], vchRet.size());
+ return (vchRet.size() == 0) ? string() : string((const char*)&vchRet[0], vchRet.size());
}
bool ParseInt32(const std::string& str, int32_t *out)
diff --git a/src/version.cpp b/src/version.cpp
index 8311041ed2..95632fdab7 100644
--- a/src/version.cpp
+++ b/src/version.cpp
@@ -7,6 +7,7 @@
#include "tinyformat.h"
#include <string>
+
#include <boost/algorithm/string/join.hpp>
// Name of client reported in the 'version' message. Report the same name
@@ -15,7 +16,7 @@
const std::string CLIENT_NAME("Satoshi");
// Client version number
-#define CLIENT_VERSION_SUFFIX ""
+#define CLIENT_VERSION_SUFFIX ""
// The following part of the code determines the CLIENT_BUILD variable.
@@ -34,40 +35,40 @@ const std::string CLIENT_NAME("Satoshi");
// First, include build.h if requested
#ifdef HAVE_BUILD_INFO
-# include "build.h"
+#include "build.h"
#endif
// git will put "#define GIT_ARCHIVE 1" on the next line inside archives. $Format:%n#define GIT_ARCHIVE 1$
#ifdef GIT_ARCHIVE
-# define GIT_COMMIT_ID "$Format:%h$"
-# define GIT_COMMIT_DATE "$Format:%cD$"
+#define GIT_COMMIT_ID "$Format:%h$"
+#define GIT_COMMIT_DATE "$Format:%cD$"
#endif
-#define BUILD_DESC_WITH_SUFFIX(maj,min,rev,build,suffix) \
+#define BUILD_DESC_WITH_SUFFIX(maj, min, rev, build, suffix) \
"v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-" DO_STRINGIZE(suffix)
-#define BUILD_DESC_FROM_COMMIT(maj,min,rev,build,commit) \
+#define BUILD_DESC_FROM_COMMIT(maj, min, rev, build, commit) \
"v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-g" commit
-#define BUILD_DESC_FROM_UNKNOWN(maj,min,rev,build) \
+#define BUILD_DESC_FROM_UNKNOWN(maj, min, rev, build) \
"v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-unk"
#ifndef BUILD_DESC
-# ifdef BUILD_SUFFIX
-# define BUILD_DESC BUILD_DESC_WITH_SUFFIX(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, BUILD_SUFFIX)
-# elif defined(GIT_COMMIT_ID)
-# define BUILD_DESC BUILD_DESC_FROM_COMMIT(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, GIT_COMMIT_ID)
-# else
-# define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD)
-# endif
+#ifdef BUILD_SUFFIX
+#define BUILD_DESC BUILD_DESC_WITH_SUFFIX(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, BUILD_SUFFIX)
+#elif defined(GIT_COMMIT_ID)
+#define BUILD_DESC BUILD_DESC_FROM_COMMIT(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, GIT_COMMIT_ID)
+#else
+#define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD)
+#endif
#endif
#ifndef BUILD_DATE
-# ifdef GIT_COMMIT_DATE
-# define BUILD_DATE GIT_COMMIT_DATE
-# else
-# define BUILD_DATE __DATE__ ", " __TIME__
-# endif
+#ifdef GIT_COMMIT_DATE
+#define BUILD_DATE GIT_COMMIT_DATE
+#else
+#define BUILD_DATE __DATE__ ", " __TIME__
+#endif
#endif
const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX);
@@ -75,10 +76,10 @@ const std::string CLIENT_DATE(BUILD_DATE);
static std::string FormatVersion(int nVersion)
{
- if (nVersion%100 == 0)
- return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100);
+ if (nVersion % 100 == 0)
+ return strprintf("%d.%d.%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100);
else
- return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100);
+ return strprintf("%d.%d.%d.%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100, nVersion % 100);
}
std::string FormatFullVersion()
diff --git a/src/wallet.cpp b/src/wallet.cpp
index b69ed223b4..e69f59aacd 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -44,7 +44,7 @@ struct CompareValueOnly
std::string COutput::ToString() const
{
- return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue).c_str());
+ return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue));
}
const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const
@@ -639,14 +639,14 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
{
{
AssertLockHeld(cs_wallet);
- bool fExisted = mapWallet.count(tx.GetHash());
+ bool fExisted = mapWallet.count(tx.GetHash()) != 0;
if (fExisted && !fUpdate) return false;
if (fExisted || IsMine(tx) || IsFromMe(tx))
{
CWalletTx wtx(this,tx);
// Get merkle branch if transaction was found in a block
if (pblock)
- wtx.SetMerkleBranch(pblock);
+ wtx.SetMerkleBranch(*pblock);
return AddToWallet(wtx);
}
}
@@ -1131,7 +1131,7 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
!IsLockedCoin((*it).first, i) && pcoin->vout[i].nValue > 0 &&
(!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i)))
- vCoins.push_back(COutput(pcoin, i, nDepth, mine & ISMINE_SPENDABLE));
+ vCoins.push_back(COutput(pcoin, i, nDepth, (mine & ISMINE_SPENDABLE) != ISMINE_NO));
}
}
}
@@ -1385,7 +1385,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
// coin control: send change to custom address
if (coinControl && !boost::get<CNoDestination>(&coinControl->destChange))
- scriptChange.SetDestination(coinControl->destChange);
+ scriptChange = GetScriptForDestination(coinControl->destChange);
// no coin control: send change to newly generated address
else
@@ -1403,7 +1403,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
ret = reservekey.GetReservedKey(vchPubKey);
assert(ret); // should never fail, as we just unlocked
- scriptChange.SetDestination(vchPubKey.GetID());
+ scriptChange = GetScriptForDestination(vchPubKey.GetID());
}
CTxOut newTxOut(nChange, scriptChange);
@@ -1556,8 +1556,7 @@ string CWallet::SendMoney(const CTxDestination &address, int64_t nValue, CWallet
}
// Parse Bitcoin address
- CScript scriptPubKey;
- scriptPubKey.SetDestination(address);
+ CScript scriptPubKey = GetScriptForDestination(address);
// Create and send the transaction
CReserveKey reservekey(this);
@@ -1657,7 +1656,7 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const string& strNam
if (!strPurpose.empty()) /* update purpose only if requested */
mapAddressBook[address].purpose = strPurpose;
}
- NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address),
+ NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address) != ISMINE_NO,
strPurpose, (fUpdated ? CT_UPDATED : CT_NEW) );
if (!fFileBacked)
return false;
@@ -1683,7 +1682,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
mapAddressBook.erase(address);
}
- NotifyAddressBookChanged(this, address, "", ::IsMine(*this, address), "", CT_DELETED);
+ NotifyAddressBookChanged(this, address, "", ::IsMine(*this, address) != ISMINE_NO, "", CT_DELETED);
if (!fFileBacked)
return false;
@@ -2086,6 +2085,39 @@ void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts)
}
}
+
+class CAffectedKeysVisitor : public boost::static_visitor<void> {
+private:
+ const CKeyStore &keystore;
+ std::vector<CKeyID> &vKeys;
+
+public:
+ CAffectedKeysVisitor(const CKeyStore &keystoreIn, std::vector<CKeyID> &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {}
+
+ void Process(const CScript &script) {
+ txnouttype type;
+ std::vector<CTxDestination> vDest;
+ int nRequired;
+ if (ExtractDestinations(script, type, vDest, nRequired)) {
+ BOOST_FOREACH(const CTxDestination &dest, vDest)
+ boost::apply_visitor(*this, dest);
+ }
+ }
+
+ void operator()(const CKeyID &keyId) {
+ if (keystore.HaveKey(keyId))
+ vKeys.push_back(keyId);
+ }
+
+ void operator()(const CScriptID &scriptId) {
+ CScript script;
+ if (keystore.GetCScript(scriptId, script))
+ Process(script);
+ }
+
+ void operator()(const CNoDestination &none) {}
+};
+
void CWallet::GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const {
AssertLockHeld(cs_wallet); // mapKeyMetadata
mapKeyBirth.clear();
@@ -2121,7 +2153,7 @@ void CWallet::GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const {
int nHeight = blit->second->nHeight;
BOOST_FOREACH(const CTxOut &txout, wtx.vout) {
// iterate over all their outputs
- ::ExtractAffectedKeys(*this, txout.scriptPubKey, vAffected);
+ CAffectedKeysVisitor(*this, vAffected).Process(txout.scriptPubKey);
BOOST_FOREACH(const CKeyID &keyid, vAffected) {
// ... and all their affected keys
std::map<CKeyID, CBlockIndex*>::iterator rit = mapKeyFirstBlock.find(keyid);
@@ -2197,48 +2229,34 @@ CWalletKey::CWalletKey(int64_t nExpires)
nTimeExpires = nExpires;
}
-int CMerkleTx::SetMerkleBranch(const CBlock* pblock)
+int CMerkleTx::SetMerkleBranch(const CBlock& block)
{
AssertLockHeld(cs_main);
CBlock blockTmp;
- if (pblock == NULL) {
- CCoins coins;
- if (pcoinsTip->GetCoins(GetHash(), coins)) {
- CBlockIndex *pindex = chainActive[coins.nHeight];
- if (pindex) {
- if (!ReadBlockFromDisk(blockTmp, pindex))
- return 0;
- pblock = &blockTmp;
- }
- }
- }
-
- if (pblock) {
- // Update the tx's hashBlock
- hashBlock = pblock->GetHash();
-
- // Locate the transaction
- for (nIndex = 0; nIndex < (int)pblock->vtx.size(); nIndex++)
- if (pblock->vtx[nIndex] == *(CTransaction*)this)
- break;
- if (nIndex == (int)pblock->vtx.size())
- {
- vMerkleBranch.clear();
- nIndex = -1;
- LogPrintf("ERROR: SetMerkleBranch() : couldn't find tx in block\n");
- return 0;
- }
+ // Update the tx's hashBlock
+ hashBlock = block.GetHash();
- // Fill in merkle branch
- vMerkleBranch = pblock->GetMerkleBranch(nIndex);
+ // Locate the transaction
+ for (nIndex = 0; nIndex < (int)block.vtx.size(); nIndex++)
+ if (block.vtx[nIndex] == *(CTransaction*)this)
+ break;
+ if (nIndex == (int)block.vtx.size())
+ {
+ vMerkleBranch.clear();
+ nIndex = -1;
+ LogPrintf("ERROR: SetMerkleBranch() : couldn't find tx in block\n");
+ return 0;
}
+ // Fill in merkle branch
+ vMerkleBranch = block.GetMerkleBranch(nIndex);
+
// Is the tx in a block that's in the main chain
BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi == mapBlockIndex.end())
return 0;
- CBlockIndex* pindex = (*mi).second;
+ const CBlockIndex* pindex = (*mi).second;
if (!pindex || !chainActive.Contains(pindex))
return 0;
diff --git a/src/wallet.h b/src/wallet.h
index 6788986f88..fde87a8a2f 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -11,8 +11,8 @@
#include "key.h"
#include "keystore.h"
#include "main.h"
-#include "scriptutils.h"
#include "ui_interface.h"
+#include "wallet_ismine.h"
#include "walletdb.h"
#include <algorithm>
@@ -504,7 +504,7 @@ public:
READWRITE(nIndex);
}
- int SetMerkleBranch(const CBlock* pblock=NULL);
+ int SetMerkleBranch(const CBlock& block);
// Return depth of transaction in blockchain:
// -1 : not in blockchain, and not in memory pool (conflicted transaction)
diff --git a/src/scriptutils.cpp b/src/wallet_ismine.cpp
index a636eeedab..07149ebd0b 100644
--- a/src/scriptutils.cpp
+++ b/src/wallet_ismine.cpp
@@ -1,9 +1,9 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include "scriptutils.h"
+#include "wallet_ismine.h"
#include "key.h"
#include "keystore.h"
@@ -29,8 +29,7 @@ unsigned int HaveKeys(const vector<valtype>& pubkeys, const CKeyStore& keystore)
isminetype IsMine(const CKeyStore &keystore, const CTxDestination& dest)
{
- CScript script;
- script.SetDestination(dest);
+ CScript script = GetScriptForDestination(dest);
return IsMine(keystore, script);
}
@@ -89,39 +88,3 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey)
return ISMINE_WATCH_ONLY;
return ISMINE_NO;
}
-
-class CAffectedKeysVisitor : public boost::static_visitor<void> {
-private:
- const CKeyStore &keystore;
- std::vector<CKeyID> &vKeys;
-
-public:
- CAffectedKeysVisitor(const CKeyStore &keystoreIn, std::vector<CKeyID> &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {}
-
- void Process(const CScript &script) {
- txnouttype type;
- std::vector<CTxDestination> vDest;
- int nRequired;
- if (ExtractDestinations(script, type, vDest, nRequired)) {
- BOOST_FOREACH(const CTxDestination &dest, vDest)
- boost::apply_visitor(*this, dest);
- }
- }
-
- void operator()(const CKeyID &keyId) {
- if (keystore.HaveKey(keyId))
- vKeys.push_back(keyId);
- }
-
- void operator()(const CScriptID &scriptId) {
- CScript script;
- if (keystore.GetCScript(scriptId, script))
- Process(script);
- }
-
- void operator()(const CNoDestination &none) {}
-};
-
-void ExtractAffectedKeys(const CKeyStore &keystore, const CScript& scriptPubKey, std::vector<CKeyID> &vKeys) {
- CAffectedKeysVisitor(keystore, vKeys).Process(scriptPubKey);
-}
diff --git a/src/scriptutils.h b/src/wallet_ismine.h
index 98080fc456..f326b86815 100644
--- a/src/scriptutils.h
+++ b/src/wallet_ismine.h
@@ -1,15 +1,16 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef H_BITCOIN_SCRIPTUTILS
-#define H_BITCOIN_SCRIPTUTILS
+#ifndef H_BITCOIN_WALLET_ISMINE
+#define H_BITCOIN_WALLET_ISMINE
#include "key.h"
-#include "script/script.h"
+#include "script/standard.h"
class CKeyStore;
+class CScript;
/** IsMine() return codes */
enum isminetype
@@ -24,6 +25,5 @@ typedef uint8_t isminefilter;
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey);
isminetype IsMine(const CKeyStore& keystore, const CTxDestination& dest);
-void ExtractAffectedKeys(const CKeyStore &keystore, const CScript& scriptPubKey, std::vector<CKeyID> &vKeys);
-#endif // H_BITCOIN_SCRIPT
+#endif // H_BITCOIN_WALLET_ISMINE
diff --git a/src/walletdb.cpp b/src/walletdb.cpp
index 48045b98c8..a84f44db01 100644
--- a/src/walletdb.cpp
+++ b/src/walletdb.cpp
@@ -9,8 +9,8 @@
#include "protocol.h"
#include "serialize.h"
#include "sync.h"
-#include "utiltime.h"
#include "util.h"
+#include "utiltime.h"
#include "wallet.h"
#include <boost/filesystem.hpp>
@@ -242,9 +242,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
pcursor->close();
}
-
-DBErrors
-CWalletDB::ReorderTransactions(CWallet* pwallet)
+DBErrors CWalletDB::ReorderTransactions(CWallet* pwallet)
{
LOCK(pwallet->cs_wallet);
// Old wallets didn't have any defined order for transactions
diff --git a/src/walletdb.h b/src/walletdb.h
index ce63bb0b97..2c5b608f3d 100644
--- a/src/walletdb.h
+++ b/src/walletdb.h
@@ -75,13 +75,10 @@ public:
class CWalletDB : public CDB
{
public:
- CWalletDB(std::string strFilename, const char* pszMode="r+") : CDB(strFilename.c_str(), pszMode)
+ CWalletDB(const std::string& strFilename, const char* pszMode = "r+") : CDB(strFilename, pszMode)
{
}
-private:
- CWalletDB(const CWalletDB&);
- void operator=(const CWalletDB&);
-public:
+
bool WriteName(const std::string& strAddress, const std::string& strName);
bool EraseName(const std::string& strAddress);
@@ -119,19 +116,23 @@ public:
bool WriteDestData(const std::string &address, const std::string &key, const std::string &value);
/// Erase destination data tuple from wallet database
bool EraseDestData(const std::string &address, const std::string &key);
-private:
- bool WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry);
-public:
+
bool WriteAccountingEntry(const CAccountingEntry& acentry);
int64_t GetAccountCreditDebit(const std::string& strAccount);
void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries);
- DBErrors ReorderTransactions(CWallet*);
+ DBErrors ReorderTransactions(CWallet* pwallet);
DBErrors LoadWallet(CWallet* pwallet);
DBErrors FindWalletTx(CWallet* pwallet, std::vector<uint256>& vTxHash, std::vector<CWalletTx>& vWtx);
DBErrors ZapWalletTx(CWallet* pwallet, std::vector<CWalletTx>& vWtx);
static bool Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys);
static bool Recover(CDBEnv& dbenv, std::string filename);
+
+private:
+ CWalletDB(const CWalletDB&);
+ void operator=(const CWalletDB&);
+
+ bool WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry);
};
bool BackupWallet(const CWallet& wallet, const std::string& strDest);