aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-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--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/bitcoin-cli.cpp4
-rw-r--r--src/bitcoin-tx.cpp16
-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.cpp27
-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/random.cpp4
-rw-r--r--src/rpcclient.cpp2
-rw-r--r--src/rpcdump.cpp3
-rw-r--r--src/rpcmining.cpp6
-rw-r--r--src/rpcnet.cpp1
-rw-r--r--src/rpcprotocol.cpp2
-rw-r--r--src/rpcrawtransaction.cpp6
-rw-r--r--src/rpcserver.cpp2
-rw-r--r--src/rpcwallet.cpp2
-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.cpp4
-rw-r--r--src/script/script.h6
-rw-r--r--src/script/sign.cpp4
-rw-r--r--src/script/sign.h7
-rw-r--r--src/script/standard.cpp4
-rw-r--r--src/script/standard.h6
-rw-r--r--src/serialize.h2
-rw-r--r--src/sync.cpp3
-rw-r--r--src/test/data/bitcoin-util-test.json3
-rw-r--r--src/test/data/txcreate2.hex1
-rw-r--r--src/timedata.h4
-rw-r--r--src/txdb.cpp3
-rw-r--r--src/txmempool.cpp12
-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.cpp8
-rw-r--r--src/wallet.h2
-rw-r--r--src/wallet_ismine.cpp4
-rw-r--r--src/wallet_ismine.h6
-rw-r--r--src/walletdb.cpp2
83 files changed, 777 insertions, 396 deletions
diff --git a/.travis.yml b/.travis.yml
index 379a0e1df7..7580adf5c4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,7 +25,7 @@ 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"
- compiler: "true 3"
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/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/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 91525b51c9..354d6ba41d 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;
@@ -237,8 +238,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 f978254961..3c19407b95 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1802,11 +1802,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);
@@ -1819,7 +1814,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();
@@ -1936,6 +1931,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);
@@ -2795,7 +2795,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)
@@ -2822,6 +2822,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)
@@ -3163,7 +3168,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;
}
@@ -3786,15 +3791,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(),
@@ -3828,7 +3834,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)
diff --git a/src/main.h b/src/main.h
index d340fd0b6a..f83db59849 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/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..81797248b4 100644
--- a/src/rpcclient.cpp
+++ b/src/rpcclient.cpp
@@ -3,7 +3,6 @@
// 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"
@@ -11,6 +10,7 @@
#include "ui_interface.h"
#include "chainparams.h" // for Params().RPCPort()
+#include <set>
#include <stdint.h>
using namespace std;
diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp
index c286626fd3..dc73161bf1 100644
--- a/src/rpcdump.cpp
+++ b/src/rpcdump.cpp
@@ -7,8 +7,8 @@
#include "init.h"
#include "main.h"
#include "sync.h"
-#include "utiltime.h"
#include "util.h"
+#include "utiltime.h"
#include "wallet.h"
#include <fstream>
@@ -16,6 +16,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;
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/rpcnet.cpp b/src/rpcnet.cpp
index 2baa481c4e..4afbe442ee 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;
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 c5c99870fc..1828a5dc7d 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)
{
@@ -543,7 +543,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..997b861e59 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -1536,7 +1536,7 @@ Value gettransaction(const Array& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id");
const CWalletTx& wtx = pwalletMain->mapWallet[hash];
- int64_t nCredit = wtx.GetCredit(filter);
+ int64_t nCredit = wtx.GetCredit(filter != 0);
int64_t nDebit = wtx.GetDebit(filter);
int64_t nNet = nCredit - nDebit;
int64_t nFee = (wtx.IsFromMe(filter) ? wtx.GetValueOut() - nDebit : 0);
diff --git a/src/script/compressor.cpp b/src/script/compressor.cpp
index 2f8df602bf..51a3cf6025 100644
--- a/src/script/compressor.cpp
+++ b/src/script/compressor.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "compressor.h"
diff --git a/src/script/compressor.h b/src/script/compressor.h
index f0a3754f02..53c6bf3ecc 100644
--- a/src/script/compressor.h
+++ b/src/script/compressor.h
@@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef H_BITCOIN_SCRIPT_COMPRESSOR
@@ -81,4 +81,4 @@ public:
}
};
-#endif
+#endif // H_BITCOIN_SCRIPT_COMPRESSOR
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 4f4fdb6b7f..471edf1c98 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 0c6f8b9d13..6fbcd92a3d 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, int nHashType);
bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType);
-#endif
+#endif // H_BITCOIN_SCRIPT_INTERPRETER
diff --git a/src/script/script.cpp b/src/script/script.cpp
index 60d1beac95..3c9f38dc8b 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"
diff --git a/src/script/script.h b/src/script/script.h
index 21847c09bd..2336cafd67 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
@@ -642,4 +642,4 @@ public:
}
};
-#endif
+#endif // H_BITCOIN_SCRIPT
diff --git a/src/script/sign.cpp b/src/script/sign.cpp
index 958177de3d..db9513db9f 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..bda4b8b0ae 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"
diff --git a/src/script/standard.h b/src/script/standard.h
index 18092e879e..6c17a9394e 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
@@ -53,4 +53,4 @@ 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
+#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/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/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..404cca2373 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>
@@ -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..611fb8bbcd 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));
}
}
}
@@ -1657,7 +1657,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 +1683,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..a3c221d3ab 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"
diff --git a/src/wallet_ismine.h b/src/wallet_ismine.h
index 9915e9f7bb..29e13a94a6 100644
--- a/src/wallet_ismine.h
+++ b/src/wallet_ismine.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_WALLET_ISMINE
@@ -25,4 +25,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>