aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml1
-rw-r--r--COPYING2
-rw-r--r--README.md2
-rw-r--r--configure.ac15
-rw-r--r--contrib/README.md4
-rw-r--r--contrib/debian/control2
-rw-r--r--contrib/debian/copyright2
-rw-r--r--contrib/devtools/README.md22
-rwxr-xr-xcontrib/devtools/check-doc.py45
-rwxr-xr-xcontrib/devtools/clang-format-diff.py164
-rwxr-xr-xcontrib/devtools/github-merge.py223
-rwxr-xr-xcontrib/devtools/github-merge.sh185
-rwxr-xr-xcontrib/devtools/security-check.py2
-rw-r--r--contrib/gitian-descriptors/gitian-linux.yml2
-rw-r--r--contrib/gitian-descriptors/gitian-osx.yml2
-rw-r--r--contrib/gitian-descriptors/gitian-win.yml2
-rw-r--r--doc/gitian-building.md6
-rwxr-xr-xqa/rpc-tests/bip65-cltv-p2p.py2
-rwxr-xr-xqa/rpc-tests/bip65-cltv.py4
-rwxr-xr-xqa/rpc-tests/bipdersig-p2p.py2
-rwxr-xr-xqa/rpc-tests/bipdersig.py4
-rwxr-xr-xqa/rpc-tests/blockchain.py40
-rwxr-xr-xqa/rpc-tests/disablewallet.py1
-rwxr-xr-xqa/rpc-tests/forknotify.py2
-rwxr-xr-xqa/rpc-tests/fundrawtransaction.py50
-rwxr-xr-xqa/rpc-tests/getchaintips.py4
-rwxr-xr-xqa/rpc-tests/httpbasics.py14
-rwxr-xr-xqa/rpc-tests/invalidblockrequest.py2
-rwxr-xr-xqa/rpc-tests/invalidtxrequest.py4
-rwxr-xr-xqa/rpc-tests/keypool.py6
-rwxr-xr-xqa/rpc-tests/listtransactions.py114
-rwxr-xr-xqa/rpc-tests/mempool_limit.py2
-rwxr-xr-xqa/rpc-tests/mempool_packages.py9
-rwxr-xr-xqa/rpc-tests/mempool_reorg.py8
-rwxr-xr-xqa/rpc-tests/mempool_resurrect_test.py2
-rwxr-xr-xqa/rpc-tests/mempool_spendcoinbase.py2
-rwxr-xr-xqa/rpc-tests/merkle_blocks.py4
-rwxr-xr-xqa/rpc-tests/nodehandling.py5
-rwxr-xr-xqa/rpc-tests/p2p-fullblocktest.py6
-rwxr-xr-xqa/rpc-tests/proxy_test.py6
-rwxr-xr-xqa/rpc-tests/pruning.py1
-rwxr-xr-xqa/rpc-tests/rawtransactions.py16
-rwxr-xr-xqa/rpc-tests/receivedby.py5
-rwxr-xr-xqa/rpc-tests/reindex.py1
-rwxr-xr-xqa/rpc-tests/replace-by-fee.py3
-rwxr-xr-xqa/rpc-tests/rest.py14
-rwxr-xr-xqa/rpc-tests/rpcbind_test.py7
-rwxr-xr-xqa/rpc-tests/sendheaders.py3
-rw-r--r--qa/rpc-tests/test_framework/blocktools.py2
-rw-r--r--qa/rpc-tests/test_framework/script.py8
-rw-r--r--qa/rpc-tests/test_framework/util.py59
-rwxr-xr-xqa/rpc-tests/txn_clone.py4
-rwxr-xr-xqa/rpc-tests/txn_doublespend.py3
-rwxr-xr-xqa/rpc-tests/wallet.py4
-rwxr-xr-xqa/rpc-tests/zmq_test.py7
-rw-r--r--share/setup.nsi.in2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/chainparams.cpp3
-rw-r--r--src/chainparams.h2
-rw-r--r--src/clientversion.h2
-rw-r--r--src/init.cpp15
-rw-r--r--src/main.cpp16
-rw-r--r--src/main.h2
-rw-r--r--src/net.cpp56
-rw-r--r--src/netbase.cpp2
-rw-r--r--src/policy/fees.cpp2
-rw-r--r--src/policy/fees.h6
-rw-r--r--src/policy/rbf.cpp46
-rw-r--r--src/policy/rbf.h20
-rw-r--r--src/qt/clientmodel.cpp2
-rw-r--r--src/qt/sendcoinsdialog.cpp2
-rw-r--r--src/rpcblockchain.cpp4
-rw-r--r--src/test/merkle_tests.cpp2
-rw-r--r--src/torcontrol.cpp14
-rw-r--r--src/wallet/db.cpp2
-rw-r--r--src/wallet/rpcwallet.cpp24
-rw-r--r--src/wallet/wallet_ismine.h2
-rw-r--r--src/wallet/walletdb.cpp5
78 files changed, 944 insertions, 400 deletions
diff --git a/.travis.yml b/.travis.yml
index e2d43d6330..71cee99254 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -64,6 +64,7 @@ script:
- test -n "$USE_SHELL" && eval '"$USE_SHELL" -c "./autogen.sh"' || ./autogen.sh
- ./configure --cache-file=config.cache $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false)
- make distdir PACKAGE=bitcoin VERSION=$HOST
+ - if [ "$RUN_TESTS" = "true" ]; then contrib/devtools/check-doc.py; fi
- cd bitcoin-$HOST
- ./configure --cache-file=../config.cache $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false)
- make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && make $GOAL V=1 ; false )
diff --git a/COPYING b/COPYING
index 314d2e2ff3..c6be8e5470 100644
--- a/COPYING
+++ b/COPYING
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2009-2015 The Bitcoin Core developers
+Copyright (c) 2009-2016 The Bitcoin Core developers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 5bf56947d8..77d30db695 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@ Bitcoin Core integration/staging tree
[![Build Status](https://travis-ci.org/bitcoin/bitcoin.svg?branch=master)](https://travis-ci.org/bitcoin/bitcoin)
-https://www.bitcoin.org
+https://bitcoincore.org
What is Bitcoin?
----------------
diff --git a/configure.ac b/configure.ac
index 07f9a4a6f3..3e5303647a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@ define(_CLIENT_VERSION_MINOR, 12)
define(_CLIENT_VERSION_REVISION, 99)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, false)
-define(_COPYRIGHT_YEAR, 2015)
+define(_COPYRIGHT_YEAR, 2016)
AC_INIT([Bitcoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/bitcoin/bitcoin/issues],[bitcoin])
AC_CONFIG_SRCDIR([src/main.cpp])
AC_CONFIG_HEADERS([src/config/bitcoin-config.h])
@@ -619,6 +619,17 @@ if test x$use_boost = xyes; then
BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB $BOOST_CHRONO_LIB"
+
+dnl If boost (prior to 1.57) was built without c++11, it emulated scoped enums
+dnl using c++98 constructs. Unfortunately, this implementation detail leaked into
+dnl the abi. This was fixed in 1.57.
+
+dnl When building against that installed version using c++11, the headers pick up
+dnl on the native c++11 scoped enum support and enable it, however it will fail to
+dnl link. This can be worked around by disabling c++11 scoped enums if linking will
+dnl fail.
+dnl BOOST_NO_SCOPED_ENUMS was changed to BOOST_NO_CXX11_SCOPED_ENUMS in 1.51.
+
TEMP_LIBS="$LIBS"
LIBS="$BOOST_LIBS $LIBS"
TEMP_CPPFLAGS="$CPPFLAGS"
@@ -640,7 +651,7 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
choke;
#endif
]])],
- [AC_MSG_RESULT(mismatched); AC_DEFINE(FORCE_BOOST_EMULATED_SCOPED_ENUMS, 1, [Define this symbol if boost scoped enums are emulated])], [AC_MSG_RESULT(ok)])
+ [AC_MSG_RESULT(mismatched); BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_NO_SCOPED_ENUMS -DBOOST_NO_CXX11_SCOPED_ENUMS"], [AC_MSG_RESULT(ok)])
LIBS="$TEMP_LIBS"
CPPFLAGS="$TEMP_CPPFLAGS"
diff --git a/contrib/README.md b/contrib/README.md
index 125594312b..b6e572102a 100644
--- a/contrib/README.md
+++ b/contrib/README.md
@@ -11,10 +11,10 @@ Repository Tools
### [Developer tools](/contrib/devtools) ###
Specific tools for developers working on this repository.
-Contains the script `github-merge.sh` for merging github pull requests securely and signing them using GPG.
+Contains the script `github-merge.py` for merging github pull requests securely and signing them using GPG.
### [Verify-Commits](/contrib/verify-commits) ###
-Tool to verify that every merge commit was signed by a developer using the above `github-merge.sh` script.
+Tool to verify that every merge commit was signed by a developer using the above `github-merge.py` script.
### [Linearize](/contrib/linearize) ###
Construct a linear, no-fork, best version of the blockchain.
diff --git a/contrib/debian/control b/contrib/debian/control
index 490b2571c3..fce6bc0118 100644
--- a/contrib/debian/control
+++ b/contrib/debian/control
@@ -23,7 +23,7 @@ Build-Depends: debhelper,
libprotobuf-dev, protobuf-compiler,
python
Standards-Version: 3.9.2
-Homepage: https://www.bitcoin.org/
+Homepage: https://bitcoincore.org/
Vcs-Git: git://github.com/bitcoin/bitcoin.git
Vcs-Browser: https://github.com/bitcoin/bitcoin
diff --git a/contrib/debian/copyright b/contrib/debian/copyright
index 83ce560a79..bbaa5b1636 100644
--- a/contrib/debian/copyright
+++ b/contrib/debian/copyright
@@ -5,7 +5,7 @@ Upstream-Contact: Satoshi Nakamoto <satoshin@gmx.com>
Source: https://github.com/bitcoin/bitcoin
Files: *
-Copyright: 2009-2015, Bitcoin Core Developers
+Copyright: 2009-2016, Bitcoin Core Developers
License: Expat
Comment: The Bitcoin Core Developers encompasses the current developers listed on bitcoin.org,
as well as the numerous contributors to the project.
diff --git a/contrib/devtools/README.md b/contrib/devtools/README.md
index 240ab6d9e0..1103ca86c5 100644
--- a/contrib/devtools/README.md
+++ b/contrib/devtools/README.md
@@ -2,11 +2,29 @@ Contents
========
This directory contains tools for developers working on this repository.
+check-doc.py
+============
+
+Check if all command line args are documented. The return value indicates the
+number of undocumented args.
+
clang-format.py
===============
A script to format cpp source code according to [.clang-format](../../src/.clang-format). This should only be applied to new files or files which are currently not actively developed on. Also, git subtrees are not subject to formatting.
+clang-format-diff.py
+===================
+
+A script to format unified git diffs according to [.clang-format](../../src/.clang-format).
+
+For instance, to format the last commit with 0 lines of context,
+the script should be called from the git root folder as follows.
+
+```
+git diff -U0 HEAD~1.. | ./contrib/devtools/clang-format-diff.py -p1 -i -v
+```
+
fix-copyright-headers.py
========================
@@ -38,14 +56,14 @@ Usage: `git-subtree-check.sh DIR COMMIT`
`COMMIT` may be omitted, in which case `HEAD` is used.
-github-merge.sh
+github-merge.py
===============
A small script to automate merging pull-requests securely and sign them with GPG.
For example:
- ./github-merge.sh bitcoin/bitcoin 3077
+ ./github-merge.py 3077
(in any git repository) will help you merge pull request #3077 for the
bitcoin/bitcoin repository.
diff --git a/contrib/devtools/check-doc.py b/contrib/devtools/check-doc.py
new file mode 100755
index 0000000000..9c589e6e6d
--- /dev/null
+++ b/contrib/devtools/check-doc.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# Copyright (c) 2015 The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+'''
+This checks if all command line args are documented.
+Return value is 0 to indicate no error.
+
+Author: @MarcoFalke
+'''
+
+from subprocess import check_output
+import re
+
+FOLDER_GREP = 'src'
+FOLDER_TEST = 'src/test/'
+CMD_ROOT_DIR = '`git rev-parse --show-toplevel`/%s' % FOLDER_GREP
+CMD_GREP_ARGS = r"egrep -r -I '(map(Multi)?Args(\.count\(|\[)|Get(Bool)?Arg\()\"\-[^\"]+?\"' %s | grep -v '%s'" % (CMD_ROOT_DIR, FOLDER_TEST)
+CMD_GREP_DOCS = r"egrep -r -I 'HelpMessageOpt\(\"\-[^\"=]+?(=|\")' %s" % (CMD_ROOT_DIR)
+REGEX_ARG = re.compile(r'(?:map(?:Multi)?Args(?:\.count\(|\[)|Get(?:Bool)?Arg\()\"(\-[^\"]+?)\"')
+REGEX_DOC = re.compile(r'HelpMessageOpt\(\"(\-[^\"=]+?)(?:=|\")')
+# list unsupported, deprecated and duplicate args as they need no documentation
+SET_DOC_OPTIONAL = set(['-rpcssl', '-benchmark', '-h', '-help', '-socks', '-tor', '-debugnet'])
+
+def main():
+ used = check_output(CMD_GREP_ARGS, shell=True)
+ docd = check_output(CMD_GREP_DOCS, shell=True)
+
+ args_used = set(re.findall(REGEX_ARG,used))
+ args_docd = set(re.findall(REGEX_DOC,docd)).union(SET_DOC_OPTIONAL)
+ args_need_doc = args_used.difference(args_docd)
+ args_unknown = args_docd.difference(args_used)
+
+ print "Args used : %s" % len(args_used)
+ print "Args documented : %s" % len(args_docd)
+ print "Args undocumented: %s" % len(args_need_doc)
+ print args_need_doc
+ print "Args unknown : %s" % len(args_unknown)
+ print args_unknown
+
+ exit(len(args_need_doc))
+
+if __name__ == "__main__":
+ main()
diff --git a/contrib/devtools/clang-format-diff.py b/contrib/devtools/clang-format-diff.py
new file mode 100755
index 0000000000..13d2573b9f
--- /dev/null
+++ b/contrib/devtools/clang-format-diff.py
@@ -0,0 +1,164 @@
+#!/usr/bin/env python
+#
+#===- clang-format-diff.py - ClangFormat Diff Reformatter ----*- python -*--===#
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License.
+#
+# ============================================================
+#
+# University of Illinois/NCSA
+# Open Source License
+#
+# Copyright (c) 2007-2015 University of Illinois at Urbana-Champaign.
+# All rights reserved.
+#
+# Developed by:
+#
+# LLVM Team
+#
+# University of Illinois at Urbana-Champaign
+#
+# http://llvm.org
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy of
+# this software and associated documentation files (the "Software"), to deal with
+# the Software without restriction, including without limitation the rights to
+# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+# of the Software, and to permit persons to whom the Software is furnished to do
+# so, subject to the following conditions:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimers.
+#
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimers in the
+# documentation and/or other materials provided with the distribution.
+#
+# * Neither the names of the LLVM Team, University of Illinois at
+# Urbana-Champaign, nor the names of its contributors may be used to
+# endorse or promote products derived from this Software without specific
+# prior written permission.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
+# SOFTWARE.
+#
+# ============================================================
+#
+#===------------------------------------------------------------------------===#
+
+r"""
+ClangFormat Diff Reformatter
+============================
+
+This script reads input from a unified diff and reformats all the changed
+lines. This is useful to reformat all the lines touched by a specific patch.
+Example usage for git/svn users:
+
+ git diff -U0 HEAD^ | clang-format-diff.py -p1 -i
+ svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i
+
+"""
+
+import argparse
+import difflib
+import re
+import string
+import subprocess
+import StringIO
+import sys
+
+
+# Change this to the full path if clang-format is not on the path.
+binary = 'clang-format'
+
+
+def main():
+ parser = argparse.ArgumentParser(description=
+ 'Reformat changed lines in diff. Without -i '
+ 'option just output the diff that would be '
+ 'introduced.')
+ parser.add_argument('-i', action='store_true', default=False,
+ help='apply edits to files instead of displaying a diff')
+ parser.add_argument('-p', metavar='NUM', default=0,
+ help='strip the smallest prefix containing P slashes')
+ parser.add_argument('-regex', metavar='PATTERN', default=None,
+ help='custom pattern selecting file paths to reformat '
+ '(case sensitive, overrides -iregex)')
+ parser.add_argument('-iregex', metavar='PATTERN', default=
+ r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hpp|m|mm|inc|js|ts|proto'
+ r'|protodevel|java)',
+ help='custom pattern selecting file paths to reformat '
+ '(case insensitive, overridden by -regex)')
+ parser.add_argument('-sort-includes', action='store_true', default=False,
+ help='let clang-format sort include blocks')
+ parser.add_argument('-v', '--verbose', action='store_true',
+ help='be more verbose, ineffective without -i')
+ args = parser.parse_args()
+
+ # Extract changed lines for each file.
+ filename = None
+ lines_by_file = {}
+ for line in sys.stdin:
+ match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
+ if match:
+ filename = match.group(2)
+ if filename == None:
+ continue
+
+ if args.regex is not None:
+ if not re.match('^%s$' % args.regex, filename):
+ continue
+ else:
+ if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE):
+ continue
+
+ match = re.search('^@@.*\+(\d+)(,(\d+))?', line)
+ if match:
+ start_line = int(match.group(1))
+ line_count = 1
+ if match.group(3):
+ line_count = int(match.group(3))
+ if line_count == 0:
+ continue
+ end_line = start_line + line_count - 1;
+ lines_by_file.setdefault(filename, []).extend(
+ ['-lines', str(start_line) + ':' + str(end_line)])
+
+ # Reformat files containing changes in place.
+ for filename, lines in lines_by_file.iteritems():
+ if args.i and args.verbose:
+ print 'Formatting', filename
+ command = [binary, filename]
+ if args.i:
+ command.append('-i')
+ if args.sort_includes:
+ command.append('-sort-includes')
+ command.extend(lines)
+ command.extend(['-style=file', '-fallback-style=none'])
+ p = subprocess.Popen(command, stdout=subprocess.PIPE,
+ stderr=None, stdin=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ if p.returncode != 0:
+ sys.exit(p.returncode);
+
+ if not args.i:
+ with open(filename) as f:
+ code = f.readlines()
+ formatted_code = StringIO.StringIO(stdout).readlines()
+ diff = difflib.unified_diff(code, formatted_code,
+ filename, filename,
+ '(before formatting)', '(after formatting)')
+ diff_string = string.join(diff, '')
+ if len(diff_string) > 0:
+ sys.stdout.write(diff_string)
+
+if __name__ == '__main__':
+ main()
diff --git a/contrib/devtools/github-merge.py b/contrib/devtools/github-merge.py
new file mode 100755
index 0000000000..33d33b7005
--- /dev/null
+++ b/contrib/devtools/github-merge.py
@@ -0,0 +1,223 @@
+#!/usr/bin/env python2
+# Copyright (c) 2016 Bitcoin Core Developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+# This script will locally construct a merge commit for a pull request on a
+# github repository, inspect it, sign it and optionally push it.
+
+# The following temporary branches are created/overwritten and deleted:
+# * pull/$PULL/base (the current master we're merging onto)
+# * pull/$PULL/head (the current state of the remote pull request)
+# * pull/$PULL/merge (github's merge)
+# * pull/$PULL/local-merge (our merge)
+
+# In case of a clean merge that is accepted by the user, the local branch with
+# name $BRANCH is overwritten with the merged result, and optionally pushed.
+from __future__ import division,print_function,unicode_literals
+import os,sys
+from sys import stdin,stdout,stderr
+import argparse
+import subprocess
+
+# External tools (can be overridden using environment)
+GIT = os.getenv('GIT','git')
+BASH = os.getenv('BASH','bash')
+
+def git_config_get(option, default=None):
+ '''
+ Get named configuration option from git repository.
+ '''
+ try:
+ return subprocess.check_output([GIT,'config','--get',option]).rstrip()
+ except subprocess.CalledProcessError as e:
+ return default
+
+def retrieve_pr_title(repo,pull):
+ '''
+ Retrieve pull request title from github.
+ Return None if no title can be found, or an error happens.
+ '''
+ import urllib2,json
+ try:
+ req = urllib2.Request("https://api.github.com/repos/"+repo+"/pulls/"+pull)
+ result = urllib2.urlopen(req)
+ result = json.load(result)
+ return result['title']
+ except Exception as e:
+ print('Warning: unable to retrieve pull title from github: %s' % e)
+ return None
+
+def ask_prompt(text):
+ print(text,end=" ",file=stderr)
+ reply = stdin.readline().rstrip()
+ print("",file=stderr)
+ return reply
+
+def parse_arguments(branch):
+ epilog = '''
+ In addition, you can set the following git configuration variables:
+ githubmerge.repository (mandatory),
+ user.signingkey (mandatory),
+ githubmerge.host (default: git@github.com),
+ githubmerge.branch (default: master),
+ githubmerge.testcmd (default: none).
+ '''
+ parser = argparse.ArgumentParser(description='Utility to merge, sign and push github pull requests',
+ epilog=epilog)
+ parser.add_argument('pull', metavar='PULL', type=int, nargs=1,
+ help='Pull request ID to merge')
+ parser.add_argument('branch', metavar='BRANCH', type=str, nargs='?',
+ default=branch, help='Branch to merge against (default: '+branch+')')
+ return parser.parse_args()
+
+def main():
+ # Extract settings from git repo
+ repo = git_config_get('githubmerge.repository')
+ host = git_config_get('githubmerge.host','git@github.com')
+ branch = git_config_get('githubmerge.branch','master')
+ testcmd = git_config_get('githubmerge.testcmd')
+ signingkey = git_config_get('user.signingkey')
+ if repo is None:
+ print("ERROR: No repository configured. Use this command to set:", file=stderr)
+ print("git config githubmerge.repository <owner>/<repo>", file=stderr)
+ exit(1)
+ if signingkey is None:
+ print("ERROR: No GPG signing key set. Set one using:",file=stderr)
+ print("git config --global user.signingkey <key>",file=stderr)
+ exit(1)
+
+ host_repo = host+":"+repo # shortcut for push/pull target
+
+ # Extract settings from command line
+ args = parse_arguments(branch)
+ pull = str(args.pull[0])
+ branch = args.branch
+
+ # Initialize source branches
+ head_branch = 'pull/'+pull+'/head'
+ base_branch = 'pull/'+pull+'/base'
+ merge_branch = 'pull/'+pull+'/merge'
+ local_merge_branch = 'pull/'+pull+'/local-merge'
+
+ devnull = open(os.devnull,'w')
+ try:
+ subprocess.check_call([GIT,'checkout','-q',branch])
+ except subprocess.CalledProcessError as e:
+ print("ERROR: Cannot check out branch %s." % (branch), file=stderr)
+ exit(3)
+ try:
+ subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/pull/'+pull+'/*:refs/heads/pull/'+pull+'/*'])
+ except subprocess.CalledProcessError as e:
+ print("ERROR: Cannot find pull request #%s on %s." % (pull,host_repo), file=stderr)
+ exit(3)
+ try:
+ subprocess.check_call([GIT,'log','-q','-1','refs/heads/'+head_branch], stdout=devnull, stderr=stdout)
+ except subprocess.CalledProcessError as e:
+ print("ERROR: Cannot find head of pull request #%s on %s." % (pull,host_repo), file=stderr)
+ exit(3)
+ try:
+ subprocess.check_call([GIT,'log','-q','-1','refs/heads/'+merge_branch], stdout=devnull, stderr=stdout)
+ except subprocess.CalledProcessError as e:
+ print("ERROR: Cannot find merge of pull request #%s on %s." % (pull,host_repo), file=stderr)
+ exit(3)
+ try:
+ subprocess.check_call([GIT,'fetch','-q',host_repo,'+refs/heads/'+branch+':refs/heads/'+base_branch])
+ except subprocess.CalledProcessError as e:
+ print("ERROR: Cannot find branch %s on %s." % (branch,host_repo), file=stderr)
+ exit(3)
+ subprocess.check_call([GIT,'checkout','-q',base_branch])
+ subprocess.call([GIT,'branch','-q','-D',local_merge_branch], stderr=devnull)
+ subprocess.check_call([GIT,'checkout','-q','-b',local_merge_branch])
+
+ try:
+ # Create unsigned merge commit.
+ title = retrieve_pr_title(repo,pull)
+ if title:
+ firstline = 'Merge #%s: %s' % (pull,title)
+ else:
+ firstline = 'Merge #%s' % (pull,)
+ message = firstline + '\n\n'
+ message += subprocess.check_output([GIT,'log','--no-merges','--topo-order','--pretty=format:%h %s (%an)',base_branch+'..'+head_branch])
+ try:
+ subprocess.check_call([GIT,'merge','-q','--commit','--no-edit','--no-ff','-m',message,head_branch])
+ except subprocess.CalledProcessError as e:
+ print("ERROR: Cannot be merged cleanly.",file=stderr)
+ subprocess.check_call([GIT,'merge','--abort'])
+ exit(4)
+ logmsg = subprocess.check_output([GIT,'log','--pretty=format:%s','-n','1'])
+ if logmsg.rstrip() != firstline.rstrip():
+ print("ERROR: Creating merge failed (already merged?).",file=stderr)
+ exit(4)
+
+ # Run test command if configured.
+ if testcmd:
+ # Go up to the repository's root.
+ toplevel = subprocess.check_output([GIT,'rev-parse','--show-toplevel'])
+ os.chdir(toplevel)
+ if subprocess.call(testcmd,shell=True):
+ print("ERROR: Running %s failed." % testcmd,file=stderr)
+ exit(5)
+
+ # Show the created merge.
+ diff = subprocess.check_output([GIT,'diff',merge_branch+'..'+local_merge_branch])
+ subprocess.check_call([GIT,'diff',base_branch+'..'+local_merge_branch])
+ if diff:
+ print("WARNING: merge differs from github!",file=stderr)
+ reply = ask_prompt("Type 'ignore' to continue.")
+ if reply.lower() == 'ignore':
+ print("Difference with github ignored.",file=stderr)
+ else:
+ exit(6)
+ reply = ask_prompt("Press 'd' to accept the diff.")
+ if reply.lower() == 'd':
+ print("Diff accepted.",file=stderr)
+ else:
+ print("ERROR: Diff rejected.",file=stderr)
+ exit(6)
+ else:
+ # Verify the result manually.
+ print("Dropping you on a shell so you can try building/testing the merged source.",file=stderr)
+ print("Run 'git diff HEAD~' to show the changes being merged.",file=stderr)
+ print("Type 'exit' when done.",file=stderr)
+ if os.path.isfile('/etc/debian_version'): # Show pull number on Debian default prompt
+ os.putenv('debian_chroot',pull)
+ subprocess.call([BASH,'-i'])
+ reply = ask_prompt("Type 'm' to accept the merge.")
+ if reply.lower() == 'm':
+ print("Merge accepted.",file=stderr)
+ else:
+ print("ERROR: Merge rejected.",file=stderr)
+ exit(7)
+
+ # Sign the merge commit.
+ reply = ask_prompt("Type 's' to sign off on the merge.")
+ if reply == 's':
+ try:
+ subprocess.check_call([GIT,'commit','-q','--gpg-sign','--amend','--no-edit'])
+ except subprocess.CalledProcessError as e:
+ print("Error signing, exiting.",file=stderr)
+ exit(1)
+ else:
+ print("Not signing off on merge, exiting.",file=stderr)
+ exit(1)
+
+ # Put the result in branch.
+ subprocess.check_call([GIT,'checkout','-q',branch])
+ subprocess.check_call([GIT,'reset','-q','--hard',local_merge_branch])
+ finally:
+ # Clean up temporary branches.
+ subprocess.call([GIT,'checkout','-q',branch])
+ subprocess.call([GIT,'branch','-q','-D',head_branch],stderr=devnull)
+ subprocess.call([GIT,'branch','-q','-D',base_branch],stderr=devnull)
+ subprocess.call([GIT,'branch','-q','-D',merge_branch],stderr=devnull)
+ subprocess.call([GIT,'branch','-q','-D',local_merge_branch],stderr=devnull)
+
+ # Push the result.
+ reply = ask_prompt("Type 'push' to push the result to %s, branch %s." % (host_repo,branch))
+ if reply.lower() == 'push':
+ subprocess.check_call([GIT,'push',host_repo,'refs/heads/'+branch])
+
+if __name__ == '__main__':
+ main()
+
diff --git a/contrib/devtools/github-merge.sh b/contrib/devtools/github-merge.sh
deleted file mode 100755
index afb53f0390..0000000000
--- a/contrib/devtools/github-merge.sh
+++ /dev/null
@@ -1,185 +0,0 @@
-#!/bin/bash
-
-# This script will locally construct a merge commit for a pull request on a
-# github repository, inspect it, sign it and optionally push it.
-
-# The following temporary branches are created/overwritten and deleted:
-# * pull/$PULL/base (the current master we're merging onto)
-# * pull/$PULL/head (the current state of the remote pull request)
-# * pull/$PULL/merge (github's merge)
-# * pull/$PULL/local-merge (our merge)
-
-# In case of a clean merge that is accepted by the user, the local branch with
-# name $BRANCH is overwritten with the merged result, and optionally pushed.
-
-REPO="$(git config --get githubmerge.repository)"
-if [[ "d$REPO" == "d" ]]; then
- echo "ERROR: No repository configured. Use this command to set:" >&2
- echo "git config githubmerge.repository <owner>/<repo>" >&2
- echo "In addition, you can set the following variables:" >&2
- echo "- githubmerge.host (default git@github.com)" >&2
- echo "- githubmerge.branch (default master)" >&2
- echo "- githubmerge.testcmd (default none)" >&2
- exit 1
-fi
-
-HOST="$(git config --get githubmerge.host)"
-if [[ "d$HOST" == "d" ]]; then
- HOST="git@github.com"
-fi
-
-BRANCH="$(git config --get githubmerge.branch)"
-if [[ "d$BRANCH" == "d" ]]; then
- BRANCH="master"
-fi
-
-TESTCMD="$(git config --get githubmerge.testcmd)"
-
-PULL="$1"
-
-if [[ "d$PULL" == "d" ]]; then
- echo "Usage: $0 pullnumber [branch]" >&2
- exit 2
-fi
-
-if [[ "d$2" != "d" ]]; then
- BRANCH="$2"
-fi
-
-# Initialize source branches.
-git checkout -q "$BRANCH"
-if git fetch -q "$HOST":"$REPO" "+refs/pull/$PULL/*:refs/heads/pull/$PULL/*"; then
- if ! git log -q -1 "refs/heads/pull/$PULL/head" >/dev/null 2>&1; then
- echo "ERROR: Cannot find head of pull request #$PULL on $HOST:$REPO." >&2
- exit 3
- fi
- if ! git log -q -1 "refs/heads/pull/$PULL/merge" >/dev/null 2>&1; then
- echo "ERROR: Cannot find merge of pull request #$PULL on $HOST:$REPO." >&2
- exit 3
- fi
-else
- echo "ERROR: Cannot find pull request #$PULL on $HOST:$REPO." >&2
- exit 3
-fi
-if git fetch -q "$HOST":"$REPO" +refs/heads/"$BRANCH":refs/heads/pull/"$PULL"/base; then
- true
-else
- echo "ERROR: Cannot find branch $BRANCH on $HOST:$REPO." >&2
- exit 3
-fi
-git checkout -q pull/"$PULL"/base
-git branch -q -D pull/"$PULL"/local-merge 2>/dev/null
-git checkout -q -b pull/"$PULL"/local-merge
-TMPDIR="$(mktemp -d -t ghmXXXXX)"
-
-function cleanup() {
- git checkout -q "$BRANCH"
- git branch -q -D pull/"$PULL"/head 2>/dev/null
- git branch -q -D pull/"$PULL"/base 2>/dev/null
- git branch -q -D pull/"$PULL"/merge 2>/dev/null
- git branch -q -D pull/"$PULL"/local-merge 2>/dev/null
- rm -rf "$TMPDIR"
-}
-
-# Create unsigned merge commit.
-(
- echo "Merge pull request #$PULL"
- echo ""
- git log --no-merges --topo-order --pretty='format:%h %s (%an)' pull/"$PULL"/base..pull/"$PULL"/head
-)>"$TMPDIR/message"
-if git merge -q --commit --no-edit --no-ff -m "$(<"$TMPDIR/message")" pull/"$PULL"/head; then
- if [ "d$(git log --pretty='format:%s' -n 1)" != "dMerge pull request #$PULL" ]; then
- echo "ERROR: Creating merge failed (already merged?)." >&2
- cleanup
- exit 4
- fi
-else
- echo "ERROR: Cannot be merged cleanly." >&2
- git merge --abort
- cleanup
- exit 4
-fi
-
-# Run test command if configured.
-if [[ "d$TESTCMD" != "d" ]]; then
- # Go up to the repository's root.
- while [ ! -d .git ]; do cd ..; done
- if ! $TESTCMD; then
- echo "ERROR: Running $TESTCMD failed." >&2
- cleanup
- exit 5
- fi
- # Show the created merge.
- git diff pull/"$PULL"/merge..pull/"$PULL"/local-merge >"$TMPDIR"/diff
- git diff pull/"$PULL"/base..pull/"$PULL"/local-merge
- if [[ "$(<"$TMPDIR"/diff)" != "" ]]; then
- echo "WARNING: merge differs from github!" >&2
- read -p "Type 'ignore' to continue. " -r >&2
- if [[ "d$REPLY" =~ ^d[iI][gG][nN][oO][rR][eE]$ ]]; then
- echo "Difference with github ignored." >&2
- else
- cleanup
- exit 6
- fi
- fi
- read -p "Press 'd' to accept the diff. " -n 1 -r >&2
- echo
- if [[ "d$REPLY" =~ ^d[dD]$ ]]; then
- echo "Diff accepted." >&2
- else
- echo "ERROR: Diff rejected." >&2
- cleanup
- exit 6
- fi
-else
- # Verify the result.
- echo "Dropping you on a shell so you can try building/testing the merged source." >&2
- echo "Run 'git diff HEAD~' to show the changes being merged." >&2
- echo "Type 'exit' when done." >&2
- if [[ -f /etc/debian_version ]]; then # Show pull number in prompt on Debian default prompt
- export debian_chroot="$PULL"
- fi
- bash -i
- read -p "Press 'm' to accept the merge. " -n 1 -r >&2
- echo
- if [[ "d$REPLY" =~ ^d[Mm]$ ]]; then
- echo "Merge accepted." >&2
- else
- echo "ERROR: Merge rejected." >&2
- cleanup
- exit 7
- fi
-fi
-
-# Sign the merge commit.
-read -p "Press 's' to sign off on the merge. " -n 1 -r >&2
-echo
-if [[ "d$REPLY" =~ ^d[Ss]$ ]]; then
- if [[ "$(git config --get user.signingkey)" == "" ]]; then
- echo "ERROR: No GPG signing key set, not signing. Set one using:" >&2
- echo "git config --global user.signingkey <key>" >&2
- cleanup
- exit 1
- else
- if ! git commit -q --gpg-sign --amend --no-edit; then
- echo "Error signing, exiting."
- cleanup
- exit 1
- fi
- fi
-else
- echo "Not signing off on merge, exiting."
- cleanup
- exit 1
-fi
-
-# Clean up temporary branches, and put the result in $BRANCH.
-git checkout -q "$BRANCH"
-git reset -q --hard pull/"$PULL"/local-merge
-cleanup
-
-# Push the result.
-read -p "Type 'push' to push the result to $HOST:$REPO, branch $BRANCH. " -r >&2
-if [[ "d$REPLY" =~ ^d[Pp][Uu][Ss][Hh]$ ]]; then
- git push "$HOST":"$REPO" refs/heads/"$BRANCH"
-fi
diff --git a/contrib/devtools/security-check.py b/contrib/devtools/security-check.py
index e96eaa9c38..fe5dc9ad89 100755
--- a/contrib/devtools/security-check.py
+++ b/contrib/devtools/security-check.py
@@ -1,7 +1,7 @@
#!/usr/bin/python2
'''
Perform basic ELF security checks on a series of executables.
-Exit status will be 0 if succesful, and the program will be silent.
+Exit status will be 0 if successful, and the program will be silent.
Otherwise the exit status will be 1 and it will log which executables failed which checks.
Needs `readelf` (for ELF) and `objdump` (for PE).
'''
diff --git a/contrib/gitian-descriptors/gitian-linux.yml b/contrib/gitian-descriptors/gitian-linux.yml
index ee852ff138..04b9b0177c 100644
--- a/contrib/gitian-descriptors/gitian-linux.yml
+++ b/contrib/gitian-descriptors/gitian-linux.yml
@@ -15,6 +15,8 @@ packages:
- "faketime"
- "bsdmainutils"
- "binutils-gold"
+- "ca-certificates"
+- "python"
reference_datetime: "2016-01-01 00:00:00"
remotes:
- "url": "https://github.com/bitcoin/bitcoin.git"
diff --git a/contrib/gitian-descriptors/gitian-osx.yml b/contrib/gitian-descriptors/gitian-osx.yml
index 7e40803a07..c2d8b9baaa 100644
--- a/contrib/gitian-descriptors/gitian-osx.yml
+++ b/contrib/gitian-descriptors/gitian-osx.yml
@@ -18,6 +18,8 @@ packages:
- "libcap-dev"
- "libz-dev"
- "libbz2-dev"
+- "ca-certificates"
+- "python"
reference_datetime: "2016-01-01 00:00:00"
remotes:
- "url": "https://github.com/bitcoin/bitcoin.git"
diff --git a/contrib/gitian-descriptors/gitian-win.yml b/contrib/gitian-descriptors/gitian-win.yml
index c8fbe32eee..361842920d 100644
--- a/contrib/gitian-descriptors/gitian-win.yml
+++ b/contrib/gitian-descriptors/gitian-win.yml
@@ -18,6 +18,8 @@ packages:
- "g++-mingw-w64"
- "nsis"
- "zip"
+- "ca-certificates"
+- "python"
reference_datetime: "2016-01-01 00:00:00"
remotes:
- "url": "https://github.com/bitcoin/bitcoin.git"
diff --git a/doc/gitian-building.md b/doc/gitian-building.md
index 019e851696..e3fb944388 100644
--- a/doc/gitian-building.md
+++ b/doc/gitian-building.md
@@ -259,15 +259,15 @@ adduser debian sudo
Then set up LXC and the rest with the following, which is a complex jumble of settings and workarounds:
```bash
-# the version of lxc-start in Debian 7.4 needs to run as root, so make sure
+# the version of lxc-start in Debian needs to run as root, so make sure
# that the build script can execute it without providing a password
echo "%sudo ALL=NOPASSWD: /usr/bin/lxc-start" > /etc/sudoers.d/gitian-lxc
-# add cgroup for LXC
-echo "cgroup /sys/fs/cgroup cgroup defaults 0 0" >> /etc/fstab
# make /etc/rc.local script that sets up bridge between guest and host
echo '#!/bin/sh -e' > /etc/rc.local
echo 'brctl addbr br0' >> /etc/rc.local
echo 'ifconfig br0 10.0.3.2/24 up' >> /etc/rc.local
+echo 'iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE' >> /etc/rc.local
+echo 'echo 1 > /proc/sys/net/ipv4/ip_forward' >> /etc/rc.local
echo 'exit 0' >> /etc/rc.local
# make sure that USE_LXC is always set when logging in as debian,
# and configure LXC IP addresses
diff --git a/qa/rpc-tests/bip65-cltv-p2p.py b/qa/rpc-tests/bip65-cltv-p2p.py
index 5bb41df1ad..9b1fdd9350 100755
--- a/qa/rpc-tests/bip65-cltv-p2p.py
+++ b/qa/rpc-tests/bip65-cltv-p2p.py
@@ -10,7 +10,7 @@ from test_framework.mininode import CTransaction, NetworkThread
from test_framework.blocktools import create_coinbase, create_block
from test_framework.comptool import TestInstance, TestManager
from test_framework.script import CScript, OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP
-from binascii import hexlify, unhexlify
+from binascii import unhexlify
import cStringIO
import time
diff --git a/qa/rpc-tests/bip65-cltv.py b/qa/rpc-tests/bip65-cltv.py
index e90e11e6a7..f666a07c9b 100755
--- a/qa/rpc-tests/bip65-cltv.py
+++ b/qa/rpc-tests/bip65-cltv.py
@@ -9,8 +9,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-import os
-import shutil
class BIP65Test(BitcoinTestFramework):
@@ -46,7 +44,7 @@ class BIP65Test(BitcoinTestFramework):
self.nodes[2].generate(1)
self.sync_all()
if (self.nodes[0].getblockcount() != cnt + 851):
- raise AssertionFailure("Failed to mine a version=4 blocks")
+ raise AssertionError("Failed to mine a version=4 blocks")
# TODO: check that new CHECKLOCKTIMEVERIFY rules are enforced
diff --git a/qa/rpc-tests/bipdersig-p2p.py b/qa/rpc-tests/bipdersig-p2p.py
index ec1678cc2c..9118b8facf 100755
--- a/qa/rpc-tests/bipdersig-p2p.py
+++ b/qa/rpc-tests/bipdersig-p2p.py
@@ -10,7 +10,7 @@ from test_framework.mininode import CTransaction, NetworkThread
from test_framework.blocktools import create_coinbase, create_block
from test_framework.comptool import TestInstance, TestManager
from test_framework.script import CScript
-from binascii import hexlify, unhexlify
+from binascii import unhexlify
import cStringIO
import time
diff --git a/qa/rpc-tests/bipdersig.py b/qa/rpc-tests/bipdersig.py
index 5afc9ddde8..be9121c456 100755
--- a/qa/rpc-tests/bipdersig.py
+++ b/qa/rpc-tests/bipdersig.py
@@ -9,8 +9,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-import os
-import shutil
class BIP66Test(BitcoinTestFramework):
@@ -46,7 +44,7 @@ class BIP66Test(BitcoinTestFramework):
self.nodes[2].generate(1)
self.sync_all()
if (self.nodes[0].getblockcount() != cnt + 851):
- raise AssertionFailure("Failed to mine a version=3 blocks")
+ raise AssertionError("Failed to mine a version=3 blocks")
# TODO: check that new DERSIG rules are enforced
diff --git a/qa/rpc-tests/blockchain.py b/qa/rpc-tests/blockchain.py
index 673f1cc545..b0fc7b0172 100755
--- a/qa/rpc-tests/blockchain.py
+++ b/qa/rpc-tests/blockchain.py
@@ -4,19 +4,25 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
-# Test RPC calls related to blockchain state.
+# Test RPC calls related to blockchain state. Tests correspond to code in
+# rpcblockchain.cpp.
#
-import decimal
+from decimal import Decimal
from test_framework.test_framework import BitcoinTestFramework
+from test_framework.authproxy import JSONRPCException
from test_framework.util import (
initialize_chain,
assert_equal,
+ assert_raises,
+ assert_is_hex_string,
+ assert_is_hash_string,
start_nodes,
connect_nodes_bi,
)
+
class BlockchainTest(BitcoinTestFramework):
"""
Test blockchain-related RPC calls:
@@ -36,10 +42,14 @@ class BlockchainTest(BitcoinTestFramework):
self.sync_all()
def run_test(self):
+ self._test_gettxoutsetinfo()
+ self._test_getblockheader()
+
+ def _test_gettxoutsetinfo(self):
node = self.nodes[0]
res = node.gettxoutsetinfo()
- assert_equal(res[u'total_amount'], decimal.Decimal('8725.00000000'))
+ assert_equal(res[u'total_amount'], Decimal('8725.00000000'))
assert_equal(res[u'transactions'], 200)
assert_equal(res[u'height'], 200)
assert_equal(res[u'txouts'], 200)
@@ -47,6 +57,30 @@ class BlockchainTest(BitcoinTestFramework):
assert_equal(len(res[u'bestblock']), 64)
assert_equal(len(res[u'hash_serialized']), 64)
+ def _test_getblockheader(self):
+ node = self.nodes[0]
+
+ assert_raises(
+ JSONRPCException, lambda: node.getblockheader('nonsense'))
+
+ besthash = node.getbestblockhash()
+ secondbesthash = node.getblockhash(199)
+ header = node.getblockheader(besthash)
+
+ assert_equal(header['hash'], besthash)
+ assert_equal(header['height'], 200)
+ assert_equal(header['confirmations'], 1)
+ assert_equal(header['previousblockhash'], secondbesthash)
+ assert_is_hex_string(header['chainwork'])
+ assert_is_hash_string(header['hash'])
+ assert_is_hash_string(header['previousblockhash'])
+ assert_is_hash_string(header['merkleroot'])
+ assert_is_hash_string(header['bits'], length=None)
+ assert isinstance(header['time'], int)
+ assert isinstance(header['mediantime'], int)
+ assert isinstance(header['nonce'], int)
+ assert isinstance(header['version'], int)
+ assert isinstance(header['difficulty'], Decimal)
if __name__ == '__main__':
BlockchainTest().main()
diff --git a/qa/rpc-tests/disablewallet.py b/qa/rpc-tests/disablewallet.py
index 2112097af1..6964348d55 100755
--- a/qa/rpc-tests/disablewallet.py
+++ b/qa/rpc-tests/disablewallet.py
@@ -10,6 +10,7 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
+
class DisableWalletTest (BitcoinTestFramework):
def setup_chain(self):
diff --git a/qa/rpc-tests/forknotify.py b/qa/rpc-tests/forknotify.py
index 2deede0c38..20e6ce9619 100755
--- a/qa/rpc-tests/forknotify.py
+++ b/qa/rpc-tests/forknotify.py
@@ -9,8 +9,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-import os
-import shutil
class ForkNotifyTest(BitcoinTestFramework):
diff --git a/qa/rpc-tests/fundrawtransaction.py b/qa/rpc-tests/fundrawtransaction.py
index dda9166151..0287965b97 100755
--- a/qa/rpc-tests/fundrawtransaction.py
+++ b/qa/rpc-tests/fundrawtransaction.py
@@ -5,8 +5,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-from pprint import pprint
-from time import sleep
# Create one-input, one-output, no-fee transaction:
class RawTransactionsTest(BitcoinTestFramework):
@@ -53,11 +51,11 @@ class RawTransactionsTest(BitcoinTestFramework):
watchonly_amount = 200
self.nodes[3].importpubkey(watchonly_pubkey, "", True)
watchonly_txid = self.nodes[0].sendtoaddress(watchonly_address, watchonly_amount)
- self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), watchonly_amount / 10);
+ self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), watchonly_amount / 10)
- self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.5);
- self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.0);
- self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),5.0);
+ self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.5)
+ self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0)
+ self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 5.0)
self.sync_all()
self.nodes[0].generate(1)
@@ -130,7 +128,7 @@ class RawTransactionsTest(BitcoinTestFramework):
for aUtx in listunspent:
if aUtx['amount'] == 5.0:
utx = aUtx
- break;
+ break
assert_equal(utx!=False, True)
@@ -159,7 +157,7 @@ class RawTransactionsTest(BitcoinTestFramework):
for aUtx in listunspent:
if aUtx['amount'] == 5.0:
utx = aUtx
- break;
+ break
assert_equal(utx!=False, True)
@@ -189,7 +187,7 @@ class RawTransactionsTest(BitcoinTestFramework):
for aUtx in listunspent:
if aUtx['amount'] == 1.0:
utx = aUtx
- break;
+ break
assert_equal(utx!=False, True)
@@ -314,7 +312,7 @@ class RawTransactionsTest(BitcoinTestFramework):
except JSONRPCException,e:
errorString = e.error['message']
- assert_equal("Insufficient" in errorString, True);
+ assert("Insufficient" in errorString)
@@ -326,11 +324,11 @@ class RawTransactionsTest(BitcoinTestFramework):
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
#create same transaction over sendtoaddress
- txId = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1.1);
+ txId = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1.1)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
#compare fee
- feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
+ feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################
@@ -341,11 +339,11 @@ class RawTransactionsTest(BitcoinTestFramework):
rawTx = self.nodes[0].createrawtransaction(inputs, outputs)
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
#create same transaction over sendtoaddress
- txId = self.nodes[0].sendmany("", outputs);
+ txId = self.nodes[0].sendmany("", outputs)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
#compare fee
- feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
+ feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################
@@ -368,11 +366,11 @@ class RawTransactionsTest(BitcoinTestFramework):
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
#create same transaction over sendtoaddress
- txId = self.nodes[0].sendtoaddress(mSigObj, 1.1);
+ txId = self.nodes[0].sendtoaddress(mSigObj, 1.1)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
#compare fee
- feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
+ feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################
@@ -401,11 +399,11 @@ class RawTransactionsTest(BitcoinTestFramework):
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
#create same transaction over sendtoaddress
- txId = self.nodes[0].sendtoaddress(mSigObj, 1.1);
+ txId = self.nodes[0].sendtoaddress(mSigObj, 1.1)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
#compare fee
- feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
+ feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################
@@ -424,7 +422,7 @@ class RawTransactionsTest(BitcoinTestFramework):
# send 1.2 BTC to msig addr
- txId = self.nodes[0].sendtoaddress(mSigObj, 1.2);
+ txId = self.nodes[0].sendtoaddress(mSigObj, 1.2)
self.sync_all()
self.nodes[1].generate(1)
self.sync_all()
@@ -466,7 +464,7 @@ class RawTransactionsTest(BitcoinTestFramework):
error = False
try:
- self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.2);
+ self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.2)
except:
error = True
assert(error)
@@ -496,13 +494,13 @@ class RawTransactionsTest(BitcoinTestFramework):
###############################################
#empty node1, send some small coins from node0 to node1
- self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True);
+ self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
for i in range(0,20):
- self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01);
+ self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
@@ -514,11 +512,11 @@ class RawTransactionsTest(BitcoinTestFramework):
fundedTx = self.nodes[1].fundrawtransaction(rawTx)
#create same transaction over sendtoaddress
- txId = self.nodes[1].sendmany("", outputs);
+ txId = self.nodes[1].sendmany("", outputs)
signedFee = self.nodes[1].getrawmempool(True)[txId]['fee']
#compare fee
- feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
+ feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance*19) #~19 inputs
@@ -527,13 +525,13 @@ class RawTransactionsTest(BitcoinTestFramework):
#############################################
#again, empty node1, send some small coins from node0 to node1
- self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True);
+ self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
for i in range(0,20):
- self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01);
+ self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
diff --git a/qa/rpc-tests/getchaintips.py b/qa/rpc-tests/getchaintips.py
index e8d2d8f3fd..dd260836bb 100755
--- a/qa/rpc-tests/getchaintips.py
+++ b/qa/rpc-tests/getchaintips.py
@@ -23,8 +23,8 @@ class GetChainTipsTest (BitcoinTestFramework):
# Split the network and build two chains of different lengths.
self.split_network ()
- self.nodes[0].generate(10);
- self.nodes[2].generate(20);
+ self.nodes[0].generate(10)
+ self.nodes[2].generate(20)
self.sync_all ()
tips = self.nodes[1].getchaintips ()
diff --git a/qa/rpc-tests/httpbasics.py b/qa/rpc-tests/httpbasics.py
index 5b9fa00976..eb548aee9d 100755
--- a/qa/rpc-tests/httpbasics.py
+++ b/qa/rpc-tests/httpbasics.py
@@ -36,13 +36,13 @@ class HTTPBasicsTest (BitcoinTestFramework):
conn = httplib.HTTPConnection(url.hostname, url.port)
conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
- out1 = conn.getresponse().read();
+ out1 = conn.getresponse().read()
assert_equal('"error":null' in out1, True)
assert_equal(conn.sock!=None, True) #according to http/1.1 connection must still be open!
#send 2nd request without closing connection
conn.request('POST', '/', '{"method": "getchaintips"}', headers)
- out2 = conn.getresponse().read();
+ out2 = conn.getresponse().read()
assert_equal('"error":null' in out1, True) #must also response with a correct json-rpc message
assert_equal(conn.sock!=None, True) #according to http/1.1 connection must still be open!
conn.close()
@@ -53,13 +53,13 @@ class HTTPBasicsTest (BitcoinTestFramework):
conn = httplib.HTTPConnection(url.hostname, url.port)
conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
- out1 = conn.getresponse().read();
+ out1 = conn.getresponse().read()
assert_equal('"error":null' in out1, True)
assert_equal(conn.sock!=None, True) #according to http/1.1 connection must still be open!
#send 2nd request without closing connection
conn.request('POST', '/', '{"method": "getchaintips"}', headers)
- out2 = conn.getresponse().read();
+ out2 = conn.getresponse().read()
assert_equal('"error":null' in out1, True) #must also response with a correct json-rpc message
assert_equal(conn.sock!=None, True) #according to http/1.1 connection must still be open!
conn.close()
@@ -70,7 +70,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
conn = httplib.HTTPConnection(url.hostname, url.port)
conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
- out1 = conn.getresponse().read();
+ out1 = conn.getresponse().read()
assert_equal('"error":null' in out1, True)
assert_equal(conn.sock!=None, False) #now the connection must be closed after the response
@@ -82,7 +82,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
conn = httplib.HTTPConnection(urlNode1.hostname, urlNode1.port)
conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
- out1 = conn.getresponse().read();
+ out1 = conn.getresponse().read()
assert_equal('"error":null' in out1, True)
#node2 (third node) is running with standard keep-alive parameters which means keep-alive is on
@@ -93,7 +93,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
conn = httplib.HTTPConnection(urlNode2.hostname, urlNode2.port)
conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
- out1 = conn.getresponse().read();
+ out1 = conn.getresponse().read()
assert_equal('"error":null' in out1, True)
assert_equal(conn.sock!=None, True) #connection must be closed because bitcoind should use keep-alive by default
diff --git a/qa/rpc-tests/invalidblockrequest.py b/qa/rpc-tests/invalidblockrequest.py
index a74ecb1288..5f6b1abed4 100755
--- a/qa/rpc-tests/invalidblockrequest.py
+++ b/qa/rpc-tests/invalidblockrequest.py
@@ -7,9 +7,7 @@
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
from test_framework.comptool import TestManager, TestInstance, RejectResult
-from test_framework.mininode import *
from test_framework.blocktools import *
-import logging
import copy
import time
diff --git a/qa/rpc-tests/invalidtxrequest.py b/qa/rpc-tests/invalidtxrequest.py
index d17b3d0980..b2c0d145f9 100755
--- a/qa/rpc-tests/invalidtxrequest.py
+++ b/qa/rpc-tests/invalidtxrequest.py
@@ -5,12 +5,8 @@
#
from test_framework.test_framework import ComparisonTestFramework
-from test_framework.util import *
from test_framework.comptool import TestManager, TestInstance, RejectResult
-from test_framework.mininode import *
from test_framework.blocktools import *
-import logging
-import copy
import time
diff --git a/qa/rpc-tests/keypool.py b/qa/rpc-tests/keypool.py
index c300bbc57e..95d0d6832a 100755
--- a/qa/rpc-tests/keypool.py
+++ b/qa/rpc-tests/keypool.py
@@ -70,9 +70,11 @@ class KeyPoolTest(BitcoinTestFramework):
assert(e.error['code']==-12)
# refill keypool with three new addresses
- nodes[0].walletpassphrase('test', 12000)
+ nodes[0].walletpassphrase('test', 1)
nodes[0].keypoolrefill(3)
- nodes[0].walletlock()
+ # test walletpassphrase timeout
+ time.sleep(1.1)
+ assert_equal(nodes[0].getwalletinfo()["unlocked_until"], 0)
# drain them by mining
nodes[0].generate(1)
diff --git a/qa/rpc-tests/listtransactions.py b/qa/rpc-tests/listtransactions.py
index 8a1e3dc4bc..45ede8f040 100755
--- a/qa/rpc-tests/listtransactions.py
+++ b/qa/rpc-tests/listtransactions.py
@@ -7,7 +7,15 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
+from test_framework.mininode import CTransaction
+import cStringIO
+import binascii
+def txFromHex(hexstring):
+ tx = CTransaction()
+ f = cStringIO.StringIO(binascii.unhexlify(hexstring))
+ tx.deserialize(f)
+ return tx
def check_array_result(object_array, to_match, expected):
"""
@@ -32,6 +40,11 @@ def check_array_result(object_array, to_match, expected):
class ListTransactionsTest(BitcoinTestFramework):
+ def setup_nodes(self):
+ #This test requires mocktime
+ enable_mocktime()
+ return start_nodes(4, self.options.tmpdir)
+
def run_test(self):
# Simple send, 0 to 1:
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
@@ -103,6 +116,107 @@ class ListTransactionsTest(BitcoinTestFramework):
{"category":"receive","amount":Decimal("0.1")},
{"txid":txid, "account" : "watchonly"} )
+ self.run_rbf_opt_in_test()
+
+ # Check that the opt-in-rbf flag works properly, for sent and received
+ # transactions.
+ def run_rbf_opt_in_test(self):
+ # Check whether a transaction signals opt-in RBF itself
+ def is_opt_in(node, txid):
+ rawtx = node.getrawtransaction(txid, 1)
+ for x in rawtx["vin"]:
+ if x["sequence"] < 0xfffffffe:
+ return True
+ return False
+
+ # Find an unconfirmed output matching a certain txid
+ def get_unconfirmed_utxo_entry(node, txid_to_match):
+ utxo = node.listunspent(0, 0)
+ for i in utxo:
+ if i["txid"] == txid_to_match:
+ return i
+ return None
+
+ # 1. Chain a few transactions that don't opt-in.
+ txid_1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1)
+ assert(not is_opt_in(self.nodes[0], txid_1))
+ check_array_result(self.nodes[0].listtransactions(), {"txid": txid_1}, {"bip125-replaceable":"no"})
+ sync_mempools(self.nodes)
+ check_array_result(self.nodes[1].listtransactions(), {"txid": txid_1}, {"bip125-replaceable":"no"})
+
+ # Tx2 will build off txid_1, still not opting in to RBF.
+ utxo_to_use = get_unconfirmed_utxo_entry(self.nodes[1], txid_1)
+
+ # Create tx2 using createrawtransaction
+ inputs = [{"txid":utxo_to_use["txid"], "vout":utxo_to_use["vout"]}]
+ outputs = {self.nodes[0].getnewaddress(): 0.999}
+ tx2 = self.nodes[1].createrawtransaction(inputs, outputs)
+ tx2_signed = self.nodes[1].signrawtransaction(tx2)["hex"]
+ txid_2 = self.nodes[1].sendrawtransaction(tx2_signed)
+
+ # ...and check the result
+ assert(not is_opt_in(self.nodes[1], txid_2))
+ check_array_result(self.nodes[1].listtransactions(), {"txid": txid_2}, {"bip125-replaceable":"no"})
+ sync_mempools(self.nodes)
+ check_array_result(self.nodes[0].listtransactions(), {"txid": txid_2}, {"bip125-replaceable":"no"})
+
+ # Tx3 will opt-in to RBF
+ utxo_to_use = get_unconfirmed_utxo_entry(self.nodes[0], txid_2)
+ inputs = [{"txid": txid_2, "vout":utxo_to_use["vout"]}]
+ outputs = {self.nodes[1].getnewaddress(): 0.998}
+ tx3 = self.nodes[0].createrawtransaction(inputs, outputs)
+ tx3_modified = txFromHex(tx3)
+ tx3_modified.vin[0].nSequence = 0
+ tx3 = binascii.hexlify(tx3_modified.serialize()).decode('utf-8')
+ tx3_signed = self.nodes[0].signrawtransaction(tx3)['hex']
+ txid_3 = self.nodes[0].sendrawtransaction(tx3_signed)
+
+ assert(is_opt_in(self.nodes[0], txid_3))
+ check_array_result(self.nodes[0].listtransactions(), {"txid": txid_3}, {"bip125-replaceable":"yes"})
+ sync_mempools(self.nodes)
+ check_array_result(self.nodes[1].listtransactions(), {"txid": txid_3}, {"bip125-replaceable":"yes"})
+
+ # Tx4 will chain off tx3. Doesn't signal itself, but depends on one
+ # that does.
+ utxo_to_use = get_unconfirmed_utxo_entry(self.nodes[1], txid_3)
+ inputs = [{"txid": txid_3, "vout":utxo_to_use["vout"]}]
+ outputs = {self.nodes[0].getnewaddress(): 0.997}
+ tx4 = self.nodes[1].createrawtransaction(inputs, outputs)
+ tx4_signed = self.nodes[1].signrawtransaction(tx4)["hex"]
+ txid_4 = self.nodes[1].sendrawtransaction(tx4_signed)
+
+ assert(not is_opt_in(self.nodes[1], txid_4))
+ check_array_result(self.nodes[1].listtransactions(), {"txid": txid_4}, {"bip125-replaceable":"yes"})
+ sync_mempools(self.nodes)
+ check_array_result(self.nodes[0].listtransactions(), {"txid": txid_4}, {"bip125-replaceable":"yes"})
+
+ # Replace tx3, and check that tx4 becomes unknown
+ tx3_b = tx3_modified
+ tx3_b.vout[0].nValue -= 0.004*100000000 # bump the fee
+ tx3_b = binascii.hexlify(tx3_b.serialize()).decode('utf-8')
+ tx3_b_signed = self.nodes[0].signrawtransaction(tx3_b)['hex']
+ txid_3b = self.nodes[0].sendrawtransaction(tx3_b_signed, True)
+ assert(is_opt_in(self.nodes[0], txid_3b))
+
+ check_array_result(self.nodes[0].listtransactions(), {"txid": txid_4}, {"bip125-replaceable":"unknown"})
+ sync_mempools(self.nodes)
+ check_array_result(self.nodes[1].listtransactions(), {"txid": txid_4}, {"bip125-replaceable":"unknown"})
+
+ # Check gettransaction as well:
+ for n in self.nodes[0:2]:
+ assert_equal(n.gettransaction(txid_1)["bip125-replaceable"], "no")
+ assert_equal(n.gettransaction(txid_2)["bip125-replaceable"], "no")
+ assert_equal(n.gettransaction(txid_3)["bip125-replaceable"], "yes")
+ assert_equal(n.gettransaction(txid_3b)["bip125-replaceable"], "yes")
+ assert_equal(n.gettransaction(txid_4)["bip125-replaceable"], "unknown")
+
+ # After mining a transaction, it's no longer BIP125-replaceable
+ self.nodes[0].generate(1)
+ assert(txid_3b not in self.nodes[0].getrawmempool())
+ assert_equal(self.nodes[0].gettransaction(txid_3b)["bip125-replaceable"], "no")
+ assert_equal(self.nodes[0].gettransaction(txid_4)["bip125-replaceable"], "unknown")
+
+
if __name__ == '__main__':
ListTransactionsTest().main()
diff --git a/qa/rpc-tests/mempool_limit.py b/qa/rpc-tests/mempool_limit.py
index a8cf6360ee..7914ceea22 100755
--- a/qa/rpc-tests/mempool_limit.py
+++ b/qa/rpc-tests/mempool_limit.py
@@ -48,7 +48,7 @@ class MempoolLimitTest(BitcoinTestFramework):
# by now, the tx should be evicted, check confirmation state
assert(txid not in self.nodes[0].getrawmempool())
- txdata = self.nodes[0].gettransaction(txid);
+ txdata = self.nodes[0].gettransaction(txid)
assert(txdata['confirmations'] == 0) #confirmation should still be 0
if __name__ == '__main__':
diff --git a/qa/rpc-tests/mempool_packages.py b/qa/rpc-tests/mempool_packages.py
index 063308d394..47c1028b9f 100755
--- a/qa/rpc-tests/mempool_packages.py
+++ b/qa/rpc-tests/mempool_packages.py
@@ -87,9 +87,18 @@ class MempoolPackagesTest(BitcoinTestFramework):
print "too-long-ancestor-chain successfully rejected"
# Check that prioritising a tx before it's added to the mempool works
+ # First clear the mempool by mining a block.
self.nodes[0].generate(1)
+ sync_blocks(self.nodes)
+ assert_equal(len(self.nodes[0].getrawmempool()), 0)
+ # Prioritise a transaction that has been mined, then add it back to the
+ # mempool by using invalidateblock.
self.nodes[0].prioritisetransaction(chain[-1], 0, 2000)
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
+ # Keep node1's tip synced with node0
+ self.nodes[1].invalidateblock(self.nodes[1].getbestblockhash())
+
+ # Now check that the transaction is in the mempool, with the right modified fee
mempool = self.nodes[0].getrawmempool(True)
descendant_fees = 0
diff --git a/qa/rpc-tests/mempool_reorg.py b/qa/rpc-tests/mempool_reorg.py
index d96a3f8266..ea48e38451 100755
--- a/qa/rpc-tests/mempool_reorg.py
+++ b/qa/rpc-tests/mempool_reorg.py
@@ -10,8 +10,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-import os
-import shutil
# Create one-input, one-output, no-fee transaction:
class MempoolCoinbaseTest(BitcoinTestFramework):
@@ -25,7 +23,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
self.nodes.append(start_node(1, self.options.tmpdir, args))
connect_nodes(self.nodes[1], 0)
self.is_network_split = False
- self.sync_all
+ self.sync_all()
def create_tx(self, from_txid, to_address, amount):
inputs = [{ "txid" : from_txid, "vout" : 0}]
@@ -87,11 +85,11 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
self.sync_all()
- assert_equal(set(self.nodes[0].getrawmempool()), set([ spend_101_id, spend_102_1_id, timelock_tx_id ]))
+ assert_equal(set(self.nodes[0].getrawmempool()), {spend_101_id, spend_102_1_id, timelock_tx_id})
for node in self.nodes:
node.invalidateblock(last_block[0])
- assert_equal(set(self.nodes[0].getrawmempool()), set([ spend_101_id, spend_102_1_id, spend_103_1_id ]))
+ assert_equal(set(self.nodes[0].getrawmempool()), {spend_101_id, spend_102_1_id, spend_103_1_id})
# Use invalidateblock to re-org back and make all those coinbase spends
# immature/invalid:
diff --git a/qa/rpc-tests/mempool_resurrect_test.py b/qa/rpc-tests/mempool_resurrect_test.py
index 750953ee5e..14ca44310f 100755
--- a/qa/rpc-tests/mempool_resurrect_test.py
+++ b/qa/rpc-tests/mempool_resurrect_test.py
@@ -10,8 +10,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-import os
-import shutil
# Create one-input, one-output, no-fee transaction:
class MempoolCoinbaseTest(BitcoinTestFramework):
diff --git a/qa/rpc-tests/mempool_spendcoinbase.py b/qa/rpc-tests/mempool_spendcoinbase.py
index 35ce76e244..4a6e436097 100755
--- a/qa/rpc-tests/mempool_spendcoinbase.py
+++ b/qa/rpc-tests/mempool_spendcoinbase.py
@@ -15,8 +15,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-import os
-import shutil
# Create one-input, one-output, no-fee transaction:
class MempoolSpendCoinbaseTest(BitcoinTestFramework):
diff --git a/qa/rpc-tests/merkle_blocks.py b/qa/rpc-tests/merkle_blocks.py
index 08e5db45fa..ed9a9b01bd 100755
--- a/qa/rpc-tests/merkle_blocks.py
+++ b/qa/rpc-tests/merkle_blocks.py
@@ -9,8 +9,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-import os
-import shutil
class MerkleBlockTest(BitcoinTestFramework):
@@ -72,7 +70,7 @@ class MerkleBlockTest(BitcoinTestFramework):
txid_spent = txin_spent["txid"]
txid_unspent = txid1 if txin_spent["txid"] != txid1 else txid2
- # We cant find the block from a fully-spent tx
+ # We can't find the block from a fully-spent tx
assert_raises(JSONRPCException, self.nodes[2].gettxoutproof, [txid_spent])
# ...but we can if we specify the block
assert_equal(self.nodes[2].verifytxoutproof(self.nodes[2].gettxoutproof([txid_spent], blockhash)), [txid_spent])
diff --git a/qa/rpc-tests/nodehandling.py b/qa/rpc-tests/nodehandling.py
index 3239dd0339..c6c8c436e9 100755
--- a/qa/rpc-tests/nodehandling.py
+++ b/qa/rpc-tests/nodehandling.py
@@ -9,7 +9,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-import base64
try:
import http.client as httplib
@@ -54,7 +53,7 @@ class NodeHandlingTest (BitcoinTestFramework):
self.nodes[2].setban("127.0.0.0/24", "add")
self.nodes[2].setban("192.168.0.1", "add", 1) #ban for 1 seconds
self.nodes[2].setban("2001:4d48:ac57:400:cacf:e9ff:fe1d:9c63/19", "add", 1000) #ban for 1000 seconds
- listBeforeShutdown = self.nodes[2].listbanned();
+ listBeforeShutdown = self.nodes[2].listbanned()
assert_equal("192.168.0.1/32", listBeforeShutdown[2]['address']) #must be here
time.sleep(2) #make 100% sure we expired 192.168.0.1 node time
@@ -62,7 +61,7 @@ class NodeHandlingTest (BitcoinTestFramework):
stop_node(self.nodes[2], 2)
self.nodes[2] = start_node(2, self.options.tmpdir)
- listAfterShutdown = self.nodes[2].listbanned();
+ listAfterShutdown = self.nodes[2].listbanned()
assert_equal("127.0.0.0/24", listAfterShutdown[0]['address'])
assert_equal("127.0.0.0/32", listAfterShutdown[1]['address'])
assert_equal("/19" in listAfterShutdown[2]['address'], True)
diff --git a/qa/rpc-tests/p2p-fullblocktest.py b/qa/rpc-tests/p2p-fullblocktest.py
index a6525e6793..28cc2474f1 100755
--- a/qa/rpc-tests/p2p-fullblocktest.py
+++ b/qa/rpc-tests/p2p-fullblocktest.py
@@ -8,14 +8,10 @@
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
from test_framework.comptool import TestManager, TestInstance, RejectResult
-from test_framework.mininode import *
from test_framework.blocktools import *
-import logging
-import copy
import time
-import numbers
from test_framework.key import CECKey
-from test_framework.script import CScript, CScriptOp, SignatureHash, SIGHASH_ALL, OP_TRUE, OP_FALSE
+from test_framework.script import CScript, SignatureHash, SIGHASH_ALL, OP_TRUE, OP_FALSE
class PreviousSpendableOutput(object):
def __init__(self, tx = CTransaction(), n = -1):
diff --git a/qa/rpc-tests/proxy_test.py b/qa/rpc-tests/proxy_test.py
index 3623c16162..7f77e664d2 100755
--- a/qa/rpc-tests/proxy_test.py
+++ b/qa/rpc-tests/proxy_test.py
@@ -3,9 +3,6 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
import socket
-import traceback, sys
-from binascii import hexlify
-import time, os
from test_framework.socks5 import Socks5Configuration, Socks5Command, Socks5Server, AddressType
from test_framework.test_framework import BitcoinTestFramework
@@ -34,7 +31,8 @@ addnode connect to onion
addnode connect to generic DNS name
'''
-class ProxyTest(BitcoinTestFramework):
+
+class ProxyTest(BitcoinTestFramework):
def __init__(self):
# Create two proxies on different ports
# ... one unauthenticated
diff --git a/qa/rpc-tests/pruning.py b/qa/rpc-tests/pruning.py
index 26ae4af010..b0f4b88aee 100755
--- a/qa/rpc-tests/pruning.py
+++ b/qa/rpc-tests/pruning.py
@@ -13,7 +13,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-import os.path
def calc_usage(blockdir):
return sum(os.path.getsize(blockdir+f) for f in os.listdir(blockdir) if os.path.isfile(blockdir+f))/(1024*1024)
diff --git a/qa/rpc-tests/rawtransactions.py b/qa/rpc-tests/rawtransactions.py
index d77b41979b..dd9e5e28a5 100755
--- a/qa/rpc-tests/rawtransactions.py
+++ b/qa/rpc-tests/rawtransactions.py
@@ -10,8 +10,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-from pprint import pprint
-from time import sleep
# Create one-input, one-output, no-fee transaction:
class RawTransactionsTest(BitcoinTestFramework):
@@ -43,9 +41,9 @@ class RawTransactionsTest(BitcoinTestFramework):
self.sync_all()
self.nodes[0].generate(101)
self.sync_all()
- self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.5);
- self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.0);
- self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),5.0);
+ self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.5)
+ self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.0)
+ self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),5.0)
self.sync_all()
self.nodes[0].generate(5)
self.sync_all()
@@ -64,7 +62,7 @@ class RawTransactionsTest(BitcoinTestFramework):
except JSONRPCException,e:
errorString = e.error['message']
- assert_equal("Missing inputs" in errorString, True);
+ assert("Missing inputs" in errorString)
#########################
# RAW TX MULTISIG TESTS #
@@ -83,7 +81,7 @@ class RawTransactionsTest(BitcoinTestFramework):
bal = self.nodes[2].getbalance()
# send 1.2 BTC to msig adr
- txId = self.nodes[0].sendtoaddress(mSigObj, 1.2);
+ txId = self.nodes[0].sendtoaddress(mSigObj, 1.2)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
@@ -105,7 +103,7 @@ class RawTransactionsTest(BitcoinTestFramework):
mSigObj = self.nodes[2].addmultisigaddress(2, [addr1Obj['pubkey'], addr2Obj['pubkey'], addr3Obj['pubkey']])
mSigObjValid = self.nodes[2].validateaddress(mSigObj)
- txId = self.nodes[0].sendtoaddress(mSigObj, 2.2);
+ txId = self.nodes[0].sendtoaddress(mSigObj, 2.2)
decTx = self.nodes[0].gettransaction(txId)
rawTx = self.nodes[0].decoderawtransaction(decTx['hex'])
sPK = rawTx['vout'][0]['scriptPubKey']['hex']
@@ -123,7 +121,7 @@ class RawTransactionsTest(BitcoinTestFramework):
for outpoint in rawTx['vout']:
if outpoint['value'] == Decimal('2.20000000'):
vout = outpoint
- break;
+ break
bal = self.nodes[0].getbalance()
inputs = [{ "txid" : txId, "vout" : vout['n'], "scriptPubKey" : vout['scriptPubKey']['hex']}]
diff --git a/qa/rpc-tests/receivedby.py b/qa/rpc-tests/receivedby.py
index 18af0e8102..606426b394 100755
--- a/qa/rpc-tests/receivedby.py
+++ b/qa/rpc-tests/receivedby.py
@@ -53,6 +53,11 @@ def check_array_result(object_array, to_match, expected, should_not_find = False
class ReceivedByTest(BitcoinTestFramework):
+ def setup_nodes(self):
+ #This test requires mocktime
+ enable_mocktime()
+ return start_nodes(4, self.options.tmpdir)
+
def run_test(self):
'''
listreceivedbyaddress Test
diff --git a/qa/rpc-tests/reindex.py b/qa/rpc-tests/reindex.py
index d90177a029..321c2fe422 100755
--- a/qa/rpc-tests/reindex.py
+++ b/qa/rpc-tests/reindex.py
@@ -8,7 +8,6 @@
#
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-import os.path
class ReindexTest(BitcoinTestFramework):
diff --git a/qa/rpc-tests/replace-by-fee.py b/qa/rpc-tests/replace-by-fee.py
index 734db33b51..ba1956853a 100755
--- a/qa/rpc-tests/replace-by-fee.py
+++ b/qa/rpc-tests/replace-by-fee.py
@@ -54,8 +54,7 @@ def make_utxo(node, amount, confirmed=True, scriptPubKey=CScript([1])):
tx2.vout = [CTxOut(amount, scriptPubKey)]
tx2.rehash()
- tx2_hex = binascii.hexlify(tx2.serialize()).decode('utf-8')
- #print tx2_hex
+ binascii.hexlify(tx2.serialize()).decode('utf-8')
signed_tx = node.signrawtransaction(binascii.hexlify(tx2.serialize()).decode('utf-8'))
diff --git a/qa/rpc-tests/rest.py b/qa/rpc-tests/rest.py
index 682c531691..8c83536501 100755
--- a/qa/rpc-tests/rest.py
+++ b/qa/rpc-tests/rest.py
@@ -12,9 +12,7 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from struct import *
import binascii
-import json
import StringIO
-import decimal
try:
import http.client as httplib
@@ -143,9 +141,9 @@ class RESTTest (BitcoinTestFramework):
binaryRequest = b'\x01\x02'
binaryRequest += binascii.unhexlify(txid)
- binaryRequest += pack("i", n);
- binaryRequest += binascii.unhexlify(vintx);
- binaryRequest += pack("i", 0);
+ binaryRequest += pack("i", n)
+ binaryRequest += binascii.unhexlify(vintx)
+ binaryRequest += pack("i", 0)
bin_response = http_post_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'bin', binaryRequest)
output = StringIO.StringIO()
@@ -206,7 +204,7 @@ class RESTTest (BitcoinTestFramework):
json_request = '/checkmempool/'
for x in range(0, 15):
json_request += txid+'-'+str(n)+'/'
- json_request = json_request.rstrip("/");
+ json_request = json_request.rstrip("/")
response = http_post_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json', '', True)
assert_equal(response.status, 200) #must be a 500 because we exceeding the limits
@@ -254,7 +252,7 @@ class RESTTest (BitcoinTestFramework):
response_header_json = http_get_call(url.hostname, url.port, '/rest/headers/1/'+bb_hash+self.FORMAT_SEPARATOR+"json", True)
assert_equal(response_header_json.status, 200)
response_header_json_str = response_header_json.read()
- json_obj = json.loads(response_header_json_str, parse_float=decimal.Decimal)
+ json_obj = json.loads(response_header_json_str, parse_float=Decimal)
assert_equal(len(json_obj), 1) #ensure that there is one header in the json response
assert_equal(json_obj[0]['hash'], bb_hash) #request/response hash should be the same
@@ -282,7 +280,7 @@ class RESTTest (BitcoinTestFramework):
assert_equal(len(json_obj), 5) #now we should have 5 header objects
# do tx test
- tx_hash = block_json_obj['tx'][0]['txid'];
+ tx_hash = block_json_obj['tx'][0]['txid']
json_string = http_get_call(url.hostname, url.port, '/rest/tx/'+tx_hash+self.FORMAT_SEPARATOR+"json")
json_obj = json.loads(json_string)
assert_equal(json_obj['txid'], tx_hash)
diff --git a/qa/rpc-tests/rpcbind_test.py b/qa/rpc-tests/rpcbind_test.py
index 5f409ad616..10a48b5556 100755
--- a/qa/rpc-tests/rpcbind_test.py
+++ b/qa/rpc-tests/rpcbind_test.py
@@ -5,13 +5,8 @@
# Test for -rpcbind, as well as -rpcallowip and -rpcconnect
-# Add python-bitcoinrpc to module search path:
-import os
-import sys
+# TODO extend this test from the test framework (like all other tests)
-import json
-import shutil
-import subprocess
import tempfile
import traceback
diff --git a/qa/rpc-tests/sendheaders.py b/qa/rpc-tests/sendheaders.py
index 7572bc2776..172506715a 100755
--- a/qa/rpc-tests/sendheaders.py
+++ b/qa/rpc-tests/sendheaders.py
@@ -7,7 +7,6 @@
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-import time
from test_framework.blocktools import create_block, create_coinbase
'''
@@ -445,7 +444,7 @@ class SendHeadersTest(BitcoinTestFramework):
inv_node.sync_with_ping() # Make sure blocks are processed
test_node.last_getdata = None
- test_node.send_header_for_blocks(blocks);
+ test_node.send_header_for_blocks(blocks)
test_node.sync_with_ping()
# should not have received any getdata messages
with mininode_lock:
diff --git a/qa/rpc-tests/test_framework/blocktools.py b/qa/rpc-tests/test_framework/blocktools.py
index 59aa8c15cc..88f553a7f6 100644
--- a/qa/rpc-tests/test_framework/blocktools.py
+++ b/qa/rpc-tests/test_framework/blocktools.py
@@ -5,7 +5,7 @@
#
from mininode import *
-from script import CScript, CScriptOp, OP_TRUE, OP_CHECKSIG
+from script import CScript, OP_TRUE, OP_CHECKSIG
# Create a block (with regtest difficulty)
def create_block(hashprev, coinbase, nTime=None):
diff --git a/qa/rpc-tests/test_framework/script.py b/qa/rpc-tests/test_framework/script.py
index 0088876028..bf5e25fb27 100644
--- a/qa/rpc-tests/test_framework/script.py
+++ b/qa/rpc-tests/test_framework/script.py
@@ -14,7 +14,8 @@ Functionality to build scripts, as well as SignatureHash().
from __future__ import absolute_import, division, print_function, unicode_literals
-from test_framework.mininode import CTransaction, CTxOut, hash256
+from .mininode import CTransaction, CTxOut, hash256
+from binascii import hexlify
import sys
bchr = chr
@@ -24,10 +25,9 @@ if sys.version > '3':
bchr = lambda x: bytes([x])
bord = lambda x: x
-import copy
import struct
-from test_framework.bignum import bn2vch
+from .bignum import bn2vch
MAX_SCRIPT_SIZE = 10000
MAX_SCRIPT_ELEMENT_SIZE = 520
@@ -777,7 +777,7 @@ class CScript(bytes):
# need to change
def _repr(o):
if isinstance(o, bytes):
- return "x('%s')" % binascii.hexlify(o).decode('utf8')
+ return "x('%s')" % hexlify(o).decode('utf8')
else:
return repr(o)
diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py
index 0388e08115..bf89805f16 100644
--- a/qa/rpc-tests/test_framework/util.py
+++ b/qa/rpc-tests/test_framework/util.py
@@ -22,6 +22,26 @@ from .authproxy import AuthServiceProxy, JSONRPCException
COVERAGE_DIR = None
+#Set Mocktime default to OFF.
+#MOCKTIME is only needed for scripts that use the
+#cached version of the blockchain. If the cached
+#version of the blockchain is used without MOCKTIME
+#then the mempools will not sync due to IBD.
+MOCKTIME = 0
+
+def enable_mocktime():
+ #For backwared compatibility of the python scripts
+ #with previous versions of the cache, set MOCKTIME
+ #to Jan 1, 2014 + (201 * 10 * 60)
+ global MOCKTIME
+ MOCKTIME = 1388534400 + (201 * 10 * 60)
+
+def disable_mocktime():
+ global MOCKTIME
+ MOCKTIME = 0
+
+def get_mocktime():
+ return MOCKTIME
def enable_coverage(dirname):
"""Maintain a log of which RPC calls are made during testing."""
@@ -102,12 +122,12 @@ def initialize_datadir(dirname, n):
if not os.path.isdir(datadir):
os.makedirs(datadir)
with open(os.path.join(datadir, "bitcoin.conf"), 'w') as f:
- f.write("regtest=1\n");
- f.write("rpcuser=rt\n");
- f.write("rpcpassword=rt\n");
- f.write("port="+str(p2p_port(n))+"\n");
- f.write("rpcport="+str(rpc_port(n))+"\n");
- f.write("listenonion=0\n");
+ f.write("regtest=1\n")
+ f.write("rpcuser=rt\n")
+ f.write("rpcpassword=rt\n")
+ f.write("port="+str(p2p_port(n))+"\n")
+ f.write("rpcport="+str(rpc_port(n))+"\n")
+ f.write("listenonion=0\n")
return datadir
def initialize_chain(test_dir):
@@ -155,9 +175,10 @@ def initialize_chain(test_dir):
# Create a 200-block-long chain; each of the 4 nodes
# gets 25 mature blocks and 25 immature.
- # blocks are created with timestamps 10 minutes apart, starting
- # at 1 Jan 2014
- block_time = 1388534400
+ # blocks are created with timestamps 10 minutes apart
+ # starting from 2010 minutes in the past
+ enable_mocktime()
+ block_time = get_mocktime() - (201 * 10 * 60)
for i in range(2):
for peer in range(4):
for j in range(25):
@@ -170,6 +191,7 @@ def initialize_chain(test_dir):
# Shut them down, and clean up cache directories:
stop_nodes(rpcs)
wait_bitcoinds()
+ disable_mocktime()
for i in range(4):
os.remove(log_filename("cache", i, "debug.log"))
os.remove(log_filename("cache", i, "db.log"))
@@ -219,7 +241,7 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
if binary is None:
binary = os.getenv("BITCOIND", "bitcoind")
# RPC tests still depend on free transactions
- args = [ binary, "-datadir="+datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-blockprioritysize=50000" ]
+ args = [ binary, "-datadir="+datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-blockprioritysize=50000", "-mocktime="+str(get_mocktime()) ]
if extra_args is not None: args.extend(extra_args)
bitcoind_processes[i] = subprocess.Popen(args)
devnull = open(os.devnull, "w")
@@ -407,6 +429,23 @@ def assert_raises(exc, fun, *args, **kwds):
else:
raise AssertionError("No exception raised")
+def assert_is_hex_string(string):
+ try:
+ int(string, 16)
+ except Exception as e:
+ raise AssertionError(
+ "Couldn't interpret %r as hexadecimal; raised: %s" % (string, e))
+
+def assert_is_hash_string(string, length=64):
+ if not isinstance(string, basestring):
+ raise AssertionError("Expected a string, got type %r" % type(string))
+ elif length and len(string) != length:
+ raise AssertionError(
+ "String of length %d expected; got %d" % (length, len(string)))
+ elif not re.match('[abcdef0-9]+$', string):
+ raise AssertionError(
+ "String %r contains invalid characters for a hash." % string)
+
def satoshi_round(amount):
return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN)
diff --git a/qa/rpc-tests/txn_clone.py b/qa/rpc-tests/txn_clone.py
index bad090bcb4..3092f09ecb 100755
--- a/qa/rpc-tests/txn_clone.py
+++ b/qa/rpc-tests/txn_clone.py
@@ -8,11 +8,7 @@
#
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.authproxy import AuthServiceProxy, JSONRPCException
-from decimal import Decimal
from test_framework.util import *
-import os
-import shutil
class TxnMallTest(BitcoinTestFramework):
diff --git a/qa/rpc-tests/txn_doublespend.py b/qa/rpc-tests/txn_doublespend.py
index 05a3a34788..8d7f6e505d 100755
--- a/qa/rpc-tests/txn_doublespend.py
+++ b/qa/rpc-tests/txn_doublespend.py
@@ -9,9 +9,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-from decimal import Decimal
-import os
-import shutil
class TxnMallTest(BitcoinTestFramework):
diff --git a/qa/rpc-tests/wallet.py b/qa/rpc-tests/wallet.py
index 43ec621a40..43ba1d977a 100755
--- a/qa/rpc-tests/wallet.py
+++ b/qa/rpc-tests/wallet.py
@@ -3,7 +3,6 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
-
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
@@ -145,7 +144,7 @@ class WalletTest (BitcoinTestFramework):
sync_blocks(self.nodes)
relayed = self.nodes[0].resendwallettransactions()
- assert_equal(set(relayed), set([txid1, txid2]))
+ assert_equal(set(relayed), {txid1, txid2})
sync_mempools(self.nodes)
assert(txid1 in self.nodes[3].getrawmempool())
@@ -265,6 +264,7 @@ class WalletTest (BitcoinTestFramework):
'-salvagewallet',
]
for m in maintenance:
+ print "check " + m
stop_nodes(self.nodes)
wait_bitcoinds()
self.nodes = start_nodes(3, self.options.tmpdir, [[m]] * 3)
diff --git a/qa/rpc-tests/zmq_test.py b/qa/rpc-tests/zmq_test.py
index bcb132321a..88532541ab 100755
--- a/qa/rpc-tests/zmq_test.py
+++ b/qa/rpc-tests/zmq_test.py
@@ -11,7 +11,6 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
import zmq
import binascii
-from test_framework.mininode import hash256
try:
import http.client as httplib
@@ -42,7 +41,7 @@ class ZMQTest (BitcoinTestFramework):
def run_test(self):
self.sync_all()
- genhashes = self.nodes[0].generate(1);
+ genhashes = self.nodes[0].generate(1)
self.sync_all()
print "listen..."
@@ -58,7 +57,7 @@ class ZMQTest (BitcoinTestFramework):
assert_equal(genhashes[0], blkhash) #blockhash from generate must be equal to the hash received over zmq
n = 10
- genhashes = self.nodes[1].generate(n);
+ genhashes = self.nodes[1].generate(n)
self.sync_all()
zmqHashes = []
@@ -76,7 +75,7 @@ class ZMQTest (BitcoinTestFramework):
hashRPC = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.0)
self.sync_all()
- #now we should receive a zmq msg because the tx was broadcastet
+ # now we should receive a zmq msg because the tx was broadcast
msg = self.zmqSubSocket.recv_multipart()
topic = str(msg[0])
body = msg[1]
diff --git a/share/setup.nsi.in b/share/setup.nsi.in
index 6c0e895bb1..62db88c271 100644
--- a/share/setup.nsi.in
+++ b/share/setup.nsi.in
@@ -7,7 +7,7 @@ SetCompressor /SOLID lzma
!define REGKEY "SOFTWARE\$(^Name)"
!define VERSION @CLIENT_VERSION_MAJOR@.@CLIENT_VERSION_MINOR@.@CLIENT_VERSION_REVISION@
!define COMPANY "Bitcoin Core project"
-!define URL http://www.bitcoin.org/
+!define URL https://bitcoincore.org/
# MUI Symbol Definitions
!define MUI_ICON "@abs_top_srcdir@/share/pixmaps/bitcoin.ico"
diff --git a/src/Makefile.am b/src/Makefile.am
index 74ffc7e2c0..948d12424f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -122,6 +122,7 @@ BITCOIN_CORE_H = \
noui.h \
policy/fees.h \
policy/policy.h \
+ policy/rbf.h \
pow.h \
prevector.h \
primitives/block.h \
@@ -240,6 +241,7 @@ libbitcoin_wallet_a_SOURCES = \
wallet/wallet.cpp \
wallet/wallet_ismine.cpp \
wallet/walletdb.cpp \
+ policy/rbf.cpp \
$(BITCOIN_CORE_H)
# crypto primitives library
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 9cf99492c9..b962f6ac0a 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -92,7 +92,6 @@ public:
pchMessageStart[3] = 0xd9;
vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
nDefaultPort = 8333;
- nMaxTipAge = 24 * 60 * 60;
nPruneAfterHeight = 100000;
genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
@@ -169,7 +168,6 @@ public:
pchMessageStart[3] = 0x07;
vAlertPubKey = ParseHex("04302390343f91cc401d56d68b123028bf52e5fca1939df127f63c6467cdf9c8e2c14b61104cf817d0b780da337893ecc4aaff1309e536162dabbdb45200ca2b0a");
nDefaultPort = 18333;
- nMaxTipAge = 0x7fffffff;
nPruneAfterHeight = 1000;
genesis = CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50 * COIN);
@@ -232,7 +230,6 @@ public:
pchMessageStart[1] = 0xbf;
pchMessageStart[2] = 0xb5;
pchMessageStart[3] = 0xda;
- nMaxTipAge = 24 * 60 * 60;
nDefaultPort = 18444;
nPruneAfterHeight = 1000;
diff --git a/src/chainparams.h b/src/chainparams.h
index fdf5c17a0e..88bc666765 100644
--- a/src/chainparams.h
+++ b/src/chainparams.h
@@ -64,7 +64,6 @@ public:
bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
/** Policy: Filter transactions that do not match well-defined patterns */
bool RequireStandard() const { return fRequireStandard; }
- int64_t MaxTipAge() const { return nMaxTipAge; }
uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
/** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
@@ -84,7 +83,6 @@ protected:
//! Raw pub key bytes for the broadcast alert signing key.
std::vector<unsigned char> vAlertPubKey;
int nDefaultPort;
- long nMaxTipAge;
uint64_t nPruneAfterHeight;
std::vector<CDNSSeedData> vSeeds;
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
diff --git a/src/clientversion.h b/src/clientversion.h
index c832663a76..40361660e6 100644
--- a/src/clientversion.h
+++ b/src/clientversion.h
@@ -26,7 +26,7 @@
* Copyright year (2009-this)
* Todo: update this when changing our copyright comments in the source
*/
-#define COPYRIGHT_YEAR 2015
+#define COPYRIGHT_YEAR 2016
#endif //HAVE_CONFIG_H
diff --git a/src/init.cpp b/src/init.cpp
index 1314afb7c3..282ede55c1 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -312,7 +312,8 @@ std::string HelpMessage(HelpMessageMode mode)
// When adding new options to the categories, please keep and ensure alphabetical ordering.
// Do not translate _(...) -help-debug options, Many technical terms, and only a very small audience, so is unnecessary stress to translators.
string strUsage = HelpMessageGroup(_("Options:"));
- strUsage += HelpMessageOpt("-?", _("This help message"));
+ strUsage += HelpMessageOpt("-?", _("Print this help message and exit"));
+ strUsage += HelpMessageOpt("-version", _("Print version and exit"));
strUsage += HelpMessageOpt("-alerts", strprintf(_("Receive and display P2P network alerts (default: %u)"), DEFAULT_ALERTS));
strUsage += HelpMessageOpt("-alertnotify=<cmd>", _("Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)"));
strUsage += HelpMessageOpt("-blocknotify=<cmd>", _("Execute command when the best block changes (%s in cmd is replaced by block hash)"));
@@ -423,8 +424,11 @@ std::string HelpMessage(HelpMessageMode mode)
#endif
strUsage += HelpMessageGroup(_("Debugging/Testing options:"));
+ strUsage += HelpMessageOpt("-uacomment=<cmt>", _("Append comment to the user agent string"));
if (showDebug)
{
+ strUsage += HelpMessageOpt("-checkblockindex", strprintf("Do a full consistency check for mapBlockIndex, setBlockIndexCandidates, chainActive and mapBlocksUnlinked occasionally. Also sets -checkmempool (default: %u)", Params(CBaseChainParams::MAIN).DefaultConsistencyChecks()));
+ strUsage += HelpMessageOpt("-checkmempool=<n>", strprintf("Run checks every <n> transactions (default: %u)", Params(CBaseChainParams::MAIN).DefaultConsistencyChecks()));
strUsage += HelpMessageOpt("-checkpoints", strprintf("Disable expensive verification for known chain history (default: %u)", DEFAULT_CHECKPOINTS_ENABLED));
#ifdef ENABLE_WALLET
strUsage += HelpMessageOpt("-dblogsize=<n>", strprintf("Flush wallet database activity from memory to disk log every <n> megabytes (default: %u)", DEFAULT_WALLET_DBLOGSIZE));
@@ -447,6 +451,8 @@ std::string HelpMessage(HelpMessageMode mode)
debugCategories += ", qt";
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +
_("If <category> is not supplied or if <category> = 1, output all debugging information.") + _("<category> can be:") + " " + debugCategories + ".");
+ if (showDebug)
+ strUsage += HelpMessageOpt("-nodebug", "Turn off debugging messages, same as -debug=0");
strUsage += HelpMessageOpt("-gen", strprintf(_("Generate coins (default: %u)"), DEFAULT_GENERATE));
strUsage += HelpMessageOpt("-genproclimit=<n>", strprintf(_("Set the number of threads for coin generation if enabled (-1 = all cores, default: %d)"), DEFAULT_GENERATE_THREADS));
strUsage += HelpMessageOpt("-help-debug", _("Show all debugging options (usage: --help -help-debug)"));
@@ -455,9 +461,11 @@ std::string HelpMessage(HelpMessageMode mode)
if (showDebug)
{
strUsage += HelpMessageOpt("-logtimemicros", strprintf("Add microsecond precision to debug timestamps (default: %u)", DEFAULT_LOGTIMEMICROS));
+ strUsage += HelpMessageOpt("-mocktime=<n>", "Replace actual time with <n> seconds since epoch (default: 0)");
strUsage += HelpMessageOpt("-limitfreerelay=<n>", strprintf("Continuously rate-limit free transactions to <n>*1000 bytes per minute (default: %u)", DEFAULT_LIMITFREERELAY));
strUsage += HelpMessageOpt("-relaypriority", strprintf("Require high priority for relaying free or low-fee transactions (default: %u)", DEFAULT_RELAYPRIORITY));
strUsage += HelpMessageOpt("-maxsigcachesize=<n>", strprintf("Limit size of signature cache to <n> MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE));
+ strUsage += HelpMessageOpt("-maxtipage=<n>", strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE));
}
strUsage += HelpMessageOpt("-minrelaytxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)"),
CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE)));
@@ -491,6 +499,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-server", _("Accept command line and JSON-RPC commands"));
strUsage += HelpMessageOpt("-rest", strprintf(_("Accept public REST requests (default: %u)"), DEFAULT_REST_ENABLE));
strUsage += HelpMessageOpt("-rpcbind=<addr>", _("Bind to given address to listen for JSON-RPC connections. Use [host]:port notation for IPv6. This option can be specified multiple times (default: bind to all interfaces)"));
+ strUsage += HelpMessageOpt("-rpccookiefile=<loc>", _("Location of the auth cookie (default: data dir)"));
strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections"));
strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections"));
strUsage += HelpMessageOpt("-rpcauth=<userpw>", _("Username and hashed password for JSON-RPC connections. The field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>. A canonical python script is included in share/rpcuser. This option can be specified multiple times"));
@@ -990,7 +999,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
{
CAmount nMaxFee = 0;
if (!ParseMoney(mapArgs["-maxtxfee"], nMaxFee))
- return InitError(AmountErrMsg("maxtxfee", mapArgs["-maptxfee"]));
+ return InitError(AmountErrMsg("maxtxfee", mapArgs["-maxtxfee"]));
if (nMaxFee > nHighTransactionMaxFeeWarning)
InitWarning(_("-maxtxfee is set very high! Fees this large could be paid on a single transaction."));
maxTxFee = nMaxFee;
@@ -1019,6 +1028,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
if (GetBoolArg("-peerbloomfilters", true))
nLocalServices |= NODE_BLOOM;
+ nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
+
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
// Initialize elliptic curve code
diff --git a/src/main.cpp b/src/main.cpp
index 06374cc1b6..9870beecc7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -75,6 +75,9 @@ bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED;
size_t nCoinCacheUsage = 5000 * 300;
uint64_t nPruneTarget = 0;
bool fAlerts = DEFAULT_ALERTS;
+/* If the tip is older than this (in seconds), the node is considered to be in initial block download.
+ */
+int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE;
/** Fees smaller than this (in satoshi) are considered zero fee (for relaying, mining and transaction creation) */
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
@@ -1377,7 +1380,7 @@ bool IsInitialBlockDownload()
if (lockIBDState)
return false;
bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 ||
- pindexBestHeader->GetBlockTime() < GetTime() - chainParams.MaxTipAge());
+ pindexBestHeader->GetBlockTime() < GetTime() - nMaxTipAge);
if (!state)
lockIBDState = true;
return state;
@@ -1633,9 +1636,12 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
// Only if ALL inputs pass do we perform expensive ECDSA signature checks.
// Helps prevent CPU exhaustion attacks.
- // Skip ECDSA signature verification when connecting blocks
- // before the last block chain checkpoint. This is safe because block merkle hashes are
- // still computed and checked, and any change will be caught at the next checkpoint.
+ // Skip ECDSA signature verification when connecting blocks before the
+ // last block chain checkpoint. Assuming the checkpoints are valid this
+ // is safe because block merkle hashes are still computed and checked,
+ // and any change will be caught at the next checkpoint. Of course, if
+ // the checkpoint is for a chain that's invalid due to false scriptSigs
+ // this optimisation would allow an invalid chain to be accepted.
if (fScriptChecks) {
for (unsigned int i = 0; i < tx.vin.size(); i++) {
const COutPoint &prevout = tx.vin[i].prevout;
@@ -4538,7 +4544,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
{
if (fBlocksOnly)
LogPrint("net", "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->id);
- else if (!fAlreadyHave && !fImporting && !fReindex)
+ else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload())
pfrom->AskFor(inv);
}
diff --git a/src/main.h b/src/main.h
index cefaedabf5..228877641d 100644
--- a/src/main.h
+++ b/src/main.h
@@ -97,6 +97,7 @@ static const unsigned int AVG_INVENTORY_BROADCAST_INTERVAL = 5;
static const unsigned int DEFAULT_LIMITFREERELAY = 15;
static const bool DEFAULT_RELAYPRIORITY = true;
+static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60;
/** Default for -permitbaremultisig */
static const bool DEFAULT_PERMIT_BAREMULTISIG = true;
@@ -137,6 +138,7 @@ extern bool fCheckpointsEnabled;
extern size_t nCoinCacheUsage;
extern CFeeRate minRelayTxFee;
extern bool fAlerts;
+extern int64_t nMaxTipAge;
/** Best header we've seen so far (used for getheaders queries' starting points). */
extern CBlockIndex *pindexBestHeader;
diff --git a/src/net.cpp b/src/net.cpp
index 84582484e5..48e9e10157 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -38,7 +38,7 @@
#include <math.h>
-// Dump addresses to peers.dat every 15 minutes (900s)
+// Dump addresses to peers.dat and banlist.dat every 15 minutes (900s)
#define DUMP_ADDRESSES_INTERVAL 900
#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
@@ -573,11 +573,13 @@ void CNode::SweepBanned()
banmap_t::iterator it = setBanned.begin();
while(it != setBanned.end())
{
+ CSubNet subNet = (*it).first;
CBanEntry banEntry = (*it).second;
if(now > banEntry.nBanUntil)
{
setBanned.erase(it++);
setBannedIsDirty = true;
+ LogPrint("net", "%s: Removed banned node ip/subnet from banlist.dat: %s\n", __func__, subNet.ToString());
}
else
++it;
@@ -1492,12 +1494,7 @@ void DumpAddresses()
void DumpData()
{
DumpAddresses();
-
- if (CNode::BannedSetIsDirty())
- {
- DumpBanlist();
- CNode::SetBannedSetDirty(false);
- }
+ DumpBanlist();
}
void static ProcessOneShot()
@@ -1938,31 +1935,36 @@ void static Discover(boost::thread_group& threadGroup)
void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler)
{
uiInterface.InitMessage(_("Loading addresses..."));
- // Load addresses for peers.dat
+ // Load addresses from peers.dat
int64_t nStart = GetTimeMillis();
{
CAddrDB adb;
- if (!adb.Read(addrman))
+ if (adb.Read(addrman))
+ LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman.size(), GetTimeMillis() - nStart);
+ else
LogPrintf("Invalid or missing peers.dat; recreating\n");
}
- //try to read stored banlist
+ uiInterface.InitMessage(_("Loading banlist..."));
+ // Load addresses from banlist.dat
+ nStart = GetTimeMillis();
CBanDB bandb;
banmap_t banmap;
- if (!bandb.Read(banmap))
+ if (bandb.Read(banmap)) {
+ CNode::SetBanned(banmap); // thread save setter
+ CNode::SetBannedSetDirty(false); // no need to write down, just read data
+ CNode::SweepBanned(); // sweep out unused entries
+
+ LogPrint("net", "Loaded %d banned node ips/subnets from banlist.dat %dms\n",
+ banmap.size(), GetTimeMillis() - nStart);
+ } else
LogPrintf("Invalid or missing banlist.dat; recreating\n");
- CNode::SetBanned(banmap); //thread save setter
- CNode::SetBannedSetDirty(false); //no need to write down just read or nonexistent data
- CNode::SweepBanned(); //sweap out unused entries
-
- LogPrintf("Loaded %i addresses from peers.dat %dms\n",
- addrman.size(), GetTimeMillis() - nStart);
fAddressesInitialized = true;
if (semOutbound == NULL) {
// initialize semaphore
- int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections);
+ int nMaxOutbound = std::min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections);
semOutbound = new CSemaphore(nMaxOutbound);
}
@@ -2177,7 +2179,7 @@ bool CNode::OutboundTargetReached(bool historicalBlockServingLimit)
if (historicalBlockServingLimit)
{
- // keep a large enought buffer to at least relay each block once
+ // keep a large enough buffer to at least relay each block once
uint64_t timeLeftInCycle = GetMaxOutboundTimeLeftInCycle();
uint64_t buffer = timeLeftInCycle / 600 * MAX_BLOCK_SIZE;
if (buffer >= nMaxOutboundLimit || nMaxOutboundTotalBytesSentInCycle >= nMaxOutboundLimit - buffer)
@@ -2609,30 +2611,34 @@ bool CBanDB::Read(banmap_t& banSet)
// ... verify the network matches ours
if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp)))
return error("%s: Invalid network magic number", __func__);
-
+
// de-serialize address data into one CAddrMan object
ssBanlist >> banSet;
}
catch (const std::exception& e) {
return error("%s: Deserialize or I/O error - %s", __func__, e.what());
}
-
+
return true;
}
void DumpBanlist()
{
- int64_t nStart = GetTimeMillis();
+ CNode::SweepBanned(); // clean unused entries (if bantime has expired)
- CNode::SweepBanned(); //clean unused entries (if bantime has expired)
+ if (!CNode::BannedSetIsDirty())
+ return;
+
+ int64_t nStart = GetTimeMillis();
CBanDB bandb;
banmap_t banmap;
CNode::GetBanned(banmap);
- bandb.Write(banmap);
+ if (bandb.Write(banmap))
+ CNode::SetBannedSetDirty(false);
LogPrint("net", "Flushed %d banned node ips/subnets to banlist.dat %dms\n",
- banmap.size(), GetTimeMillis() - nStart);
+ banmap.size(), GetTimeMillis() - nStart);
}
int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds) {
diff --git a/src/netbase.cpp b/src/netbase.cpp
index 4e1f267607..7f79dd02c6 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -140,7 +140,7 @@ bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsign
return false;
do {
- // Should set the timeout limit to a resonable value to avoid
+ // Should set the timeout limit to a reasonable value to avoid
// generating unnecessary checking call during the polling loop,
// while it can still response to stop request quick enough.
// 2 seconds looks fine in our situation.
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp
index 980ecf10df..de3c060d6a 100644
--- a/src/policy/fees.cpp
+++ b/src/policy/fees.cpp
@@ -87,7 +87,7 @@ double TxConfirmStats::EstimateMedianVal(int confTarget, double sufficientTxVal,
int maxbucketindex = buckets.size() - 1;
// requireGreater means we are looking for the lowest fee/priority such that all higher
- // values pass, so we start at maxbucketindex (highest fee) and look at succesively
+ // values pass, so we start at maxbucketindex (highest fee) and look at successively
// smaller buckets until we reach failure. Otherwise, we are looking for the highest
// fee/priority such that all lower values fail, and we go in the opposite direction.
unsigned int startbucket = requireGreater ? maxbucketindex : 0;
diff --git a/src/policy/fees.h b/src/policy/fees.h
index 7a293267d4..3fa31c39e7 100644
--- a/src/policy/fees.h
+++ b/src/policy/fees.h
@@ -29,7 +29,7 @@ class CTxMemPool;
* included in blocks before transactions of lower fee/priority. So for
* example if you wanted to know what fee you should put on a transaction to
* be included in a block within the next 5 blocks, you would start by looking
- * at the bucket with with the highest fee transactions and verifying that a
+ * at the bucket with the highest fee transactions and verifying that a
* sufficiently high percentage of them were confirmed within 5 blocks and
* then you would look at the next highest fee bucket, and so on, stopping at
* the last bucket to pass the test. The average fee of transactions in this
@@ -87,13 +87,13 @@ private:
// Count the total # of txs in each bucket
// Track the historical moving average of this total over blocks
std::vector<double> txCtAvg;
- // and calcuate the total for the current block to update the moving average
+ // and calculate the total for the current block to update the moving average
std::vector<int> curBlockTxCt;
// Count the total # of txs confirmed within Y blocks in each bucket
// Track the historical moving average of theses totals over blocks
std::vector<std::vector<double> > confAvg; // confAvg[Y][X]
- // and calcuate the totals for the current block to update the moving averages
+ // and calculate the totals for the current block to update the moving averages
std::vector<std::vector<int> > curBlockConf; // curBlockConf[Y][X]
// Sum the total priority/fee of all tx's in each bucket
diff --git a/src/policy/rbf.cpp b/src/policy/rbf.cpp
new file mode 100644
index 0000000000..98b1a1ba4c
--- /dev/null
+++ b/src/policy/rbf.cpp
@@ -0,0 +1,46 @@
+// Copyright (c) 2016 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include "policy/rbf.h"
+
+bool SignalsOptInRBF(const CTransaction &tx)
+{
+ BOOST_FOREACH(const CTxIn &txin, tx.vin) {
+ if (txin.nSequence < std::numeric_limits<unsigned int>::max()-1) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool IsRBFOptIn(const CTxMemPoolEntry &entry, CTxMemPool &pool)
+{
+ AssertLockHeld(pool.cs);
+
+ CTxMemPool::setEntries setAncestors;
+
+ // First check the transaction itself.
+ if (SignalsOptInRBF(entry.GetTx())) {
+ return true;
+ }
+
+ // If this transaction is not in our mempool, then we can't be sure
+ // we will know about all its inputs.
+ if (!pool.exists(entry.GetTx().GetHash())) {
+ throw std::runtime_error("Cannot determine RBF opt-in signal for non-mempool transaction\n");
+ }
+
+ // If all the inputs have nSequence >= maxint-1, it still might be
+ // signaled for RBF if any unconfirmed parents have signaled.
+ uint64_t noLimit = std::numeric_limits<uint64_t>::max();
+ std::string dummy;
+ pool.CalculateMemPoolAncestors(entry, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false);
+
+ BOOST_FOREACH(CTxMemPool::txiter it, setAncestors) {
+ if (SignalsOptInRBF(it->GetTx())) {
+ return true;
+ }
+ }
+ return false;
+}
diff --git a/src/policy/rbf.h b/src/policy/rbf.h
new file mode 100644
index 0000000000..925ce0d9bd
--- /dev/null
+++ b/src/policy/rbf.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2016 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_POLICY_RBF_H
+#define BITCOIN_POLICY_RBF_H
+
+#include "txmempool.h"
+
+// Check whether the sequence numbers on this transaction are signaling
+// opt-in to replace-by-fee, according to BIP 125
+bool SignalsOptInRBF(const CTransaction &tx);
+
+// Determine whether an in-mempool transaction is signaling opt-in to RBF
+// according to BIP 125
+// This involves checking sequence numbers of the transaction, as well
+// as the sequence numbers of all in-mempool ancestors.
+bool IsRBFOptIn(const CTxMemPoolEntry &entry, CTxMemPool &pool);
+
+#endif // BITCOIN_POLICY_RBF_H
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index b4ac696393..fb502b3c81 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -112,7 +112,7 @@ double ClientModel::getVerificationProgress(const CBlockIndex *tipIn) const
void ClientModel::updateTimer()
{
// no locking required at this point
- // the following calls will aquire the required lock
+ // the following calls will acquire the required lock
Q_EMIT mempoolSizeChanged(getMempoolSize(), getMempoolDynamicUsage());
Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent());
}
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index c834c3b564..5fc7b57a41 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -791,7 +791,7 @@ void SendCoinsDialog::coinControlUpdateLabels()
if (model->getOptionsModel()->getCoinControlFeatures())
{
- // enable minium absolute fee UI controls
+ // enable minimum absolute fee UI controls
ui->radioCustomAtLeast->setVisible(true);
// only enable the feature if inputs are selected
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index b76b0ca403..954441d15c 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -323,7 +323,8 @@ UniValue getblockheader(const UniValue& params, bool fHelp)
" \"bits\" : \"1d00ffff\", (string) The bits\n"
" \"difficulty\" : x.xxx, (numeric) The difficulty\n"
" \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n"
- " \"nextblockhash\" : \"hash\" (string) The hash of the next block\n"
+ " \"nextblockhash\" : \"hash\", (string) The hash of the next block\n"
+ " \"chainwork\" : \"0000...1f3\" (string) Expected number of hashes required to produce the current chain (in hex)\n"
"}\n"
"\nResult (for verbose=false):\n"
"\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n"
@@ -384,6 +385,7 @@ UniValue getblock(const UniValue& params, bool fHelp)
" \"nonce\" : n, (numeric) The nonce\n"
" \"bits\" : \"1d00ffff\", (string) The bits\n"
" \"difficulty\" : x.xxx, (numeric) The difficulty\n"
+ " \"chainwork\" : \"xxxx\", (string) Expected number of hashes required to produce the chain up to this block (in hex)\n"
" \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n"
" \"nextblockhash\" : \"hash\" (string) The hash of the next block\n"
"}\n"
diff --git a/src/test/merkle_tests.cpp b/src/test/merkle_tests.cpp
index 1e31f2e679..b40ab848dc 100644
--- a/src/test/merkle_tests.cpp
+++ b/src/test/merkle_tests.cpp
@@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(merkle_test)
int duplicate2 = mutate >= 2 ? 1 << ctz(ntx1) : 0; // Likewise for the second mutation.
if (duplicate2 >= ntx1) break;
int ntx2 = ntx1 + duplicate2;
- int duplicate3 = mutate >= 3 ? 1 << ctz(ntx2) : 0; // And for the the third mutation.
+ int duplicate3 = mutate >= 3 ? 1 << ctz(ntx2) : 0; // And for the third mutation.
if (duplicate3 >= ntx2) break;
int ntx3 = ntx2 + duplicate3;
// Build a block with ntx different transactions.
diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp
index 4ebcb9b667..8b77024819 100644
--- a/src/torcontrol.cpp
+++ b/src/torcontrol.cpp
@@ -79,7 +79,7 @@ public:
/**
* Connect to a Tor control port.
* target is address of the form host:port.
- * connected is the handler that is called when connection is succesfully established.
+ * connected is the handler that is called when connection is successfully established.
* disconnected is a handler that is called when the connection is broken.
* Return true on success.
*/
@@ -177,7 +177,7 @@ void TorControlConnection::eventcb(struct bufferevent *bev, short what, void *ct
{
TorControlConnection *self = (TorControlConnection*)ctx;
if (what & BEV_EVENT_CONNECTED) {
- LogPrint("tor", "tor: Succesfully connected!\n");
+ LogPrint("tor", "tor: Successfully connected!\n");
self->connected(*self);
} else if (what & (BEV_EVENT_EOF|BEV_EVENT_ERROR)) {
if (what & BEV_EVENT_ERROR)
@@ -303,7 +303,7 @@ static std::map<std::string,std::string> ParseTorReplyMapping(const std::string
/** Read full contents of a file and return them in a std::string.
* Returns a pair <status, string>.
- * If an error occured, status will be false, otherwise status will be true and the data will be returned in string.
+ * If an error occurred, status will be false, otherwise status will be true and the data will be returned in string.
*
* @param maxsize Puts a maximum size limit on the file that is read. If the file is larger than this, truncated data
* (with len > maxsize) will be returned.
@@ -380,7 +380,7 @@ private:
void authchallenge_cb(TorControlConnection& conn, const TorControlReply& reply);
/** Callback for PROTOCOLINFO result */
void protocolinfo_cb(TorControlConnection& conn, const TorControlReply& reply);
- /** Callback after succesful connection */
+ /** Callback after successful connection */
void connected_cb(TorControlConnection& conn);
/** Callback after connection lost or failed connection attempt */
void disconnected_cb(TorControlConnection& conn);
@@ -419,7 +419,7 @@ TorController::~TorController()
void TorController::add_onion_cb(TorControlConnection& conn, const TorControlReply& reply)
{
if (reply.code == 250) {
- LogPrint("tor", "tor: ADD_ONION succesful\n");
+ LogPrint("tor", "tor: ADD_ONION successful\n");
BOOST_FOREACH(const std::string &s, reply.lines) {
std::map<std::string,std::string> m = ParseTorReplyMapping(s);
std::map<std::string,std::string>::iterator i;
@@ -448,7 +448,7 @@ void TorController::add_onion_cb(TorControlConnection& conn, const TorControlRep
void TorController::auth_cb(TorControlConnection& conn, const TorControlReply& reply)
{
if (reply.code == 250) {
- LogPrint("tor", "tor: Authentication succesful\n");
+ LogPrint("tor", "tor: Authentication successful\n");
// Now that we know Tor is running setup the proxy for onion addresses
// if -onion isn't set to something else.
@@ -501,7 +501,7 @@ static std::vector<uint8_t> ComputeResponse(const std::string &key, const std::v
void TorController::authchallenge_cb(TorControlConnection& conn, const TorControlReply& reply)
{
if (reply.code == 250) {
- LogPrint("tor", "tor: SAFECOOKIE authentication challenge succesful\n");
+ LogPrint("tor", "tor: SAFECOOKIE authentication challenge successful\n");
std::pair<std::string,std::string> l = SplitTorReplyLine(reply.lines[0]);
if (l.first == "AUTHCHALLENGE") {
std::map<std::string,std::string> m = ParseTorReplyMapping(l.second);
diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp
index d18250b76f..50b0f40a6a 100644
--- a/src/wallet/db.cpp
+++ b/src/wallet/db.cpp
@@ -205,7 +205,7 @@ bool CDBEnv::Salvage(const std::string& strFile, bool fAggressive, std::vector<C
std::string keyHex, valueHex;
while (!strDump.eof() && keyHex != "DATA=END") {
getline(strDump, keyHex);
- if (keyHex != "DATA_END") {
+ if (keyHex != "DATA=END") {
getline(strDump, valueHex);
vResult.push_back(make_pair(ParseHex(keyHex), ParseHex(valueHex)));
}
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 7509afdb95..e542933954 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -11,6 +11,7 @@
#include "main.h"
#include "net.h"
#include "netbase.h"
+#include "policy/rbf.h"
#include "rpcserver.h"
#include "timedata.h"
#include "util.h"
@@ -76,6 +77,23 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
entry.push_back(Pair("walletconflicts", conflicts));
entry.push_back(Pair("time", wtx.GetTxTime()));
entry.push_back(Pair("timereceived", (int64_t)wtx.nTimeReceived));
+
+ // Add opt-in RBF status
+ std::string rbfStatus = "no";
+ if (confirms <= 0) {
+ LOCK(mempool.cs);
+ if (!mempool.exists(hash)) {
+ if (SignalsOptInRBF(wtx)) {
+ rbfStatus = "yes";
+ } else {
+ rbfStatus = "unknown";
+ }
+ } else if (IsRBFOptIn(*mempool.mapTx.find(hash), mempool)) {
+ rbfStatus = "yes";
+ }
+ }
+ entry.push_back(Pair("bip125-replaceable", rbfStatus));
+
BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue)
entry.push_back(Pair(item.first, item.second));
}
@@ -1423,7 +1441,7 @@ UniValue listtransactions(const UniValue& params, bool fHelp)
" 'send' category of transactions.\n"
" \"confirmations\": n, (numeric) The number of confirmations for the transaction. Available for 'send' and \n"
" 'receive' category of transactions. Negative confirmations indicate the\n"
- " transation conflicts with the block chain\n"
+ " transaction conflicts with the block chain\n"
" \"trusted\": xxx (bool) Whether we consider the outputs of this unconfirmed transaction safe to spend.\n"
" \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive'\n"
" category of transactions.\n"
@@ -1439,6 +1457,8 @@ UniValue listtransactions(const UniValue& params, bool fHelp)
" \"otheraccount\": \"accountname\", (string) For the 'move' category of transactions, the account the funds came \n"
" from (for receiving funds, positive amounts), or went to (for sending funds,\n"
" negative amounts).\n"
+ " \"bip125-replaceable\": \"yes|no|unknown\" (string) Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n"
+ " may be unknown for unconfirmed transactions not in the mempool\n"
" }\n"
"]\n"
@@ -1707,6 +1727,8 @@ UniValue gettransaction(const UniValue& params, bool fHelp)
" \"txid\" : \"transactionid\", (string) The transaction id.\n"
" \"time\" : ttt, (numeric) The transaction time in seconds since epoch (1 Jan 1970 GMT)\n"
" \"timereceived\" : ttt, (numeric) The time received in seconds since epoch (1 Jan 1970 GMT)\n"
+ " \"bip125-replaceable\": \"yes|no|unknown\" (string) Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n"
+ " may be unknown for unconfirmed transactions not in the mempool\n"
" \"details\" : [\n"
" {\n"
" \"account\" : \"accountname\", (string) DEPRECATED. The account name involved in the transaction, can be \"\" for the default account.\n"
diff --git a/src/wallet/wallet_ismine.h b/src/wallet/wallet_ismine.h
index 93cdf6ab8f..51afd1b140 100644
--- a/src/wallet/wallet_ismine.h
+++ b/src/wallet/wallet_ismine.h
@@ -17,7 +17,7 @@ class CScript;
enum isminetype
{
ISMINE_NO = 0,
- //! Indicates that we dont know how to create a scriptSig that would solve this if we were given the appropriate private keys
+ //! Indicates that we don't know how to create a scriptSig that would solve this if we were given the appropriate private keys
ISMINE_WATCH_UNSOLVABLE = 1,
//! Indicates that we know how to create a scriptSig that would solve this if we were given the appropriate private keys
ISMINE_WATCH_SOLVABLE = 2,
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp
index 5266946ca0..67511976df 100644
--- a/src/wallet/walletdb.cpp
+++ b/src/wallet/walletdb.cpp
@@ -15,11 +15,6 @@
#include "utiltime.h"
#include "wallet/wallet.h"
-#if defined(FORCE_BOOST_EMULATED_SCOPED_ENUMS)
-#define BOOST_NO_SCOPED_ENUMS
-#define BOOST_NO_CXX11_SCOPED_ENUMS
-#endif
-
#include <boost/version.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>