aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--build-aux/m4/ax_gcc_func_attribute.m4217
-rw-r--r--configure.ac46
-rwxr-xr-xqa/pull-tester/rpc-tests.sh2
-rwxr-xr-xqa/rpc-tests/txn_doublespend.py120
-rwxr-xr-xqa/rpc-tests/txnmall.sh152
-rw-r--r--src/Makefile.am43
-rw-r--r--src/Makefile.qt.include2
-rw-r--r--src/Makefile.qttest.include2
-rw-r--r--src/Makefile.test.include4
-rw-r--r--src/main.cpp5
-rw-r--r--src/qt/askpassphrasedialog.cpp7
-rw-r--r--src/qt/bitcoinstrings.cpp8
-rw-r--r--src/qt/forms/askpassphrasedialog.ui11
-rw-r--r--src/qt/forms/optionsdialog.ui4
-rw-r--r--src/qt/locale/bitcoin_en.ts342
-rw-r--r--src/rpcblockchain.cpp6
-rw-r--r--src/rpcclient.cpp10
-rw-r--r--src/rpcclient.h4
-rw-r--r--src/rpcdump.cpp2
-rw-r--r--src/rpcmining.cpp12
-rw-r--r--src/rpcmisc.cpp10
-rw-r--r--src/rpcnet.cpp2
-rw-r--r--src/rpcprotocol.cpp34
-rw-r--r--src/rpcprotocol.h72
-rw-r--r--src/rpcrawtransaction.cpp2
-rw-r--r--src/rpcserver.h7
-rw-r--r--src/rpcwallet.cpp2
-rw-r--r--src/script/bitcoinconsensus.cpp91
-rw-r--r--src/script/bitcoinconsensus.h67
-rw-r--r--src/script/interpreter.cpp6
-rw-r--r--src/script/interpreter.h13
-rw-r--r--src/script/script_error.cpp2
-rw-r--r--src/script/script_error.h3
-rw-r--r--src/script/standard.h3
-rw-r--r--src/test/data/script_invalid.json17
-rw-r--r--src/test/data/script_valid.json5
-rw-r--r--src/test/script_tests.cpp13
-rw-r--r--src/test/transaction_tests.cpp3
39 files changed, 982 insertions, 374 deletions
diff --git a/.gitignore b/.gitignore
index c97432df92..7343e722d5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,6 +45,7 @@ src/qt/test/moc*.cpp
.deps
.dirstamp
+.libs
.*.swp
*.*~*
*.bak
@@ -66,6 +67,10 @@ src/qt/test/moc*.cpp
*.json.h
*.raw.h
+#libtool object files
+*.lo
+*.la
+
# Compilation and Qt preprocessor part
*.qm
Makefile
diff --git a/build-aux/m4/ax_gcc_func_attribute.m4 b/build-aux/m4/ax_gcc_func_attribute.m4
new file mode 100644
index 0000000000..275ca63a2c
--- /dev/null
+++ b/build-aux/m4/ax_gcc_func_attribute.m4
@@ -0,0 +1,217 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE)
+#
+# DESCRIPTION
+#
+# This macro checks if the compiler supports one of GCC's function
+# attributes; many other compilers also provide function attributes with
+# the same syntax. Compiler warnings are used to detect supported
+# attributes as unsupported ones are ignored by default so quieting
+# warnings when using this macro will yield false positives.
+#
+# The ATTRIBUTE parameter holds the name of the attribute to be checked.
+#
+# If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_<ATTRIBUTE>.
+#
+# The macro caches its result in the ax_cv_have_func_attribute_<attribute>
+# variable.
+#
+# The macro currently supports the following function attributes:
+#
+# alias
+# aligned
+# alloc_size
+# always_inline
+# artificial
+# cold
+# const
+# constructor
+# deprecated
+# destructor
+# dllexport
+# dllimport
+# error
+# externally_visible
+# flatten
+# format
+# format_arg
+# gnu_inline
+# hot
+# ifunc
+# leaf
+# malloc
+# noclone
+# noinline
+# nonnull
+# noreturn
+# nothrow
+# optimize
+# pure
+# unused
+# used
+# visibility
+# warning
+# warn_unused_result
+# weak
+# weakref
+#
+# Unsuppored function attributes will be tested with a prototype returning
+# an int and not accepting any arguments and the result of the check might
+# be wrong or meaningless so use with care.
+#
+# LICENSE
+#
+# Copyright (c) 2013 Gabriele Svelto <gabriele.svelto@gmail.com>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 2
+
+AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [
+ AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1])
+
+ AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([
+ m4_case([$1],
+ [alias], [
+ int foo( void ) { return 0; }
+ int bar( void ) __attribute__(($1("foo")));
+ ],
+ [aligned], [
+ int foo( void ) __attribute__(($1(32)));
+ ],
+ [alloc_size], [
+ void *foo(int a) __attribute__(($1(1)));
+ ],
+ [always_inline], [
+ inline __attribute__(($1)) int foo( void ) { return 0; }
+ ],
+ [artificial], [
+ inline __attribute__(($1)) int foo( void ) { return 0; }
+ ],
+ [cold], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [const], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [constructor], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [deprecated], [
+ int foo( void ) __attribute__(($1("")));
+ ],
+ [destructor], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [dllexport], [
+ __attribute__(($1)) int foo( void ) { return 0; }
+ ],
+ [dllimport], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [error], [
+ int foo( void ) __attribute__(($1("")));
+ ],
+ [externally_visible], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [flatten], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [format], [
+ int foo(const char *p, ...) __attribute__(($1(printf, 1, 2)));
+ ],
+ [format_arg], [
+ char *foo(const char *p) __attribute__(($1(1)));
+ ],
+ [gnu_inline], [
+ inline __attribute__(($1)) int foo( void ) { return 0; }
+ ],
+ [hot], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [ifunc], [
+ int my_foo( void ) { return 0; }
+ static int (*resolve_foo(void))(void) { return my_foo; }
+ int foo( void ) __attribute__(($1("resolve_foo")));
+ ],
+ [leaf], [
+ __attribute__(($1)) int foo( void ) { return 0; }
+ ],
+ [malloc], [
+ void *foo( void ) __attribute__(($1));
+ ],
+ [noclone], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [noinline], [
+ __attribute__(($1)) int foo( void ) { return 0; }
+ ],
+ [nonnull], [
+ int foo(char *p) __attribute__(($1(1)));
+ ],
+ [noreturn], [
+ void foo( void ) __attribute__(($1));
+ ],
+ [nothrow], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [optimize], [
+ __attribute__(($1(3))) int foo( void ) { return 0; }
+ ],
+ [pure], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [unused], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [used], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [visibility], [
+ int foo_def( void ) __attribute__(($1("default")));
+ int foo_hid( void ) __attribute__(($1("hidden")));
+ ],
+ [warning], [
+ int foo( void ) __attribute__(($1("")));
+ ],
+ [warn_unused_result], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [weak], [
+ int foo( void ) __attribute__(($1));
+ ],
+ [weakref], [
+ static int foo( void ) { return 0; }
+ static int bar( void ) __attribute__(($1("foo")));
+ ],
+ [
+ m4_warn([syntax], [Unsupported attribute $1, the test may fail])
+ int foo( void ) __attribute__(($1));
+ ]
+ )], [])
+ ],
+ dnl GCC doesn't exit with an error if an unknown attribute is
+ dnl provided but only outputs a warning, so accept the attribute
+ dnl only if no warning were issued.
+ [AS_IF([test -s conftest.err],
+ [AS_VAR_SET([ac_var], [no])],
+ [AS_VAR_SET([ac_var], [yes])])],
+ [AS_VAR_SET([ac_var], [no])])
+ ])
+
+ AS_IF([test yes = AS_VAR_GET([ac_var])],
+ [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FUNC_ATTRIBUTE_$1), 1,
+ [Define to 1 if the system has the `$1' function attribute])], [])
+
+ AS_VAR_POPDEF([ac_var])
+])
diff --git a/configure.ac b/configure.ac
index c0489f5be7..6784521d81 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,7 +49,7 @@ case $host in
;;
esac
dnl Libtool init checks.
-LT_INIT([disable-shared])
+LT_INIT([pic-only])
dnl Check/return PATH for base programs.
AC_PATH_TOOL(AR, ar)
@@ -201,12 +201,9 @@ case $host in
AC_CHECK_LIB([iphlpapi], [main],, AC_MSG_ERROR(lib missing))
AC_CHECK_LIB([crypt32], [main],, AC_MSG_ERROR(lib missing))
- AX_CHECK_LINK_FLAG([[-static-libgcc]],[LDFLAGS="$LDFLAGS -static-libgcc"])
- AX_CHECK_LINK_FLAG([[-static-libstdc++]],[LDFLAGS="$LDFLAGS -static-libstdc++"])
-
# -static is interpreted by libtool, where it has a different meaning.
# In libtool-speak, it's -all-static.
- AX_CHECK_LINK_FLAG([[-static]],[LDFLAGS="$LDFLAGS -static"; LIBTOOL_LDFLAGS="$LIBTOOL_LDFLAGS -all-static"])
+ AX_CHECK_LINK_FLAG([[-static]],[LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static"])
AC_PATH_PROG([MAKENSIS], [makensis], none)
if test x$MAKENSIS = xnone; then
@@ -229,6 +226,15 @@ case $host in
*) AC_MSG_ERROR("Could not determine win32/win64 for installer") ;;
esac
AC_SUBST(WINDOWS_BITS)
+
+ dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against.
+ dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override
+ dnl its command here, with the predeps/postdeps removed, and -static inserted. Postdeps are
+ dnl also overridden to prevent their insertion later.
+ dnl This should only affect dll's.
+ archive_cmds_CXX="\$CC -shared \$libobjs \$deplibs \$compiler_flags -static -o \$output_objdir/\$soname \${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker \$lib"
+ postdeps_CXX=
+
;;
*darwin*)
TARGET_OS=darwin
@@ -279,6 +285,7 @@ case $host in
esac
fi
+ AX_CHECK_LINK_FLAG([[-Wl,-headerpad_max_install_names]], [LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"])
CPPFLAGS="$CPPFLAGS -DMAC_OSX"
;;
*linux*)
@@ -349,6 +356,10 @@ fi
AX_CHECK_LINK_FLAG([[-Wl,--large-address-aware]], [LDFLAGS="$LDFLAGS -Wl,--large-address-aware"])
+AX_GCC_FUNC_ATTRIBUTE([visibility])
+AX_GCC_FUNC_ATTRIBUTE([dllexport])
+AX_GCC_FUNC_ATTRIBUTE([dllimport])
+
if test x$use_glibc_compat != xno; then
#__fdelt_chk's params and return type have changed from long unsigned int to long int.
@@ -389,6 +400,12 @@ if test x$use_hardening != xno; then
AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"])
fi
+ case $host in
+ *mingw*)
+ AC_CHECK_LIB([ssp], [main],, AC_MSG_ERROR(lib missing))
+ ;;
+ esac
+
CXXFLAGS="$CXXFLAGS $HARDENED_CXXFLAGS"
CPPFLAGS="$CPPFLAGS $HARDENED_CPPFLAGS"
LDFLAGS="$LDFLAGS $HARDENED_LDFLAGS"
@@ -603,6 +620,12 @@ AC_ARG_WITH([utils],
[build_bitcoin_utils=$withval],
[build_bitcoin_utils=yes])
+AC_ARG_WITH([libs],
+ [AS_HELP_STRING([--with-libs],
+ [build libraries (default=yes)])],
+ [build_bitcoin_libs=$withval],
+ [build_bitcoin_libs=yes])
+
AC_ARG_WITH([daemon],
[AS_HELP_STRING([--with-daemon],
[build bitcoind daemon (default=yes)])],
@@ -653,6 +676,13 @@ AC_MSG_CHECKING([whether to build utils (bitcoin-cli bitcoin-tx)])
AM_CONDITIONAL([BUILD_BITCOIN_UTILS], [test x$build_bitcoin_utils = xyes])
AC_MSG_RESULT($build_bitcoin_utils)
+AC_MSG_CHECKING([whether to build libraries])
+AM_CONDITIONAL([BUILD_BITCOIN_LIBS], [test x$build_bitcoin_libs = xyes])
+if test x$build_bitcoin_libs = xyes; then
+ AC_DEFINE(HAVE_CONSENSUS_LIB, 1, [Define this symbol if the consensus lib has been built])
+fi
+AC_MSG_RESULT($build_bitcoin_libs)
+
dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus
BITCOIN_QT_CONFIGURE([$use_pkgconfig], [qt4])
@@ -769,8 +799,8 @@ else
AC_MSG_RESULT([no])
fi
-if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests = xnononono; then
- AC_MSG_ERROR([No targets! Please specify at least one of: --with-utils --with-daemon --with-gui or --enable-tests])
+if test x$build_bitcoin_utils$build_bitcoin_libs$build_bitcoind$bitcoin_enable_qt$use_tests = xnononono; then
+ AC_MSG_ERROR([No targets! Please specify at least one of: --with-utils --with-libs --with-daemon --with-gui or --enable-tests])
fi
AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin])
@@ -801,7 +831,7 @@ AC_SUBST(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE)
AC_SUBST(COPYRIGHT_YEAR, _COPYRIGHT_YEAR)
AC_SUBST(RELDFLAGS)
-AC_SUBST(LIBTOOL_LDFLAGS)
+AC_SUBST(LIBTOOL_APP_LDFLAGS)
AC_SUBST(USE_UPNP)
AC_SUBST(USE_QRCODE)
AC_SUBST(BOOST_LIBS)
diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh
index 7da7404ad9..e01e870390 100755
--- a/qa/pull-tester/rpc-tests.sh
+++ b/qa/pull-tester/rpc-tests.sh
@@ -18,6 +18,8 @@ fi
if [ "x${ENABLE_BITCOIND}${ENABLE_UTILS}${ENABLE_WALLET}" = "x111" ]; then
${BUILDDIR}/qa/rpc-tests/wallet.py --srcdir "${BUILDDIR}/src"
${BUILDDIR}/qa/rpc-tests/listtransactions.py --srcdir "${BUILDDIR}/src"
+ ${BUILDDIR}/qa/rpc-tests/txn_doublespend.py --srcdir "${BUILDDIR}/src"
+ ${BUILDDIR}/qa/rpc-tests/txn_doublespend.py --mineblock --srcdir "${BUILDDIR}/src"
#${BUILDDIR}/qa/rpc-tests/forknotify.py --srcdir "${BUILDDIR}/src"
else
echo "No rpc tests to run. Wallet, utils, and bitcoind must all be enabled"
diff --git a/qa/rpc-tests/txn_doublespend.py b/qa/rpc-tests/txn_doublespend.py
new file mode 100755
index 0000000000..6125147ebc
--- /dev/null
+++ b/qa/rpc-tests/txn_doublespend.py
@@ -0,0 +1,120 @@
+#!/usr/bin/env python
+# Copyright (c) 2014 The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#
+# Test proper accounting with malleable transactions
+#
+
+from test_framework import BitcoinTestFramework
+from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
+from decimal import Decimal
+from util import *
+import os
+import shutil
+
+class TxnMallTest(BitcoinTestFramework):
+
+ def add_options(self, parser):
+ parser.add_option("--mineblock", dest="mine_block", default=False, action="store_true",
+ help="Test double-spend of 1-confirmed transaction")
+
+ def setup_network(self):
+ # Start with split network:
+ return super(TxnMallTest, self).setup_network(True)
+
+ def run_test(self):
+ # All nodes should start with 1,250 BTC:
+ starting_balance = 1250
+ for i in range(4):
+ assert_equal(self.nodes[i].getbalance(), starting_balance)
+ self.nodes[i].getnewaddress("") # bug workaround, coins generated assigned to first getnewaddress!
+
+ # Assign coins to foo and bar accounts:
+ self.nodes[0].move("", "foo", 1220)
+ self.nodes[0].move("", "bar", 30)
+ assert_equal(self.nodes[0].getbalance(""), 0)
+
+ # Coins are sent to node1_address
+ node1_address = self.nodes[1].getnewaddress("from0")
+
+ # First: use raw transaction API to send 1210 BTC to node1_address,
+ # but don't broadcast:
+ (total_in, inputs) = gather_inputs(self.nodes[0], 1210)
+ change_address = self.nodes[0].getnewaddress("foo")
+ outputs = {}
+ outputs[change_address] = 40
+ outputs[node1_address] = 1210
+ rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
+ doublespend = self.nodes[0].signrawtransaction(rawtx)
+ assert_equal(doublespend["complete"], True)
+
+ # Create two transaction from node[0] to node[1]; the
+ # second must spend change from the first because the first
+ # spends all mature inputs:
+ txid1 = self.nodes[0].sendfrom("foo", node1_address, 1210, 0)
+ txid2 = self.nodes[0].sendfrom("bar", node1_address, 20, 0)
+
+ # Have node0 mine a block:
+ if (self.options.mine_block):
+ self.nodes[0].setgenerate(True, 1)
+ sync_blocks(self.nodes[0:2])
+
+ tx1 = self.nodes[0].gettransaction(txid1)
+ tx2 = self.nodes[0].gettransaction(txid2)
+
+ # Node0's balance should be starting balance, plus 50BTC for another
+ # matured block, minus 1210, minus 20, and minus transaction fees:
+ expected = starting_balance
+ if self.options.mine_block: expected += 50
+ expected += tx1["amount"] + tx1["fee"]
+ expected += tx2["amount"] + tx2["fee"]
+ assert_equal(self.nodes[0].getbalance(), expected)
+
+ # foo and bar accounts should be debited:
+ assert_equal(self.nodes[0].getbalance("foo"), 1220+tx1["amount"]+tx1["fee"])
+ assert_equal(self.nodes[0].getbalance("bar"), 30+tx2["amount"]+tx2["fee"])
+
+ if self.options.mine_block:
+ assert_equal(tx1["confirmations"], 1)
+ assert_equal(tx2["confirmations"], 1)
+ # Node1's "from0" balance should be both transaction amounts:
+ assert_equal(self.nodes[1].getbalance("from0"), -(tx1["amount"]+tx2["amount"]))
+ else:
+ assert_equal(tx1["confirmations"], 0)
+ assert_equal(tx2["confirmations"], 0)
+
+ # Now give doublespend to miner:
+ mutated_txid = self.nodes[2].sendrawtransaction(doublespend["hex"])
+ # ... mine a block...
+ self.nodes[2].setgenerate(True, 1)
+
+ # Reconnect the split network, and sync chain:
+ connect_nodes(self.nodes[1], 2)
+ self.nodes[2].setgenerate(True, 1) # Mine another block to make sure we sync
+ sync_blocks(self.nodes)
+
+ # Re-fetch transaction info:
+ tx1 = self.nodes[0].gettransaction(txid1)
+ tx2 = self.nodes[0].gettransaction(txid2)
+
+ # Both transactions should be conflicted
+ assert_equal(tx1["confirmations"], -1)
+ assert_equal(tx2["confirmations"], -1)
+
+ # Node0's total balance should be starting balance, plus 100BTC for
+ # two more matured blocks, minus 1210 for the double-spend:
+ expected = starting_balance + 100 - 1210
+ assert_equal(self.nodes[0].getbalance(), expected)
+ assert_equal(self.nodes[0].getbalance("*"), expected)
+
+ # foo account should be debited, but bar account should not:
+ assert_equal(self.nodes[0].getbalance("foo"), 1220-1210)
+ assert_equal(self.nodes[0].getbalance("bar"), 30)
+
+ # Node1's "from" account balance should be just the mutated send:
+ assert_equal(self.nodes[1].getbalance("from0"), 1210)
+
+if __name__ == '__main__':
+ TxnMallTest().main()
diff --git a/qa/rpc-tests/txnmall.sh b/qa/rpc-tests/txnmall.sh
deleted file mode 100755
index 1296d54d92..0000000000
--- a/qa/rpc-tests/txnmall.sh
+++ /dev/null
@@ -1,152 +0,0 @@
-#!/usr/bin/env bash
-# Copyright (c) 2014 The Bitcoin Core developers
-# Distributed under the MIT software license, see the accompanying
-# file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
-# Test proper accounting with malleable transactions
-
-if [ $# -lt 1 ]; then
- echo "Usage: $0 path_to_binaries"
- echo "e.g. $0 ../../src"
- echo "Env vars BITCOIND and BITCOINCLI may be used to specify the exact binaries used"
- exit 1
-fi
-
-set -f
-
-BITCOIND=${BITCOIND:-${1}/bitcoind}
-CLI=${BITCOINCLI:-${1}/bitcoin-cli}
-
-DIR="${BASH_SOURCE%/*}"
-SENDANDWAIT="${DIR}/send.sh"
-if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
-. "$DIR/util.sh"
-
-D=$(mktemp -d test.XXXXX)
-
-# Two nodes; one will play the part of merchant, the
-# other an evil transaction-mutating miner.
-
-D1=${D}/node1
-CreateDataDir $D1 port=11000 rpcport=11001
-B1ARGS="-datadir=$D1"
-$BITCOIND $B1ARGS &
-B1PID=$!
-
-D2=${D}/node2
-CreateDataDir $D2 port=11010 rpcport=11011
-B2ARGS="-datadir=$D2"
-$BITCOIND $B2ARGS &
-B2PID=$!
-
-# Wait until both nodes are at the same block number
-function WaitBlocks {
- while :
- do
- sleep 1
- declare -i BLOCKS1=$( GetBlocks $B1ARGS )
- declare -i BLOCKS2=$( GetBlocks $B2ARGS )
- if (( BLOCKS1 == BLOCKS2 ))
- then
- break
- fi
- done
-}
-
-# Wait until node has $N peers
-function WaitPeers {
- while :
- do
- declare -i PEERS=$( $CLI $1 getconnectioncount )
- if (( PEERS == "$2" ))
- then
- break
- fi
- sleep 1
- done
-}
-
-echo "Generating test blockchain..."
-
-# Start with B2 connected to B1:
-$CLI $B2ARGS addnode 127.0.0.1:11000 onetry
-WaitPeers "$B1ARGS" 1
-
-# 1 block, 50 XBT each == 50 XBT
-$CLI $B1ARGS setgenerate true 1
-
-WaitBlocks
-# 100 blocks, 0 mature == 0 XBT
-$CLI $B2ARGS setgenerate true 100
-WaitBlocks
-
-CheckBalance "$B1ARGS" 50
-CheckBalance "$B2ARGS" 0
-
-# restart B2 with no connection
-$CLI $B2ARGS stop > /dev/null 2>&1
-wait $B2PID
-$BITCOIND $B2ARGS &
-B2PID=$!
-
-B2ADDRESS=$( $CLI $B2ARGS getaccountaddress "from1" )
-
-# Have B1 create two transactions; second will
-# spend change from first, since B1 starts with only a single
-# 50 bitcoin output:
-$CLI $B1ARGS move "" "foo" 10.0 > /dev/null
-$CLI $B1ARGS move "" "bar" 10.0 > /dev/null
-TXID1=$( $CLI $B1ARGS sendfrom foo $B2ADDRESS 1.0 0)
-TXID2=$( $CLI $B1ARGS sendfrom bar $B2ADDRESS 2.0 0)
-
-# Mutate TXID1 and add it to B2's memory pool:
-RAWTX1=$( $CLI $B1ARGS getrawtransaction $TXID1 )
-# RAWTX1 is hex-encoded, serialized transaction. So each
-# byte is two characters; we'll prepend the first
-# "push" in the scriptsig with OP_PUSHDATA1 (0x4c),
-# and add one to the length of the signature.
-# Fields are fixed; from the beginning:
-# 4-byte version
-# 1-byte varint number-of inputs (one in this case)
-# 32-byte previous txid
-# 4-byte previous output
-# 1-byte varint length-of-scriptsig
-# 1-byte PUSH this many bytes onto stack
-# ... etc
-# So: to mutate, we want to get byte 41 (hex characters 82-83),
-# increment it, and insert 0x4c after it.
-L=${RAWTX1:82:2}
-NEWLEN=$( printf "%x" $(( 16#$L + 1 )) )
-MUTATEDTX1=${RAWTX1:0:82}${NEWLEN}4c${RAWTX1:84}
-# ... give mutated tx1 to B2:
-MUTATEDTXID=$( $CLI $B2ARGS sendrawtransaction $MUTATEDTX1 )
-
-echo "TXID1: " $TXID1
-echo "Mutated: " $MUTATEDTXID
-
-# Re-connect nodes, and have B2 mine a block
-# containing the mutant:
-$CLI $B2ARGS addnode 127.0.0.1:11000 onetry
-$CLI $B2ARGS setgenerate true 1
-WaitBlocks
-
-# B1 should have 49 BTC; the 2 BTC send is
-# conflicted, and should not count in
-# balances.
-CheckBalance "$B1ARGS" 49
-CheckBalance "$B1ARGS" 49 "*"
-CheckBalance "$B1ARGS" 9 "foo"
-CheckBalance "$B1ARGS" 10 "bar"
-
-# B2 should have 51 BTC
-CheckBalance "$B2ARGS" 51
-CheckBalance "$B2ARGS" 1 "from1"
-
-$CLI $B2ARGS stop > /dev/null 2>&1
-wait $B2PID
-$CLI $B1ARGS stop > /dev/null 2>&1
-wait $B1PID
-
-echo "Tests successful, cleaning up"
-rm -rf $D
-exit 0
diff --git a/src/Makefile.am b/src/Makefile.am
index 556fd49c0b..0d45203c90 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -49,6 +49,13 @@ BITCOIN_INCLUDES += $(BDB_CPPFLAGS)
noinst_LIBRARIES += libbitcoin_wallet.a
endif
+if BUILD_BITCOIN_LIBS
+lib_LTLIBRARIES = libbitcoinconsensus.la
+LIBBITCOIN_CONSENSUS=libbitcoinconsensus.la
+else
+LIBBITCOIN_CONSENSUS=
+endif
+
bin_PROGRAMS =
TESTS =
@@ -295,7 +302,7 @@ endif
bitcoind_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS)
bitcoind_CPPFLAGS = $(BITCOIN_INCLUDES)
-bitcoind_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS)
+bitcoind_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
# bitcoin-cli binary #
bitcoin_cli_LDADD = \
@@ -324,12 +331,42 @@ bitcoin_tx_LDADD = \
bitcoin_tx_SOURCES = bitcoin-tx.cpp
bitcoin_tx_CPPFLAGS = $(BITCOIN_INCLUDES)
#
-bitcoin_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS)
+bitcoin_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
if TARGET_WINDOWS
bitcoin_cli_SOURCES += bitcoin-cli-res.rc
endif
-bitcoin_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS)
+bitcoin_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
+
+if BUILD_BITCOIN_LIBS
+include_HEADERS = script/bitcoinconsensus.h
+libbitcoinconsensus_la_SOURCES = \
+ core/transaction.cpp \
+ crypto/sha1.cpp \
+ crypto/sha2.cpp \
+ crypto/ripemd160.cpp \
+ eccryptoverify.cpp \
+ ecwrapper.cpp \
+ hash.cpp \
+ pubkey.cpp \
+ script/script.cpp \
+ script/interpreter.cpp \
+ script/bitcoinconsensus.cpp \
+ uint256.cpp \
+ utilstrencodings.cpp
+
+if GLIBC_BACK_COMPAT
+ libbitcoinconsensus_la_SOURCES += compat/glibc_compat.cpp
+ libbitcoinconsensus_la_SOURCES += compat/glibcxx_compat.cpp
+endif
+
+libbitcoinconsensus_la_LDFLAGS = -no-undefined $(RELDFLAGS)
+libbitcoinconsensus_la_LIBADD = $(CRYPTO_LIBS)
+libbitcoinconsensus_la_CPPFLAGS = $(CRYPTO_CFLAGS) -I$(builddir)/obj -DBUILD_BITCOIN_INTERNAL
+if USE_LIBSECP256K1
+libbitcoinconsensus_la_LIBADD += secp256k1/libsecp256k1.la
+endif
+endif
CLEANFILES = leveldb/libleveldb.a leveldb/libmemenv.a *.gcda *.gcno
diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include
index fac214bdca..898337ad6f 100644
--- a/src/Makefile.qt.include
+++ b/src/Makefile.qt.include
@@ -361,7 +361,7 @@ qt_bitcoin_qt_LDADD += $(LIBBITCOIN_WALLET)
endif
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
$(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1)
-qt_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS)
+qt_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
qt_bitcoin_qt_LIBTOOLFLAGS = --tag CXX
#locale/foo.ts -> locale/foo.qm
diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include
index 622411ca68..c5392cf307 100644
--- a/src/Makefile.qttest.include
+++ b/src/Makefile.qttest.include
@@ -33,7 +33,7 @@ endif
qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) \
$(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \
$(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1)
-qt_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS)
+qt_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
CLEAN_BITCOIN_QT_TEST = $(TEST_QT_MOC_CPP) qt/test/*.gcda qt/test/*.gcno
diff --git a/src/Makefile.test.include b/src/Makefile.test.include
index 79509c9a3e..9e9f478d8f 100644
--- a/src/Makefile.test.include
+++ b/src/Makefile.test.include
@@ -85,8 +85,8 @@ if ENABLE_WALLET
test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET)
endif
-test_test_bitcoin_LDADD += $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS)
-test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS)
+test_test_bitcoin_LDADD += $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS)
+test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static
nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES)
diff --git a/src/main.cpp b/src/main.cpp
index 2bff781bfa..ac5d42d5fc 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2280,6 +2280,8 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
{
// These are checks that are independent of context.
+ // Check that the header is valid (particularly PoW). This is mostly
+ // redundant with the call in AcceptBlockHeader.
if (!CheckBlockHeader(block, state, fCheckPOW))
return false;
@@ -2351,6 +2353,9 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
return true;
}
+ if (!CheckBlockHeader(block, state))
+ return false;
+
// Get prev block index
CBlockIndex* pindexPrev = NULL;
int nHeight = 0;
diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp
index a448d5a9a0..fa9ac6b135 100644
--- a/src/qt/askpassphrasedialog.cpp
+++ b/src/qt/askpassphrasedialog.cpp
@@ -23,6 +23,10 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) :
{
ui->setupUi(this);
+ ui->passEdit1->setMinimumSize(ui->passEdit1->sizeHint());
+ ui->passEdit2->setMinimumSize(ui->passEdit2->sizeHint());
+ ui->passEdit3->setMinimumSize(ui->passEdit3->sizeHint());
+
ui->passEdit1->setMaxLength(MAX_PASSPHRASE_SIZE);
ui->passEdit2->setMaxLength(MAX_PASSPHRASE_SIZE);
ui->passEdit3->setMaxLength(MAX_PASSPHRASE_SIZE);
@@ -35,9 +39,9 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) :
switch(mode)
{
case Encrypt: // Ask passphrase x2
+ ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>ten or more random characters</b>, or <b>eight or more words</b>."));
ui->passLabel1->hide();
ui->passEdit1->hide();
- ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>ten or more random characters</b>, or <b>eight or more words</b>."));
setWindowTitle(tr("Encrypt wallet"));
break;
case Unlock: // Ask passphrase
@@ -61,7 +65,6 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) :
ui->warningLabel->setText(tr("Enter the old and new passphrase to the wallet."));
break;
}
-
textChanged();
connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
diff --git a/src/qt/bitcoinstrings.cpp b/src/qt/bitcoinstrings.cpp
index 1073b6a472..af85df2020 100644
--- a/src/qt/bitcoinstrings.cpp
+++ b/src/qt/bitcoinstrings.cpp
@@ -103,6 +103,9 @@ QT_TRANSLATE_NOOP("bitcoin-core", ""
"Maintain a full transaction index, used by the getrawtransaction rpc call "
"(default: %u)"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
+"Maximum size of data in data carrier transactions we relay and mine "
+"(default: %u)"),
+QT_TRANSLATE_NOOP("bitcoin-core", ""
"Number of seconds to keep misbehaving peers from reconnecting (default: %u)"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Output debugging information (default: %u, supplying <category> is optional)"),
@@ -115,8 +118,8 @@ QT_TRANSLATE_NOOP("bitcoin-core", ""
"Set the number of script verification threads (%u to %d, 0 = auto, <0 = "
"leave that many cores free, default: %d)"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
-"Set the processor limit for when generation is on (-1 = unlimited, default: "
-"%d)"),
+"Set the number of threads for coin generation if enabled (-1 = all cores, "
+"default: %d)"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"This is a pre-release test build - use at your own risk - do not use for "
"mining or merchant applications"),
@@ -250,6 +253,7 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Rescanning..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Run a thread to flush wallet periodically (default: %u)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Run in the background as a daemon and accept commands"),
QT_TRANSLATE_NOOP("bitcoin-core", "Send trace/debug info to console instead of debug.log file"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Send transactions as zero-fee transactions if possible (default: %u)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Server certificate file (default: %s)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Server private key (default: %s)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Set database cache size in megabytes (%d to %d, default: %d)"),
diff --git a/src/qt/forms/askpassphrasedialog.ui b/src/qt/forms/askpassphrasedialog.ui
index bc4921455f..a2105ecd0a 100644
--- a/src/qt/forms/askpassphrasedialog.ui
+++ b/src/qt/forms/askpassphrasedialog.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>598</width>
- <height>198</height>
+ <height>222</height>
</rect>
</property>
<property name="sizePolicy">
@@ -26,8 +26,14 @@
<string>Passphrase Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetMinimumSize</enum>
+ </property>
<item>
<widget class="QLabel" name="warningLabel">
+ <property name="text">
+ <string notr="true">Placeholder text</string>
+ </property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
@@ -38,6 +44,9 @@
</item>
<item>
<layout class="QFormLayout" name="formLayout">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetMinimumSize</enum>
+ </property>
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui
index 3446cf5c33..51156ade4f 100644
--- a/src/qt/forms/optionsdialog.ui
+++ b/src/qt/forms/optionsdialog.ui
@@ -209,10 +209,10 @@
<item>
<widget class="QCheckBox" name="connectSocks">
<property name="toolTip">
- <string>Connect to the Bitcoin network through a SOCKS proxy.</string>
+ <string>Connect to the Bitcoin network through a SOCKS5 proxy.</string>
</property>
<property name="text">
- <string>&amp;Connect through SOCKS proxy (default proxy):</string>
+ <string>&amp;Connect through SOCKS5 proxy (default proxy):</string>
</property>
</widget>
</item>
diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts
index df285441e1..ad63c5c086 100644
--- a/src/qt/locale/bitcoin_en.ts
+++ b/src/qt/locale/bitcoin_en.ts
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
-<TS version="2.1" language="en">
+<TS version="2.0" language="en">
<context>
<name>AddressBookPage</name>
<message>
@@ -150,7 +150,7 @@
<translation>Passphrase Dialog</translation>
</message>
<message>
- <location line="+21"/>
+ <location line="+30"/>
<source>Enter passphrase</source>
<translation>Enter passphrase</translation>
</message>
@@ -165,7 +165,7 @@
<translation>Repeat new passphrase</translation>
</message>
<message>
- <location filename="../askpassphrasedialog.cpp" line="+41"/>
+ <location filename="../askpassphrasedialog.cpp" line="+45"/>
<source>Encrypt wallet</source>
<translation>Encrypt wallet</translation>
</message>
@@ -200,7 +200,7 @@
<translation>Enter the old and new passphrase to the wallet.</translation>
</message>
<message>
- <location line="+46"/>
+ <location line="+45"/>
<source>Confirm wallet encryption</source>
<translation>Confirm wallet encryption</translation>
</message>
@@ -232,12 +232,12 @@
<translation>Wallet encrypted</translation>
</message>
<message>
- <location line="-135"/>
+ <location line="-136"/>
<source>Enter the new passphrase to the wallet.&lt;br/&gt;Please use a passphrase of &lt;b&gt;ten or more random characters&lt;/b&gt;, or &lt;b&gt;eight or more words&lt;/b&gt;.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+79"/>
+ <location line="+80"/>
<source>Bitcoin will close now to finish the encryption process. Remember that encrypting your wallet cannot fully protect your bitcoins from being stolen by malware infecting your computer.</source>
<translation>Bitcoin will close now to finish the encryption process. Remember that encrypting your wallet cannot fully protect your bitcoins from being stolen by malware infecting your computer.</translation>
</message>
@@ -286,7 +286,7 @@
<context>
<name>BitcoinGUI</name>
<message>
- <location filename="../bitcoingui.cpp" line="+309"/>
+ <location filename="../bitcoingui.cpp" line="+311"/>
<source>Sign &amp;message...</source>
<translation>Sign &amp;message...</translation>
</message>
@@ -296,7 +296,7 @@
<translation>Synchronizing with network...</translation>
</message>
<message>
- <location line="-405"/>
+ <location line="-407"/>
<source>&amp;Overview</source>
<translation>&amp;Overview</translation>
</message>
@@ -321,7 +321,7 @@
<translation>Browse transaction history</translation>
</message>
<message>
- <location line="+17"/>
+ <location line="+19"/>
<source>E&amp;xit</source>
<translation>E&amp;xit</translation>
</message>
@@ -392,12 +392,12 @@
<translation>Reindexing blocks on disk...</translation>
</message>
<message>
- <location line="-403"/>
+ <location line="-405"/>
<source>Send coins to a Bitcoin address</source>
<translation>Send coins to a Bitcoin address</translation>
</message>
<message>
- <location line="+46"/>
+ <location line="+48"/>
<source>Modify configuration options for Bitcoin</source>
<translation>Modify configuration options for Bitcoin</translation>
</message>
@@ -432,7 +432,7 @@
<translation>Bitcoin</translation>
</message>
<message>
- <location line="-636"/>
+ <location line="-638"/>
<source>Wallet</source>
<translation>Wallet</translation>
</message>
@@ -447,7 +447,7 @@
<translation>&amp;Receive</translation>
</message>
<message>
- <location line="+30"/>
+ <location line="+32"/>
<source>Show information about Bitcoin Core</source>
<translation type="unfinished"></translation>
</message>
@@ -497,7 +497,7 @@
<translation>Tabs toolbar</translation>
</message>
<message>
- <location line="-295"/>
+ <location line="-297"/>
<source>Bitcoin Core</source>
<translation type="unfinished">Bitcoin Core</translation>
</message>
@@ -507,7 +507,7 @@
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+28"/>
+ <location line="+30"/>
<source>&amp;About Bitcoin Core</source>
<translation type="unfinished"></translation>
</message>
@@ -672,7 +672,7 @@ Address: %4
<context>
<name>ClientModel</name>
<message>
- <location filename="../clientmodel.cpp" line="+139"/>
+ <location filename="../clientmodel.cpp" line="+140"/>
<source>Network Alert</source>
<translation>Network Alert</translation>
</message>
@@ -681,7 +681,7 @@ Address: %4
<name>CoinControlDialog</name>
<message>
<location filename="../forms/coincontroldialog.ui" line="+14"/>
- <source>Coin Control Address Selection</source>
+ <source>Coin Selection</source>
<translation type="unfinished"></translation>
</message>
<message>
@@ -735,19 +735,24 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+16"/>
+ <location line="+13"/>
<source>List mode</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+53"/>
+ <location line="+56"/>
<source>Amount</source>
<translation type="unfinished">Amount</translation>
</message>
<message>
- <location line="+10"/>
- <source>Address</source>
- <translation type="unfinished">Address</translation>
+ <location line="+5"/>
+ <source>Received with label</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+5"/>
+ <source>Received with address</source>
+ <translation type="unfinished"></translation>
</message>
<message>
<location line="+5"/>
@@ -770,7 +775,7 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../coincontroldialog.cpp" line="+43"/>
+ <location filename="../coincontroldialog.cpp" line="+44"/>
<source>Copy address</source>
<translation type="unfinished">Copy address</translation>
</message>
@@ -836,17 +841,17 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+333"/>
+ <location line="+347"/>
<source>highest</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+0"/>
+ <location line="+1"/>
<source>higher</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+0"/>
+ <location line="+1"/>
<source>high</source>
<translation type="unfinished"></translation>
</message>
@@ -856,18 +861,17 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+0"/>
- <location line="+12"/>
+ <location line="+1"/>
<source>medium</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="-11"/>
+ <location line="+1"/>
<source>low-medium</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+0"/>
+ <location line="+1"/>
<source>low</source>
<translation type="unfinished"></translation>
</message>
@@ -877,7 +881,7 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+11"/>
+ <location line="+1"/>
<source>lowest</source>
<translation type="unfinished"></translation>
</message>
@@ -892,12 +896,12 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+162"/>
+ <location line="+165"/>
<source>Can vary +/- %1 satoshi(s) per input.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="-28"/>
+ <location line="-32"/>
<source>yes</source>
<translation type="unfinished"></translation>
</message>
@@ -938,7 +942,7 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+50"/>
+ <location line="+55"/>
<location line="+61"/>
<source>(no label)</source>
<translation type="unfinished">(no label)</translation>
@@ -1224,17 +1228,7 @@ Address: %4
<translation>&amp;Main</translation>
</message>
<message>
- <location line="+116"/>
- <source>Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB.</source>
- <translation>Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB.</translation>
- </message>
- <message>
- <location line="+15"/>
- <source>Pay transaction &amp;fee</source>
- <translation>Pay transaction &amp;fee</translation>
- </message>
- <message>
- <location line="-125"/>
+ <location line="+6"/>
<source>Automatically start Bitcoin after logging in to the system.</source>
<translation>Automatically start Bitcoin after logging in to the system.</translation>
</message>
@@ -1259,7 +1253,7 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+160"/>
+ <location line="+114"/>
<source>Accept connections from outside</source>
<translation type="unfinished"></translation>
</message>
@@ -1269,17 +1263,7 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+7"/>
- <source>Connect to the Bitcoin network through a SOCKS proxy.</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+3"/>
- <source>&amp;Connect through SOCKS proxy (default proxy):</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+34"/>
+ <location line="+44"/>
<source>IP address of the proxy (e.g. IPv4: 127.0.0.1 / IPv6: ::1)</source>
<translation type="unfinished"></translation>
</message>
@@ -1315,7 +1299,7 @@ Address: %4
<translation>&amp;Network</translation>
</message>
<message>
- <location line="-131"/>
+ <location line="-85"/>
<source>(0 = auto, &lt;0 = leave that many cores free)</source>
<translation type="unfinished"></translation>
</message>
@@ -1325,7 +1309,7 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+65"/>
+ <location line="+6"/>
<source>Expert</source>
<translation type="unfinished"></translation>
</message>
@@ -1345,7 +1329,7 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+17"/>
+ <location line="+30"/>
<source>Automatically open the Bitcoin client port on the router. This only works when your router supports UPnP and it is enabled.</source>
<translation>Automatically open the Bitcoin client port on the router. This only works when your router supports UPnP and it is enabled.</translation>
</message>
@@ -1355,7 +1339,17 @@ Address: %4
<translation>Map port using &amp;UPnP</translation>
</message>
<message>
- <location line="+29"/>
+ <location line="+17"/>
+ <source>Connect to the Bitcoin network through a SOCKS5 proxy.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>&amp;Connect through SOCKS5 proxy (default proxy):</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+9"/>
<source>Proxy &amp;IP:</source>
<translation>Proxy &amp;IP:</translation>
</message>
@@ -1420,12 +1414,12 @@ Address: %4
<translation>Choose the default subdivision unit to show in the interface and when sending coins.</translation>
</message>
<message>
- <location line="-240"/>
+ <location line="-253"/>
<source>Whether to show coin control features or not.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+402"/>
+ <location line="+415"/>
<source>&amp;OK</source>
<translation>&amp;OK</translation>
</message>
@@ -1435,17 +1429,17 @@ Address: %4
<translation>&amp;Cancel</translation>
</message>
<message>
- <location filename="../optionsdialog.cpp" line="+71"/>
+ <location filename="../optionsdialog.cpp" line="+76"/>
<source>default</source>
<translation>default</translation>
</message>
<message>
- <location line="+63"/>
+ <location line="+60"/>
<source>none</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+82"/>
+ <location line="+76"/>
<source>Confirm options reset</source>
<translation>Confirm options reset</translation>
</message>
@@ -1466,7 +1460,7 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+34"/>
+ <location line="+25"/>
<source>The supplied proxy address is invalid.</source>
<translation>The supplied proxy address is invalid.</translation>
</message>
@@ -2268,7 +2262,7 @@ Address: %4
<context>
<name>RecentRequestsTableModel</name>
<message>
- <location filename="../recentrequeststablemodel.cpp" line="+26"/>
+ <location filename="../recentrequeststablemodel.cpp" line="+28"/>
<source>Date</source>
<translation type="unfinished">Date</translation>
</message>
@@ -2307,7 +2301,7 @@ Address: %4
<name>SendCoinsDialog</name>
<message>
<location filename="../forms/sendcoinsdialog.ui" line="+14"/>
- <location filename="../sendcoinsdialog.cpp" line="+447"/>
+ <location filename="../sendcoinsdialog.cpp" line="+529"/>
<source>Send Coins</source>
<translation>Send Coins</translation>
</message>
@@ -2377,7 +2371,98 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+164"/>
+ <location line="+206"/>
+ <source>Transaction Fee:</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+14"/>
+ <source>Choose...</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>collapse fee-settings</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>Minimize</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+78"/>
+ <source>If the custom fee is set to 1000 satoshis and the transaction is only 250 bytes, then &quot;per kilobyte&quot; only pays 250 satoshis in fee, while &quot;at least&quot; pays 1000 satoshis. For transactions bigger than a kilobyte both pay by kilobyte.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>per kilobyte</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+13"/>
+ <source>If the custom fee is set to 1000 satoshis and the transaction is only 250 bytes, then &quot;per kilobyte&quot; only pays 250 satoshis in fee, while &quot;total at least&quot; pays 1000 satoshis. For transactions bigger than a kilobyte both pay by kilobyte.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>total at least</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+30"/>
+ <location line="+13"/>
+ <source>Paying only the minimum fee is just fine as long as there is less transaction volume than space in the blocks. But be aware that this can end up in a never confirming transaction once there is more demand for bitcoin transactions than the network can process.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+3"/>
+ <source>(read the tooltip)</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+29"/>
+ <source>Recommended:</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+30"/>
+ <source>Custom:</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+52"/>
+ <source>(Smart fee not initialized yet. This usually takes a few blocks...)</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+29"/>
+ <source>Confirmation time:</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+60"/>
+ <source>normal</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+20"/>
+ <source>fast</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+38"/>
+ <source>Send as zero-fee transaction if possible</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+7"/>
+ <source>(confirmation may take longer)</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+110"/>
<source>Send to multiple recipients at once</source>
<translation>Send to multiple recipients at once</translation>
</message>
@@ -2392,12 +2477,12 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="-274"/>
+ <location line="-858"/>
<source>Dust:</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+277"/>
+ <location line="+861"/>
<source>Clear &amp;All</source>
<translation>Clear &amp;All</translation>
</message>
@@ -2417,12 +2502,12 @@ Address: %4
<translation>S&amp;end</translation>
</message>
<message>
- <location filename="../sendcoinsdialog.cpp" line="-215"/>
+ <location filename="../sendcoinsdialog.cpp" line="-221"/>
<source>Confirm send coins</source>
<translation>Confirm send coins</translation>
</message>
<message>
- <location line="-74"/>
+ <location line="-77"/>
<location line="+5"/>
<location line="+5"/>
<location line="+4"/>
@@ -2430,7 +2515,7 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="-122"/>
+ <location line="-192"/>
<source>Copy quantity</source>
<translation type="unfinished"></translation>
</message>
@@ -2465,7 +2550,7 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+171"/>
+ <location line="+244"/>
<source>Total Amount %1 (= %2)</source>
<translation type="unfinished"></translation>
</message>
@@ -2475,7 +2560,7 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+189"/>
+ <location line="+192"/>
<source>The recipient address is not valid, please recheck.</source>
<translation>The recipient address is not valid, please recheck.</translation>
</message>
@@ -2510,7 +2595,22 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+113"/>
+ <location line="+4"/>
+ <source>A fee higher than %1 is considered an insanely high fee.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+87"/>
+ <source>Pay only the minimum fee of %1</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+22"/>
+ <source>Estimated to begin confirmation within %1 block(s).</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+107"/>
<source>Warning: Invalid Bitcoin address</source>
<translation type="unfinished"></translation>
</message>
@@ -2525,12 +2625,12 @@ Address: %4
<translation type="unfinished"></translation>
</message>
<message>
- <location line="-504"/>
+ <location line="-687"/>
<source>Copy dust</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+151"/>
+ <location line="+221"/>
<source>Are you sure you want to send?</source>
<translation type="unfinished"></translation>
</message>
@@ -3087,7 +3187,7 @@ Address: %4
<context>
<name>TransactionTableModel</name>
<message>
- <location filename="../transactiontablemodel.cpp" line="+235"/>
+ <location filename="../transactiontablemodel.cpp" line="+229"/>
<source>Date</source>
<translation>Date</translation>
</message>
@@ -3102,7 +3202,7 @@ Address: %4
<translation>Address</translation>
</message>
<message>
- <location line="+76"/>
+ <location line="+79"/>
<source>Immature (%1 confirmations, will be available after %2)</source>
<translation type="unfinished"></translation>
</message>
@@ -3418,7 +3518,7 @@ Address: %4
<context>
<name>WalletModel</name>
<message>
- <location filename="../walletmodel.cpp" line="+280"/>
+ <location filename="../walletmodel.cpp" line="+276"/>
<source>Send Coins</source>
<translation>Send Coins</translation>
</message>
@@ -3436,7 +3536,7 @@ Address: %4
<translation>Export the data in the current tab to a file</translation>
</message>
<message>
- <location line="+184"/>
+ <location line="+187"/>
<source>Backup Wallet</source>
<translation>Backup Wallet</translation>
</message>
@@ -3469,27 +3569,27 @@ Address: %4
<context>
<name>bitcoin-core</name>
<message>
- <location filename="../bitcoinstrings.cpp" line="+236"/>
+ <location filename="../bitcoinstrings.cpp" line="+239"/>
<source>Options:</source>
<translation>Options:</translation>
</message>
<message>
- <location line="+30"/>
+ <location line="+31"/>
<source>Specify data directory</source>
<translation>Specify data directory</translation>
</message>
<message>
- <location line="-90"/>
+ <location line="-91"/>
<source>Connect to a node to retrieve peer addresses, and disconnect</source>
<translation>Connect to a node to retrieve peer addresses, and disconnect</translation>
</message>
<message>
- <location line="+93"/>
+ <location line="+94"/>
<source>Specify your own public address</source>
<translation>Specify your own public address</translation>
</message>
<message>
- <location line="-108"/>
+ <location line="-109"/>
<source>Accept command line and JSON-RPC commands</source>
<translation>Accept command line and JSON-RPC commands</translation>
</message>
@@ -3499,17 +3599,17 @@ Address: %4
<translation>Run in the background as a daemon and accept commands</translation>
</message>
<message>
- <location line="+35"/>
+ <location line="+36"/>
<source>Use the test network</source>
<translation>Use the test network</translation>
</message>
<message>
- <location line="-124"/>
+ <location line="-125"/>
<source>Accept connections from outside (default: 1 if no -proxy or -connect)</source>
<translation>Accept connections from outside (default: 1 if no -proxy or -connect)</translation>
</message>
<message>
- <location line="-150"/>
+ <location line="-153"/>
<source>%s, you must set a rpcpassword in the configuration file:
%s
It is recommended you use the following random password:
@@ -3569,7 +3669,7 @@ for example: alertnotify=echo %%s | mail -s &quot;Bitcoin Alert&quot; admin@foo.
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+17"/>
+ <location line="+20"/>
<source>Set the number of script verification threads (%u to %d, 0 = auto, &lt;0 = leave that many cores free, default: %d)</source>
<translation type="unfinished"></translation>
</message>
@@ -3744,7 +3844,7 @@ for example: alertnotify=echo %%s | mail -s &quot;Bitcoin Alert&quot; admin@foo.
<translation>Rebuild block chain index from current blk000??.dat files</translation>
</message>
<message>
- <location line="+10"/>
+ <location line="+11"/>
<source>Set database cache size in megabytes (%d to %d, default: %d)</source>
<translation type="unfinished"></translation>
</message>
@@ -3794,12 +3894,12 @@ for example: alertnotify=echo %%s | mail -s &quot;Bitcoin Alert&quot; admin@foo.
<translation>You need to rebuild the database using -reindex to change -txindex</translation>
</message>
<message>
- <location line="-91"/>
+ <location line="-92"/>
<source>Imports blocks from external blk000??.dat file</source>
<translation>Imports blocks from external blk000??.dat file</translation>
</message>
<message>
- <location line="-179"/>
+ <location line="-182"/>
<source>Allow JSON-RPC connections from specified source. Valid for &lt;ip&gt; are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times</source>
<translation type="unfinished"></translation>
</message>
@@ -3864,7 +3964,12 @@ for example: alertnotify=echo %%s | mail -s &quot;Bitcoin Alert&quot; admin@foo.
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+23"/>
+ <location line="+19"/>
+ <source>Maximum size of data in data carrier transactions we relay and mine (default: %u)</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+7"/>
<source>Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect)</source>
<translation type="unfinished"></translation>
</message>
@@ -3874,7 +3979,12 @@ for example: alertnotify=echo %%s | mail -s &quot;Bitcoin Alert&quot; admin@foo.
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+11"/>
+ <location line="+5"/>
+ <source>Set the number of threads for coin generation if enabled (-1 = all cores, default: %d)</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location line="+6"/>
<source>This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit &lt;https://www.openssl.org/&gt; and cryptographic software written by Eric Young and UPnP software written by Thomas Bernard.</source>
<translation type="unfinished"></translation>
</message>
@@ -4004,6 +4114,11 @@ for example: alertnotify=echo %%s | mail -s &quot;Bitcoin Alert&quot; admin@foo.
<translation>Send trace/debug info to console instead of debug.log file</translation>
</message>
<message>
+ <location line="+1"/>
+ <source>Send transactions as zero-fee transactions if possible (default: %u)</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
<location line="+9"/>
<source>Show all debugging options (usage: --help -help-debug)</source>
<translation type="unfinished"></translation>
@@ -4094,27 +4209,27 @@ for example: alertnotify=echo %%s | mail -s &quot;Bitcoin Alert&quot; admin@foo.
<translation>wallet.dat corrupt, salvage failed</translation>
</message>
<message>
- <location line="-63"/>
+ <location line="-64"/>
<source>Password for JSON-RPC connections</source>
<translation>Password for JSON-RPC connections</translation>
</message>
<message>
- <location line="-157"/>
+ <location line="-160"/>
<source>Execute command when the best block changes (%s in cmd is replaced by block hash)</source>
<translation>Execute command when the best block changes (%s in cmd is replaced by block hash)</translation>
</message>
<message>
- <location line="+202"/>
+ <location line="+206"/>
<source>Upgrade wallet to latest format</source>
<translation>Upgrade wallet to latest format</translation>
</message>
<message>
- <location line="-34"/>
+ <location line="-35"/>
<source>Rescan the block chain for missing wallet transactions</source>
<translation>Rescan the block chain for missing wallet transactions</translation>
</message>
<message>
- <location line="+35"/>
+ <location line="+36"/>
<source>Use OpenSSL (https) for JSON-RPC connections</source>
<translation>Use OpenSSL (https) for JSON-RPC connections</translation>
</message>
@@ -4124,7 +4239,7 @@ for example: alertnotify=echo %%s | mail -s &quot;Bitcoin Alert&quot; admin@foo.
<translation>This help message</translation>
</message>
<message>
- <location line="-107"/>
+ <location line="-108"/>
<source>Allow DNS lookups for -addnode, -seednode and -connect</source>
<translation>Allow DNS lookups for -addnode, -seednode and -connect</translation>
</message>
@@ -4139,7 +4254,7 @@ for example: alertnotify=echo %%s | mail -s &quot;Bitcoin Alert&quot; admin@foo.
<translation>Error loading wallet.dat: Wallet corrupted</translation>
</message>
<message>
- <location line="-167"/>
+ <location line="-170"/>
<source>(1 = keep tx meta data e.g. account owner and payment request information, 2 = drop tx meta data)</source>
<translation type="unfinished"></translation>
</message>
@@ -4169,7 +4284,7 @@ for example: alertnotify=echo %%s | mail -s &quot;Bitcoin Alert&quot; admin@foo.
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+3"/>
+ <location line="+6"/>
<source>Number of seconds to keep misbehaving peers from reconnecting (default: %u)</source>
<translation type="unfinished"></translation>
</message>
@@ -4179,12 +4294,7 @@ for example: alertnotify=echo %%s | mail -s &quot;Bitcoin Alert&quot; admin@foo.
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+10"/>
- <source>Set the processor limit for when generation is on (-1 = unlimited, default: %d)</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location line="+13"/>
+ <location line="+23"/>
<source>Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: %s)</source>
<translation type="unfinished"></translation>
</message>
@@ -4299,7 +4409,7 @@ for example: alertnotify=echo %%s | mail -s &quot;Bitcoin Alert&quot; admin@foo.
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+3"/>
+ <location line="+4"/>
<source>Server certificate file (default: %s)</source>
<translation type="unfinished"></translation>
</message>
@@ -4364,7 +4474,7 @@ for example: alertnotify=echo %%s | mail -s &quot;Bitcoin Alert&quot; admin@foo.
<translation>Unknown network specified in -onlynet: &apos;%s&apos;</translation>
</message>
<message>
- <location line="-111"/>
+ <location line="-112"/>
<source>Cannot resolve -bind address: &apos;%s&apos;</source>
<translation>Cannot resolve -bind address: &apos;%s&apos;</translation>
</message>
@@ -4424,12 +4534,12 @@ for example: alertnotify=echo %%s | mail -s &quot;Bitcoin Alert&quot; admin@foo.
<translation>Done loading</translation>
</message>
<message>
- <location line="+90"/>
+ <location line="+91"/>
<source>To use the %s option</source>
<translation>To use the %s option</translation>
</message>
<message>
- <location line="-82"/>
+ <location line="-83"/>
<source>Error</source>
<translation>Error</translation>
</message>
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index a7cd63bd95..7919fb1a0c 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 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 "checkpoints.h"
@@ -468,7 +468,7 @@ Value getblockchaininfo(const Array& params, bool fHelp)
return obj;
}
-/* Comparison function for sorting the getchaintips heads. */
+/** Comparison function for sorting the getchaintips heads. */
struct CompareBlocksByHeight
{
bool operator()(const CBlockIndex* a, const CBlockIndex* b) const
diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp
index 7a1f1918f6..03ce9acbbf 100644
--- a/src/rpcclient.cpp
+++ b/src/rpcclient.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 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 "rpcclient.h"
@@ -18,8 +18,8 @@ using namespace json_spirit;
class CRPCConvertParam
{
public:
- std::string methodName; // method whose params want conversion
- int paramIdx; // 0-based idx of param to convert
+ std::string methodName; //! method whose params want conversion
+ int paramIdx; //! 0-based idx of param to convert
};
static const CRPCConvertParam vRPCConvertParams[] =
@@ -116,7 +116,7 @@ CRPCConvertTable::CRPCConvertTable()
static CRPCConvertTable rpcCvtTable;
-// Convert strings to command-specific RPC representation
+/** Convert strings to command-specific RPC representation */
Array RPCConvertValues(const std::string &strMethod, const std::vector<std::string> &strParams)
{
Array params;
diff --git a/src/rpcclient.h b/src/rpcclient.h
index cd11f177e8..a91c2eb033 100644
--- a/src/rpcclient.h
+++ b/src/rpcclient.h
@@ -1,6 +1,6 @@
// Copyright (c) 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 BITCOIN_RPCCLIENT_H
diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp
index 9da0a7d091..c3ffe38cc3 100644
--- a/src/rpcdump.cpp
+++ b/src/rpcdump.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2014 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "base58.h"
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index 2bde02c0a1..81120ba981 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 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 "amount.h"
@@ -28,9 +28,11 @@
using namespace json_spirit;
using namespace std;
-// Return average network hashes per second based on the last 'lookup' blocks,
-// or from the last difficulty change if 'lookup' is nonpositive.
-// If 'height' is nonnegative, compute the estimate at the time when a given block was found.
+/**
+ * Return average network hashes per second based on the last 'lookup' blocks,
+ * or from the last difficulty change if 'lookup' is nonpositive.
+ * If 'height' is nonnegative, compute the estimate at the time when a given block was found.
+ */
Value GetNetworkHashPS(int lookup, int height) {
CBlockIndex *pb = chainActive.Tip();
diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp
index 31eaae6162..90b9c99caa 100644
--- a/src/rpcmisc.cpp
+++ b/src/rpcmisc.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "base58.h"
@@ -30,7 +30,7 @@ using namespace std;
/**
* @note Do not add or change anything in the information returned by this
- * method. `getinfo` exists for backwards-compatibilty only. It combines
+ * method. `getinfo` exists for backwards-compatibility only. It combines
* information from wildly different sources in the program, which is a mess,
* and is thus planned to be deprecated eventually.
*
@@ -198,9 +198,9 @@ Value validateaddress(const Array& params, bool fHelp)
return ret;
}
-//
-// Used by addmultisigaddress / createmultisig:
-//
+/**
+ * Used by addmultisigaddress / createmultisig:
+ */
CScript _createmultisig_redeemScript(const Array& params)
{
int nRequired = params[0].get_int();
diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp
index 46b5f3d7ad..6ddbd62fca 100644
--- a/src/rpcnet.cpp
+++ b/src/rpcnet.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2014 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "rpcserver.h"
diff --git a/src/rpcprotocol.cpp b/src/rpcprotocol.cpp
index c2ce73106f..2f7c491f3d 100644
--- a/src/rpcprotocol.cpp
+++ b/src/rpcprotocol.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "rpcprotocol.h"
@@ -30,15 +30,15 @@ using namespace boost;
using namespace boost::asio;
using namespace json_spirit;
-// Number of bytes to allocate and read at most at once in post data
+//! Number of bytes to allocate and read at most at once in post data
const size_t POST_READ_SIZE = 256 * 1024;
-//
-// HTTP protocol
-//
-// This ain't Apache. We're just using HTTP header for the length field
-// and to be compatible with other JSON-RPC implementations.
-//
+/**
+ * HTTP protocol
+ *
+ * This ain't Apache. We're just using HTTP header for the length field
+ * and to be compatible with other JSON-RPC implementations.
+ */
string HTTPPost(const string& strMsg, const map<string,string>& mapRequestHeaders)
{
@@ -246,15 +246,15 @@ int ReadHTTPMessage(std::basic_istream<char>& stream, map<string,
return HTTP_OK;
}
-//
-// JSON-RPC protocol. Bitcoin speaks version 1.0 for maximum compatibility,
-// but uses JSON-RPC 1.1/2.0 standards for parts of the 1.0 standard that were
-// unspecified (HTTP errors and contents of 'error').
-//
-// 1.0 spec: http://json-rpc.org/wiki/specification
-// 1.2 spec: http://jsonrpc.org/historical/json-rpc-over-http.html
-// http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx
-//
+/**
+ * JSON-RPC protocol. Bitcoin speaks version 1.0 for maximum compatibility,
+ * but uses JSON-RPC 1.1/2.0 standards for parts of the 1.0 standard that were
+ * unspecified (HTTP errors and contents of 'error').
+ *
+ * 1.0 spec: http://json-rpc.org/wiki/specification
+ * 1.2 spec: http://jsonrpc.org/historical/json-rpc-over-http.html
+ * http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx
+ */
string JSONRPCRequest(const string& strMethod, const Array& params, const Value& id)
{
diff --git a/src/rpcprotocol.h b/src/rpcprotocol.h
index f0d0f3445c..a321338176 100644
--- a/src/rpcprotocol.h
+++ b/src/rpcprotocol.h
@@ -1,6 +1,6 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_RPCPROTOCOL_H
@@ -19,7 +19,7 @@
#include "json/json_spirit_utils.h"
#include "json/json_spirit_writer_template.h"
-// HTTP status codes
+//! HTTP status codes
enum HTTPStatusCode
{
HTTP_OK = 200,
@@ -30,56 +30,56 @@ enum HTTPStatusCode
HTTP_INTERNAL_SERVER_ERROR = 500,
};
-// Bitcoin RPC error codes
+//! Bitcoin RPC error codes
enum RPCErrorCode
{
- // Standard JSON-RPC 2.0 errors
+ //! Standard JSON-RPC 2.0 errors
RPC_INVALID_REQUEST = -32600,
RPC_METHOD_NOT_FOUND = -32601,
RPC_INVALID_PARAMS = -32602,
RPC_INTERNAL_ERROR = -32603,
RPC_PARSE_ERROR = -32700,
- // General application defined errors
- RPC_MISC_ERROR = -1, // std::exception thrown in command handling
- RPC_FORBIDDEN_BY_SAFE_MODE = -2, // Server is in safe mode, and command is not allowed in safe mode
- RPC_TYPE_ERROR = -3, // Unexpected type was passed as parameter
- RPC_INVALID_ADDRESS_OR_KEY = -5, // Invalid address or key
- RPC_OUT_OF_MEMORY = -7, // Ran out of memory during operation
- RPC_INVALID_PARAMETER = -8, // Invalid, missing or duplicate parameter
- RPC_DATABASE_ERROR = -20, // Database error
- RPC_DESERIALIZATION_ERROR = -22, // Error parsing or validating structure in raw format
- RPC_VERIFY_ERROR = -25, // General error during transaction or block submission
- RPC_VERIFY_REJECTED = -26, // Transaction or block was rejected by network rules
- RPC_VERIFY_ALREADY_IN_CHAIN = -27, // Transaction already in chain
- RPC_IN_WARMUP = -28, // Client still warming up
+ //! General application defined errors
+ RPC_MISC_ERROR = -1, //! std::exception thrown in command handling
+ RPC_FORBIDDEN_BY_SAFE_MODE = -2, //! Server is in safe mode, and command is not allowed in safe mode
+ RPC_TYPE_ERROR = -3, //! Unexpected type was passed as parameter
+ RPC_INVALID_ADDRESS_OR_KEY = -5, //! Invalid address or key
+ RPC_OUT_OF_MEMORY = -7, //! Ran out of memory during operation
+ RPC_INVALID_PARAMETER = -8, //! Invalid, missing or duplicate parameter
+ RPC_DATABASE_ERROR = -20, //! Database error
+ RPC_DESERIALIZATION_ERROR = -22, //! Error parsing or validating structure in raw format
+ RPC_VERIFY_ERROR = -25, //! General error during transaction or block submission
+ RPC_VERIFY_REJECTED = -26, //! Transaction or block was rejected by network rules
+ RPC_VERIFY_ALREADY_IN_CHAIN = -27, //! Transaction already in chain
+ RPC_IN_WARMUP = -28, //! Client still warming up
- // Aliases for backward compatibility
+ //! Aliases for backward compatibility
RPC_TRANSACTION_ERROR = RPC_VERIFY_ERROR,
RPC_TRANSACTION_REJECTED = RPC_VERIFY_REJECTED,
RPC_TRANSACTION_ALREADY_IN_CHAIN= RPC_VERIFY_ALREADY_IN_CHAIN,
- // P2P client errors
- RPC_CLIENT_NOT_CONNECTED = -9, // Bitcoin is not connected
- RPC_CLIENT_IN_INITIAL_DOWNLOAD = -10, // Still downloading initial blocks
- RPC_CLIENT_NODE_ALREADY_ADDED = -23, // Node is already added
- RPC_CLIENT_NODE_NOT_ADDED = -24, // Node has not been added before
+ //! P2P client errors
+ RPC_CLIENT_NOT_CONNECTED = -9, //! Bitcoin is not connected
+ RPC_CLIENT_IN_INITIAL_DOWNLOAD = -10, //! Still downloading initial blocks
+ RPC_CLIENT_NODE_ALREADY_ADDED = -23, //! Node is already added
+ RPC_CLIENT_NODE_NOT_ADDED = -24, //! Node has not been added before
- // Wallet errors
- RPC_WALLET_ERROR = -4, // Unspecified problem with wallet (key not found etc.)
- RPC_WALLET_INSUFFICIENT_FUNDS = -6, // Not enough funds in wallet or account
- RPC_WALLET_INVALID_ACCOUNT_NAME = -11, // Invalid account name
- RPC_WALLET_KEYPOOL_RAN_OUT = -12, // Keypool ran out, call keypoolrefill first
- RPC_WALLET_UNLOCK_NEEDED = -13, // Enter the wallet passphrase with walletpassphrase first
- RPC_WALLET_PASSPHRASE_INCORRECT = -14, // The wallet passphrase entered was incorrect
- RPC_WALLET_WRONG_ENC_STATE = -15, // Command given in wrong wallet encryption state (encrypting an encrypted wallet etc.)
- RPC_WALLET_ENCRYPTION_FAILED = -16, // Failed to encrypt the wallet
- RPC_WALLET_ALREADY_UNLOCKED = -17, // Wallet is already unlocked
+ //! Wallet errors
+ RPC_WALLET_ERROR = -4, //! Unspecified problem with wallet (key not found etc.)
+ RPC_WALLET_INSUFFICIENT_FUNDS = -6, //! Not enough funds in wallet or account
+ RPC_WALLET_INVALID_ACCOUNT_NAME = -11, //! Invalid account name
+ RPC_WALLET_KEYPOOL_RAN_OUT = -12, //! Keypool ran out, call keypoolrefill first
+ RPC_WALLET_UNLOCK_NEEDED = -13, //! Enter the wallet passphrase with walletpassphrase first
+ RPC_WALLET_PASSPHRASE_INCORRECT = -14, //! The wallet passphrase entered was incorrect
+ RPC_WALLET_WRONG_ENC_STATE = -15, //! Command given in wrong wallet encryption state (encrypting an encrypted wallet etc.)
+ RPC_WALLET_ENCRYPTION_FAILED = -16, //! Failed to encrypt the wallet
+ RPC_WALLET_ALREADY_UNLOCKED = -17, //! Wallet is already unlocked
};
-//
-// IOStream device that speaks SSL but can also speak non-SSL
-//
+/**
+ * IOStream device that speaks SSL but can also speak non-SSL
+ */
template <typename Protocol>
class SSLIOStreamDevice : public boost::iostreams::device<boost::iostreams::bidirectional> {
public:
diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp
index d3ce3b3191..25734f4930 100644
--- a/src/rpcrawtransaction.cpp
+++ b/src/rpcrawtransaction.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "base58.h"
diff --git a/src/rpcserver.h b/src/rpcserver.h
index b3234f65f2..7395fc23c6 100644
--- a/src/rpcserver.h
+++ b/src/rpcserver.h
@@ -40,12 +40,13 @@ void StartRPCThreads();
* If real RPC threads have already been started this is a no-op.
*/
void StartDummyRPCThread();
-/* Stop RPC threads */
+/** Stop RPC threads */
void StopRPCThreads();
-/* Query whether RPC is running */
+/** Query whether RPC is running */
bool IsRPCRunning();
-/* Set the RPC warmup status. When this is done, all RPC calls will error out
+/**
+ * Set the RPC warmup status. When this is done, all RPC calls will error out
* immediately with RPC_IN_WARMUP.
*/
void SetRPCWarmupStatus(const std::string& newStatus);
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index 4d9e5ea137..d2d14ad9f4 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "amount.h"
diff --git a/src/script/bitcoinconsensus.cpp b/src/script/bitcoinconsensus.cpp
new file mode 100644
index 0000000000..4faa760ad7
--- /dev/null
+++ b/src/script/bitcoinconsensus.cpp
@@ -0,0 +1,91 @@
+// Copyright (c) 2009-2010 Satoshi Nakamoto
+// 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 "bitcoinconsensus.h"
+
+#include "core/transaction.h"
+#include "script/interpreter.h"
+#include "version.h"
+
+namespace {
+
+/** A class that deserializes a single CTransaction one time. */
+class TxInputStream
+{
+public:
+ TxInputStream(int nTypeIn, int nVersionIn, const unsigned char *txTo, size_t txToLen) :
+ m_type(nTypeIn),
+ m_version(nVersionIn),
+ m_data(txTo),
+ m_remaining(txToLen)
+ {}
+
+ TxInputStream& read(char* pch, size_t nSize)
+ {
+ if (nSize > m_remaining)
+ throw std::ios_base::failure(std::string(__func__) + ": end of data");
+
+ if (pch == NULL)
+ throw std::ios_base::failure(std::string(__func__) + ": bad destination buffer");
+
+ if (m_data == NULL)
+ throw std::ios_base::failure(std::string(__func__) + ": bad source buffer");
+
+ memcpy(pch, m_data, nSize);
+ m_remaining -= nSize;
+ m_data += nSize;
+ return *this;
+ }
+
+ template<typename T>
+ TxInputStream& operator>>(T& obj)
+ {
+ ::Unserialize(*this, obj, m_type, m_version);
+ return *this;
+ }
+
+private:
+ const int m_type;
+ const int m_version;
+ const unsigned char* m_data;
+ size_t m_remaining;
+};
+
+inline int set_error(bitcoinconsensus_error* ret, bitcoinconsensus_error serror)
+{
+ if (ret)
+ *ret = serror;
+ return 0;
+}
+
+} // anon namespace
+
+int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
+ const unsigned char *txTo , unsigned int txToLen,
+ unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err)
+{
+ try {
+ TxInputStream stream(SER_NETWORK, PROTOCOL_VERSION, txTo, txToLen);
+ CTransaction tx;
+ stream >> tx;
+ if (nIn >= tx.vin.size())
+ return set_error(err, bitcoinconsensus_ERR_TX_INDEX);
+ if (tx.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION) != txToLen)
+ return set_error(err, bitcoinconsensus_ERR_TX_SIZE_MISMATCH);
+
+ // Regardless of the verification result, the tx did not error.
+ set_error(err, bitcoinconsensus_ERR_OK);
+
+ return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), flags, SignatureChecker(tx, nIn), NULL);
+ } catch (std::exception &e) {
+ return set_error(err, bitcoinconsensus_ERR_TX_DESERIALIZE); // Error deserializing
+ }
+}
+
+unsigned int bitcoinconsensus_version()
+{
+ // Just use the API version for now
+ return BITCOINCONSENSUS_API_VER;
+}
diff --git a/src/script/bitcoinconsensus.h b/src/script/bitcoinconsensus.h
new file mode 100644
index 0000000000..15e3337a8d
--- /dev/null
+++ b/src/script/bitcoinconsensus.h
@@ -0,0 +1,67 @@
+// Copyright (c) 2009-2010 Satoshi Nakamoto
+// 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 BITCOIN_BITCOINCONSENSUS_H
+#define BITCOIN_BITCOINCONSENSUS_H
+
+#if defined(BUILD_BITCOIN_INTERNAL) && defined(HAVE_CONFIG_H)
+#include "config/bitcoin-config.h"
+ #if defined(_WIN32)
+ #if defined(DLL_EXPORT)
+ #if defined(HAVE_FUNC_ATTRIBUTE_DLLEXPORT)
+ #define EXPORT_SYMBOL __declspec(dllexport)
+ #else
+ #define EXPORT_SYMBOL
+ #endif
+ #endif
+ #elif defined(HAVE_FUNC_ATTRIBUTE_VISIBILITY)
+ #define EXPORT_SYMBOL __attribute__ ((visibility ("default")))
+ #endif
+#elif defined(MSC_VER) && !defined(STATIC_LIBBITCOINCONSENSUS)
+ #define EXPORT_SYMBOL __declspec(dllimport)
+#endif
+
+#ifndef EXPORT_SYMBOL
+ #define EXPORT_SYMBOL
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BITCOINCONSENSUS_API_VER 0
+
+typedef enum bitcoinconsensus_error_t
+{
+ bitcoinconsensus_ERR_OK = 0,
+ bitcoinconsensus_ERR_TX_INDEX,
+ bitcoinconsensus_ERR_TX_SIZE_MISMATCH,
+ bitcoinconsensus_ERR_TX_DESERIALIZE,
+} bitcoinconsensus_error;
+
+/** Script verification flags */
+enum
+{
+ bitcoinconsensus_SCRIPT_FLAGS_VERIFY_NONE = 0,
+ bitcoinconsensus_SCRIPT_FLAGS_VERIFY_P2SH = (1U << 0), // evaluate P2SH (BIP16) subscripts
+};
+
+/// Returns 1 if the input nIn of the serialized transaction pointed to by
+/// txTo correctly spends the scriptPubKey pointed to by scriptPubKey under
+/// the additional constraints specified by flags.
+/// If not NULL, err will contain an error/success code for the operation
+EXPORT_SYMBOL int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
+ const unsigned char *txTo , unsigned int txToLen,
+ unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err);
+
+EXPORT_SYMBOL unsigned int bitcoinconsensus_version();
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#undef EXPORT_SYMBOL
+
+#endif // BITCOIN_BITCOINCONSENSUS_H
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index cf81fe30a2..760086eaba 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -329,8 +329,14 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, un
// Control
//
case OP_NOP:
+ break;
+
case OP_NOP1: case OP_NOP2: case OP_NOP3: case OP_NOP4: case OP_NOP5:
case OP_NOP6: case OP_NOP7: case OP_NOP8: case OP_NOP9: case OP_NOP10:
+ {
+ if (flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)
+ return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS);
+ }
break;
case OP_IF:
diff --git a/src/script/interpreter.h b/src/script/interpreter.h
index 14cccc558f..12b2719414 100644
--- a/src/script/interpreter.h
+++ b/src/script/interpreter.h
@@ -57,7 +57,18 @@ enum
// any other push causes the script to fail (BIP62 rule 3).
// In addition, whenever a stack element is interpreted as a number, it must be of minimal length (BIP62 rule 4).
// (softfork safe)
- SCRIPT_VERIFY_MINIMALDATA = (1U << 6)
+ SCRIPT_VERIFY_MINIMALDATA = (1U << 6),
+
+ // Discourage use of NOPs reserved for upgrades (NOP1-10)
+ //
+ // Provided so that nodes can avoid accepting or mining transactions
+ // containing executed NOP's whose meaning may change after a soft-fork,
+ // thus rendering the script invalid; with this flag set executing
+ // discouraged NOPs fails the script. This verification flag will never be
+ // a mandatory flag applied to scripts in a block. NOPs that are not
+ // executed, e.g. within an unexecuted IF ENDIF block, are *not* rejected.
+ SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS = (1U << 7)
+
};
uint256 SignatureHash(const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
diff --git a/src/script/script_error.cpp b/src/script/script_error.cpp
index 4a3df268ec..793fc0da41 100644
--- a/src/script/script_error.cpp
+++ b/src/script/script_error.cpp
@@ -59,6 +59,8 @@ const char* ScriptErrorString(const ScriptError serror)
return "Non-canonical signature: S value is unnecessarily high";
case SCRIPT_ERR_SIG_NULLDUMMY:
return "Dummy CHECKMULTISIG argument must be zero";
+ case SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS:
+ return "NOPx reserved for soft-fork upgrades";
case SCRIPT_ERR_UNKNOWN_ERROR:
case SCRIPT_ERR_ERROR_COUNT:
default: break;
diff --git a/src/script/script_error.h b/src/script/script_error.h
index ae6626b257..21153f1bd1 100644
--- a/src/script/script_error.h
+++ b/src/script/script_error.h
@@ -43,6 +43,9 @@ typedef enum ScriptError_t
SCRIPT_ERR_SIG_HIGH_S,
SCRIPT_ERR_SIG_NULLDUMMY,
+ /* softfork safeness */
+ SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS,
+
SCRIPT_ERR_ERROR_COUNT
} ScriptError;
diff --git a/src/script/standard.h b/src/script/standard.h
index f3dcc75fdc..c4b82b4c45 100644
--- a/src/script/standard.h
+++ b/src/script/standard.h
@@ -47,7 +47,8 @@ static const unsigned int MANDATORY_SCRIPT_VERIFY_FLAGS = SCRIPT_VERIFY_P2SH;
static const unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VERIFY_FLAGS |
SCRIPT_VERIFY_STRICTENC |
SCRIPT_VERIFY_MINIMALDATA |
- SCRIPT_VERIFY_NULLDUMMY;
+ SCRIPT_VERIFY_NULLDUMMY |
+ SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS;
/** For convenience, standard but not mandatory verify flags. */
static const unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS;
diff --git a/src/test/data/script_invalid.json b/src/test/data/script_invalid.json
index 6f451a36ee..0356d0be1c 100644
--- a/src/test/data/script_invalid.json
+++ b/src/test/data/script_invalid.json
@@ -163,6 +163,23 @@ nSequences are max.
["1","NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 2 EQUAL", "P2SH,STRICTENC"],
["'NOP_1_to_10' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_11' EQUAL", "P2SH,STRICTENC"],
+["Ensure 100% coverage of discouraged NOPS"],
+["1", "NOP1", "P2SH,DISCOURAGE_UPGRADABLE_NOPS"],
+["1", "NOP2", "P2SH,DISCOURAGE_UPGRADABLE_NOPS"],
+["1", "NOP3", "P2SH,DISCOURAGE_UPGRADABLE_NOPS"],
+["1", "NOP4", "P2SH,DISCOURAGE_UPGRADABLE_NOPS"],
+["1", "NOP5", "P2SH,DISCOURAGE_UPGRADABLE_NOPS"],
+["1", "NOP6", "P2SH,DISCOURAGE_UPGRADABLE_NOPS"],
+["1", "NOP7", "P2SH,DISCOURAGE_UPGRADABLE_NOPS"],
+["1", "NOP8", "P2SH,DISCOURAGE_UPGRADABLE_NOPS"],
+["1", "NOP9", "P2SH,DISCOURAGE_UPGRADABLE_NOPS"],
+["1", "NOP10", "P2SH,DISCOURAGE_UPGRADABLE_NOPS"],
+
+["NOP10", "1", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "Discouraged NOP10 in scriptSig"],
+
+["1 0x01 0xb9", "HASH160 0x14 0x15727299b05b45fdaf9ac9ecf7565cfe27c3e567 EQUAL",
+ "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "Discouraged NOP10 in redeemScript"],
+
["0x50","1", "P2SH,STRICTENC", "opcode 0x50 is reserved"],
["1", "IF 0xba ELSE 1 ENDIF", "P2SH,STRICTENC", "opcodes above NOP10 invalid if executed"],
["1", "IF 0xbb ELSE 1 ENDIF", "P2SH,STRICTENC"],
diff --git a/src/test/data/script_valid.json b/src/test/data/script_valid.json
index 439c82ef32..0cf1563163 100644
--- a/src/test/data/script_valid.json
+++ b/src/test/data/script_valid.json
@@ -235,6 +235,11 @@ nSequences are max.
["1","NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL", "P2SH,STRICTENC"],
["'NOP_1_to_10' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_10' EQUAL", "P2SH,STRICTENC"],
+["1", "NOP", "P2SH,STRICTENC,DISCOURAGE_UPGRADABLE_NOPS", "Discourage NOPx flag allows OP_NOP"],
+
+["0", "IF NOP10 ENDIF 1", "P2SH,STRICTENC,DISCOURAGE_UPGRADABLE_NOPS",
+ "Discouraged NOPs are allowed if not executed"],
+
["0", "IF 0xba ELSE 1 ENDIF", "P2SH,STRICTENC", "opcodes above NOP10 invalid if executed"],
["0", "IF 0xbb ELSE 1 ENDIF", "P2SH,STRICTENC"],
["0", "IF 0xbc ELSE 1 ENDIF", "P2SH,STRICTENC"],
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index d98154571b..36aaa6903f 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -14,6 +14,10 @@
#include "script/sign.h"
#include "util.h"
+#if defined(HAVE_CONSENSUS_LIB)
+#include "script/bitcoinconsensus.h"
+#endif
+
#include <fstream>
#include <stdint.h>
#include <string>
@@ -94,8 +98,15 @@ CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CMu
void DoTest(const CScript& scriptPubKey, const CScript& scriptSig, int flags, bool expect, const std::string& message)
{
ScriptError err;
- BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, flags, SignatureChecker(BuildSpendingTransaction(scriptSig, BuildCreditingTransaction(scriptPubKey)), 0), &err) == expect, message);
+ CMutableTransaction tx = BuildSpendingTransaction(scriptSig, BuildCreditingTransaction(scriptPubKey));
+ CMutableTransaction tx2 = tx;
+ BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, flags, SignatureChecker(tx, 0), &err) == expect, message);
BOOST_CHECK_MESSAGE(expect == (err == SCRIPT_ERR_OK), std::string(ScriptErrorString(err)) + ": " + message);
+#if defined(HAVE_CONSENSUS_LIB)
+ CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
+ stream << tx2;
+ BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script(begin_ptr(scriptPubKey), scriptPubKey.size(), (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect,message);
+#endif
}
void static NegateSignatureS(std::vector<unsigned char>& vchSig) {
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
index bf3a60c04f..e939e89972 100644
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -37,7 +37,8 @@ static std::map<string, unsigned int> mapFlagNames = boost::assign::map_list_of
(string("LOW_S"), (unsigned int)SCRIPT_VERIFY_LOW_S)
(string("SIGPUSHONLY"), (unsigned int)SCRIPT_VERIFY_SIGPUSHONLY)
(string("MINIMALDATA"), (unsigned int)SCRIPT_VERIFY_MINIMALDATA)
- (string("NULLDUMMY"), (unsigned int)SCRIPT_VERIFY_NULLDUMMY);
+ (string("NULLDUMMY"), (unsigned int)SCRIPT_VERIFY_NULLDUMMY)
+ (string("DISCOURAGE_UPGRADABLE_NOPS"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS);
unsigned int ParseScriptFlags(string strFlags)
{