aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore23
-rw-r--r--.travis.yml6
-rw-r--r--Makefile.am2
-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)0
-rw-r--r--build-aux/m4/bitcoin_qt.m4 (renamed from src/m4/bitcoin_qt.m4)0
-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.ac52
-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
-rw-r--r--depends/config.site.in2
-rw-r--r--doc/README.md2
-rw-r--r--doc/init.md92
-rw-r--r--doc/systemd.md47
-rw-r--r--src/Makefile.am10
-rw-r--r--src/Makefile.test.include3
-rw-r--r--src/allocators.cpp4
-rw-r--r--src/allocators.h1
-rw-r--r--src/base58.h1
-rw-r--r--src/bitcoin-cli.cpp4
-rw-r--r--src/bitcoin-tx.cpp21
-rw-r--r--src/chainparamsbase.h2
-rw-r--r--src/coins.h4
-rw-r--r--src/core.cpp12
-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/ripemd160.cpp1
-rw-r--r--src/crypto/sha1.cpp1
-rw-r--r--src/crypto/sha2.cpp1
-rw-r--r--src/db.cpp3
-rw-r--r--src/db.h6
-rw-r--r--src/hash.h2
-rw-r--r--src/init.cpp10
-rw-r--r--src/key.cpp8
-rw-r--r--src/leveldbwrapper.h3
-rw-r--r--src/main.cpp55
-rw-r--r--src/main.h2
-rw-r--r--src/net.cpp8
-rw-r--r--src/netbase.cpp88
-rw-r--r--src/pow.h2
-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/guiutil.cpp4
-rw-r--r--src/qt/paymentserver.cpp4
-rw-r--r--src/qt/walletmodel.cpp3
-rw-r--r--src/random.cpp4
-rw-r--r--src/rpcclient.cpp4
-rw-r--r--src/rpcdump.cpp7
-rw-r--r--src/rpcmining.cpp6
-rw-r--r--src/rpcmisc.cpp3
-rw-r--r--src/rpcnet.cpp5
-rw-r--r--src/rpcprotocol.cpp2
-rw-r--r--src/rpcrawtransaction.cpp9
-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.cpp4
-rw-r--r--src/script/interpreter.h8
-rw-r--r--src/script/script.cpp44
-rw-r--r--src/script/script.h23
-rw-r--r--src/script/sign.cpp4
-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.h2
-rw-r--r--src/sync.cpp3
-rw-r--r--src/test/DoS_tests.cpp6
-rw-r--r--src/test/data/bitcoin-util-test.json3
-rw-r--r--src/test/data/txcreate2.hex1
-rw-r--r--src/test/miner_tests.cpp2
-rw-r--r--src/test/script_P2SH_tests.cpp45
-rw-r--r--src/test/script_tests.cpp6
-rw-r--r--src/test/sigopcount_tests.cpp9
-rw-r--r--src/test/transaction_tests.cpp6
-rw-r--r--src/timedata.h4
-rw-r--r--src/txdb.cpp3
-rw-r--r--src/txmempool.cpp14
-rw-r--r--src/txmempool.h1
-rw-r--r--src/uint256.h2
-rw-r--r--src/util.cpp2
-rw-r--r--src/util.h2
-rw-r--r--src/utilstrencodings.cpp3
-rw-r--r--src/version.cpp1
-rw-r--r--src/wallet.cpp15
-rw-r--r--src/wallet.h2
-rw-r--r--src/wallet_ismine.cpp7
-rw-r--r--src/wallet_ismine.h9
-rw-r--r--src/walletdb.cpp2
112 files changed, 966 insertions, 573 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/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..5223163fe5 100644
--- a/src/m4/bitcoin_find_bdb48.m4
+++ b/build-aux/m4/bitcoin_find_bdb48.m4
diff --git a/src/m4/bitcoin_qt.m4 b/build-aux/m4/bitcoin_qt.m4
index e141033b19..e141033b19 100644
--- a/src/m4/bitcoin_qt.m4
+++ b/build-aux/m4/bitcoin_qt.m4
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..7d525f8251 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,8 +7,8 @@ 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_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 +44,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],
@@ -120,30 +144,6 @@ AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[spec
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],
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/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/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/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/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/src/Makefile.am b/src/Makefile.am
index b2071f49e2..94a582dfac 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -98,12 +98,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 \
- wallet_ismine.h \
serialize.h \
sync.h \
threadsafety.h \
@@ -118,8 +117,9 @@ BITCOIN_CORE_H = \
utilmoneystr.h \
utiltime.h \
version.h \
- walletdb.h \
wallet.h \
+ wallet_ismine.h \
+ walletdb.h \
compat/sanity.h
JSON_H = \
@@ -173,8 +173,8 @@ libbitcoin_wallet_a_SOURCES = \
crypter.cpp \
rpcdump.cpp \
rpcwallet.cpp \
- wallet_ismine.cpp \
wallet.cpp \
+ wallet_ismine.cpp \
walletdb.cpp \
$(BITCOIN_CORE_H)
@@ -212,8 +212,8 @@ 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 \
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/allocators.cpp b/src/allocators.cpp
index 15f34aa2c8..8ecd7206cd 100644
--- a/src/allocators.cpp
+++ b/src/allocators.cpp
@@ -46,7 +46,7 @@ static inline size_t GetSystemPageSize()
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
@@ -55,7 +55,7 @@ bool MemoryPageLocker::Lock(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
diff --git a/src/allocators.h b/src/allocators.h
index 0b1c9fea68..65a7d08987 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()
/**
diff --git a/src/base58.h b/src/base58.h
index 15bf710f5e..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>
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 1e27d400c8..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
diff --git a/src/chainparamsbase.h b/src/chainparamsbase.h
index 2d3a07b44a..743c8c541a 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)
diff --git a/src/coins.h b/src/coins.h
index c25393f1e0..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) {
diff --git a/src/core.cpp b/src/core.cpp
index 8dcda0126a..491e4fa68b 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
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/ripemd160.cpp b/src/crypto/ripemd160.cpp
index 24bd318d43..b5e9f0df49 100644
--- a/src/crypto/ripemd160.cpp
+++ b/src/crypto/ripemd160.cpp
@@ -5,6 +5,7 @@
#include "crypto/ripemd160.h"
#include "crypto/common.h"
+
#include <string.h>
// Internal implementation code.
diff --git a/src/crypto/sha1.cpp b/src/crypto/sha1.cpp
index 304401a50f..819abab579 100644
--- a/src/crypto/sha1.cpp
+++ b/src/crypto/sha1.cpp
@@ -5,6 +5,7 @@
#include "crypto/sha1.h"
#include "crypto/common.h"
+
#include <string.h>
// Internal implementation code.
diff --git a/src/crypto/sha2.cpp b/src/crypto/sha2.cpp
index 99a251cb12..72f191afcd 100644
--- a/src/crypto/sha2.cpp
+++ b/src/crypto/sha2.cpp
@@ -5,6 +5,7 @@
#include "crypto/sha2.h"
#include "crypto/common.h"
+
#include <string.h>
// Internal implementation code.
diff --git a/src/db.cpp b/src/db.cpp
index 23d2cc988d..edbff6fd49 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;
@@ -231,7 +232,7 @@ CDB::CDB(const char *pszFile, const char* pszMode) :
if (pszFile == NULL)
return;
- bool fCreate = strchr(pszMode, 'c');
+ bool fCreate = strchr(pszMode, 'c') != NULL;
unsigned int nFlags = DB_THREAD;
if (fCreate)
nFlags |= DB_CREATE;
diff --git a/src/db.h b/src/db.h
index bba267b84f..999750ff3f 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);
@@ -129,7 +131,7 @@ protected:
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;
}
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 6e47536d38..67f53e044c 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>
@@ -198,7 +198,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;
@@ -402,9 +402,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++;
@@ -692,7 +694,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
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/leveldbwrapper.h b/src/leveldbwrapper.h
index 452df92839..29bc71f99d 100644
--- a/src/leveldbwrapper.h
+++ b/src/leveldbwrapper.h
@@ -10,6 +10,7 @@
#include "version.h"
#include <boost/filesystem/path.hpp>
+
#include <leveldb/db.h>
#include <leveldb/write_batch.h>
@@ -99,7 +100,7 @@ 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;
diff --git a/src/main.cpp b/src/main.cpp
index 134e87fc99..6c1c7166a8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1797,11 +1797,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);
@@ -1814,7 +1809,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();
@@ -1931,6 +1926,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);
@@ -2790,7 +2790,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)
@@ -2817,6 +2817,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)
@@ -3158,7 +3163,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;
}
@@ -3781,15 +3786,16 @@ 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(),
@@ -3823,7 +3829,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
{
LogPrint("mempool", " accepted orphan tx %s\n", orphanHash.ToString());
RelayTransaction(orphanTx);
- mapAlreadyAskedFor.erase(CInv(MSG_TX, orphanHash));
vWorkQueue.push_back(orphanHash);
}
else if (!fMissingInputs2)
@@ -4101,21 +4106,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()));
}
}
diff --git a/src/main.h b/src/main.h
index 2ec1691471..5acc551793 100644
--- a/src/main.h
+++ b/src/main.h
@@ -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 */
diff --git a/src/net.cpp b/src/net.cpp
index b18944a264..ab547e2fd7 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;
}
diff --git a/src/netbase.cpp b/src/netbase.cpp
index 954c11f77d..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");
@@ -266,7 +326,7 @@ bool static Socks5(string strDest, int port, SOCKET& 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/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/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/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/paymentserver.cpp b/src/qt/paymentserver.cpp
index 219a685faf..cc4478f39f 100644
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -609,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());
}
@@ -620,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/walletmodel.cpp b/src/qt/walletmodel.cpp
index 8d2c2e96d8..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;
diff --git a/src/random.cpp b/src/random.cpp
index 22c942acc0..fb5258a442 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -12,10 +12,12 @@
#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>
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/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 917c840536..dd45eefd58 100644
--- a/src/rpcmisc.cpp
+++ b/src/rpcmisc.cpp
@@ -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..52f98fbf00 100644
--- a/src/rpcnet.cpp
+++ b/src/rpcnet.cpp
@@ -13,6 +13,7 @@
#include "util.h"
#include <boost/foreach.hpp>
+
#include "json/json_spirit_value.h"
using namespace json_spirit;
@@ -94,8 +95,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 (booleamn) if sync node\n"
" }\n"
" ,...\n"
"]\n"
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 5730f72a85..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");
}
}
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 c745564599..fd3e4f1ff7 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"
diff --git a/src/script/interpreter.h b/src/script/interpreter.h
index 0c00eefe7d..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
@@ -42,4 +42,4 @@ bool CheckSig(std::vector<unsigned char> vchSig, const std::vector<unsigned char
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..07a4229f85 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
@@ -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>
{
@@ -604,9 +590,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 +625,4 @@ public:
}
};
-#endif
+#endif // H_BITCOIN_SCRIPT
diff --git a/src/script/sign.cpp b/src/script/sign.cpp
index cbddc1b72a..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"
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..57f5fd069b 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>
diff --git a/src/sync.cpp b/src/sync.cpp
index 066c1ca744..d424f7bc95 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)
diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp
index e019674816..af01e5518c 100644
--- a/src/test/DoS_tests.cpp
+++ b/src/test/DoS_tests.cpp
@@ -173,7 +173,7 @@ 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, i);
}
@@ -189,7 +189,7 @@ 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, i);
@@ -203,7 +203,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++)
{
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/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/script_P2SH_tests.cpp b/src/test/script_P2SH_tests.cpp
index d866380229..e6cf00c2d0 100644
--- a/src/test/script_P2SH_tests.cpp
+++ b/src/test/script_P2SH_tests.cpp
@@ -68,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:
@@ -129,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);
@@ -140,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);
@@ -163,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]);
}
@@ -244,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):
@@ -274,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;
@@ -293,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:
@@ -302,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;
@@ -320,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++)
@@ -352,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;
@@ -364,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 fc4cf05ebd..cb543a0cf1 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -280,7 +280,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);
@@ -309,7 +309,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);
@@ -327,7 +327,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 42f400ef41..41d8ee9f19 100644
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -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/timedata.h b/src/timedata.h
index 9cc47bec13..155f6872da 100644
--- a/src/timedata.h
+++ b/src/timedata.h
@@ -5,10 +5,10 @@
#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;
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 6bbadc8345..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;
}
@@ -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;
}
@@ -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.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 20aff49c86..0ac0f70a79 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -495,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);
diff --git a/src/util.h b/src/util.h
index 6e1f439ff7..e72c99adc7 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>
diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp
index ef13555104..6837e4e267 100644
--- a/src/utilstrencodings.cpp
+++ b/src/utilstrencodings.cpp
@@ -7,10 +7,11 @@
#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
diff --git a/src/version.cpp b/src/version.cpp
index 8311041ed2..e441cc463f 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
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 52660be9a0..6bfaec3681 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -639,7 +639,7 @@ 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))
{
@@ -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;
diff --git a/src/wallet.h b/src/wallet.h
index 5c26186730..3461446b8b 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -11,8 +11,8 @@
#include "key.h"
#include "keystore.h"
#include "main.h"
-#include "wallet_ismine.h"
#include "ui_interface.h"
+#include "wallet_ismine.h"
#include "walletdb.h"
#include <algorithm>
diff --git a/src/wallet_ismine.cpp b/src/wallet_ismine.cpp
index 1c2c117fad..07149ebd0b 100644
--- a/src/wallet_ismine.cpp
+++ b/src/wallet_ismine.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 "wallet_ismine.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);
}
diff --git a/src/wallet_ismine.h b/src/wallet_ismine.h
index 9915e9f7bb..f326b86815 100644
--- a/src/wallet_ismine.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_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
@@ -25,4 +26,4 @@ typedef uint8_t isminefilter;
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey);
isminetype IsMine(const CKeyStore& keystore, const CTxDestination& dest);
-#endif // H_BITCOIN_SCRIPT
+#endif // H_BITCOIN_WALLET_ISMINE
diff --git a/src/walletdb.cpp b/src/walletdb.cpp
index 48045b98c8..03161250db 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>