aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--configure.ac41
-rwxr-xr-xcontrib/devtools/github-merge.sh4
-rw-r--r--contrib/linearize/README.md34
-rw-r--r--contrib/linearize/example-linearize.cfg13
-rwxr-xr-xcontrib/linearize/linearize-data.py208
-rwxr-xr-x[-rw-r--r--]contrib/linearize/linearize-hashes.py (renamed from contrib/linearize/linearize.py)40
-rw-r--r--depends/Makefile2
-rw-r--r--depends/funcs.mk8
-rw-r--r--doc/README.md1
-rw-r--r--doc/build-osx.md27
-rw-r--r--doc/build-unix.md6
-rw-r--r--src/Makefile.am7
-rw-r--r--src/Makefile.test.include15
-rw-r--r--src/addrman.cpp14
-rw-r--r--src/alert.cpp5
-rw-r--r--src/alert.h7
-rw-r--r--src/bitcoin-tx.cpp28
-rw-r--r--src/coins.cpp16
-rw-r--r--src/coins.h10
-rw-r--r--src/core.cpp40
-rw-r--r--src/core.h6
-rw-r--r--src/crypter.cpp29
-rw-r--r--src/crypter.h5
-rw-r--r--src/db.h1
-rw-r--r--src/init.cpp5
-rw-r--r--src/m4/ax_boost_base.m46
-rw-r--r--src/m4/bitcoin_qt.m414
-rw-r--r--src/main.cpp98
-rw-r--r--src/main.h10
-rw-r--r--src/miner.cpp10
-rw-r--r--src/net.cpp12
-rw-r--r--src/net.h1
-rw-r--r--src/netbase.cpp22
-rw-r--r--src/netbase.h5
-rw-r--r--src/protocol.cpp6
-rw-r--r--src/protocol.h4
-rw-r--r--src/qt/forms/overviewpage.ui6
-rw-r--r--src/qt/guiutil.cpp2
-rw-r--r--src/qt/guiutil.h2
-rw-r--r--src/qt/walletmodel.cpp20
-rw-r--r--src/qt/walletmodel.h5
-rw-r--r--src/rpcnet.cpp33
-rw-r--r--src/rpcserver.cpp5
-rw-r--r--src/script.h6
-rw-r--r--src/serialize.h112
-rw-r--r--src/test/alert_tests.cpp2
-rw-r--r--src/test/bctest.py53
-rwxr-xr-xsrc/test/bitcoin-util-test.py12
-rw-r--r--src/test/data/bitcoin-util-test.json38
-rw-r--r--src/test/data/blanktx.hex1
-rw-r--r--src/test/data/tt-delin1-out.hex1
-rw-r--r--src/test/data/tt-delout1-out.hex1
-rw-r--r--src/test/data/tt-locktime317000-out.hex1
-rw-r--r--src/test/data/tx394b54bb.hex1
-rw-r--r--src/test/data/txcreate1.hex1
-rw-r--r--src/test/rpc_tests.cpp32
-rw-r--r--src/test/univalue_tests.cpp275
-rw-r--r--src/tinyformat.h2
-rw-r--r--src/txdb.cpp7
-rw-r--r--src/txdb.h2
-rw-r--r--src/univalue/gen.cpp78
-rw-r--r--src/univalue/univalue.cpp2
-rw-r--r--src/univalue/univalue_escapes.h262
-rw-r--r--src/univalue/univalue_write.cpp32
-rw-r--r--src/util.h1
-rw-r--r--src/version.h2
-rw-r--r--src/wallet.h11
68 files changed, 1400 insertions, 371 deletions
diff --git a/.gitignore b/.gitignore
index e21ea92552..24af4cb72e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,6 +28,8 @@ src/m4/ltsugar.m4
src/m4/ltversion.m4
src/m4/lt~obsolete.m4
+src/univalue/gen
+
src/qt/*.moc
src/qt/moc_*.cpp
src/qt/forms/ui_*.h
@@ -41,6 +43,7 @@ src/qt/test/moc*.cpp
*.bak
*.rej
*.orig
+*.pyc
*.o
*.o-*
*.patch
diff --git a/configure.ac b/configure.ac
index bf45d7cd1c..601ccf0a79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -430,10 +430,6 @@ if test x$use_reduce_exports != xno; then
AC_MSG_WARN([Cannot set default symbol visibility. Disabling reduced exports.])
use_reduce_exports=no
])
- if test x$use_reduce_exports != xno; then
- AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]], [RELDFLAGS="-Wl,--exclude-libs,ALL"])
- CXXFLAGS="$CXXFLAGS $RE_CXXFLAGS"
- fi
fi
LEVELDB_CPPFLAGS=
@@ -460,6 +456,12 @@ fi
dnl Check for boost libs
AX_BOOST_BASE
+AX_BOOST_SYSTEM
+AX_BOOST_FILESYSTEM
+AX_BOOST_PROGRAM_OPTIONS
+AX_BOOST_THREAD
+AX_BOOST_CHRONO
+
if test x$use_reduce_exports != xno; then
AC_MSG_CHECKING([for working boost reduced exports])
@@ -489,11 +491,10 @@ if test x$use_reduce_exports != xno; then
CPPFLAGS="$TEMP_CPPFLAGS"
fi
-AX_BOOST_SYSTEM
-AX_BOOST_FILESYSTEM
-AX_BOOST_PROGRAM_OPTIONS
-AX_BOOST_THREAD
-AX_BOOST_CHRONO
+if test x$use_reduce_exports != xno; then
+ CXXFLAGS="$CXXFLAGS $RE_CXXFLAGS"
+ AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]], [RELDFLAGS="-Wl,--exclude-libs,ALL"])
+fi
if test x$use_tests = xyes; then
@@ -579,15 +580,15 @@ if test x$boost_sleep != xyes; then
AC_MSG_ERROR(No working boost sleep implementation found. If on ubuntu 13.10 with libboost1.54-all-dev remove libboost.1.54-all-dev and use libboost1.53-all-dev)
fi
-AC_ARG_WITH([cli],
- [AS_HELP_STRING([--with-cli],
- [with CLI (default is yes)])],
- [build_bitcoin_cli=$withval],
- [build_bitcoin_cli=yes])
+AC_ARG_WITH([utils],
+ [AS_HELP_STRING([--with-utils],
+ [build bitcoin-cli bitcoin-tx (default=yes)])],
+ [build_bitcoin_utils=$withval],
+ [build_bitcoin_utils=yes])
AC_ARG_WITH([daemon],
[AS_HELP_STRING([--with-daemon],
- [with daemon (default is yes)])],
+ [build bitcoind daemon (default=yes)])],
[build_bitcoind=$withval],
[build_bitcoind=yes])
@@ -631,9 +632,9 @@ AC_MSG_CHECKING([whether to build bitcoind])
AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes])
AC_MSG_RESULT($build_bitcoind)
-AC_MSG_CHECKING([whether to build bitcoin-cli])
-AM_CONDITIONAL([BUILD_BITCOIN_CLI], [test x$build_bitcoin_cli = xyes])
-AC_MSG_RESULT($build_bitcoin_cli)
+AC_MSG_CHECKING([whether to build utils (bitcoin-cli bitcoin-tx)])
+AM_CONDITIONAL([BUILD_BITCOIN_UTILS], [test x$build_bitcoin_utils = xyes])
+AC_MSG_RESULT($build_bitcoin_utils)
dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus
BITCOIN_QT_CONFIGURE([$use_pkgconfig], [qt4])
@@ -748,8 +749,8 @@ else
AC_MSG_RESULT([no])
fi
-if test "x$use_tests$build_bitcoind$use_qt" = "xnonono"; then
- AC_MSG_ERROR([No targets! Please specify at least one of: --enable-cli --enable-daemon --enable-gui or --enable-tests])
+if test x$build_bitcoin_utils$build_bitcoind$bitcoin_enable_qt$use_tests = xnononono; then
+ AC_MSG_ERROR([No targets! Please specify at least one of: --with-utils --with-daemon --with-gui or --enable-tests])
fi
AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin])
diff --git a/contrib/devtools/github-merge.sh b/contrib/devtools/github-merge.sh
index e42b71a54a..3217a06195 100755
--- a/contrib/devtools/github-merge.sh
+++ b/contrib/devtools/github-merge.sh
@@ -49,11 +49,11 @@ 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 -1q "refs/heads/pull/$PULL/head" >/dev/null 2>&1; 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 -1q "refs/heads/pull/$PULL/merge" >/dev/null 2>&1; then
+ 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
diff --git a/contrib/linearize/README.md b/contrib/linearize/README.md
index 70b9f034cd..b5c6e7824e 100644
--- a/contrib/linearize/README.md
+++ b/contrib/linearize/README.md
@@ -1,2 +1,32 @@
-### Linearize ###
-Construct a linear, no-fork, best version of the blockchain. \ No newline at end of file
+# Linearize
+Construct a linear, no-fork, best version of the blockchain.
+
+## Step 1: Download hash list
+
+ $ ./linearize-hashes.py linearize.cfg > hashlist.txt
+
+Required configuration file settings for linearize-hashes:
+* RPC: rpcuser, rpcpassword
+
+Optional config file setting for linearize-hashes:
+* RPC: host, port
+* Block chain: min_height, max_height
+
+## Step 2: Copy local block data
+
+ $ ./linearize-data.py linearize.cfg
+
+Required configuration file settings:
+* "input": bitcoind blocks/ directory containing blkNNNNN.dat
+* "hashlist": text file containing list of block hashes, linearized-hashes.py
+output.
+* "output_file": bootstrap.dat
+ or
+* "output": output directory for linearized blocks/blkNNNNN.dat output
+
+Optional config file setting for linearize-data:
+* "netmagic": network magic number
+* "max_out_sz": maximum output file size (default 1000*1000*1000)
+* "split_year": Split files when a new year is first seen, in addition to
+reaching a maximum file size.
+
diff --git a/contrib/linearize/example-linearize.cfg b/contrib/linearize/example-linearize.cfg
index f5cdab5325..071345f23a 100644
--- a/contrib/linearize/example-linearize.cfg
+++ b/contrib/linearize/example-linearize.cfg
@@ -1,12 +1,17 @@
-# bitcoind RPC settings
+# bitcoind RPC settings (linearize-hashes)
rpcuser=someuser
rpcpassword=somepassword
host=127.0.0.1
port=8332
-# bootstrap.dat settings
+# bootstrap.dat hashlist settings (linearize-hashes)
+max_height=313000
+
+# bootstrap.dat input/output settings (linearize-data)
netmagic=f9beb4d9
-max_height=279000
-output=bootstrap.dat
+input=/home/example/.bitcoin/blocks
+output_file=/home/example/Downloads/bootstrap.dat
+hashlist=hashlist.txt
+split_year=1
diff --git a/contrib/linearize/linearize-data.py b/contrib/linearize/linearize-data.py
new file mode 100755
index 0000000000..ea94f25fae
--- /dev/null
+++ b/contrib/linearize/linearize-data.py
@@ -0,0 +1,208 @@
+#!/usr/bin/python
+#
+# linearize-data.py: Construct a linear, no-fork version of the chain.
+#
+# Copyright (c) 2013 The Bitcoin developers
+# Distributed under the MIT/X11 software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#
+
+import json
+import struct
+import re
+import base64
+import httplib
+import sys
+import hashlib
+import datetime
+
+settings = {}
+
+
+def uint32(x):
+ return x & 0xffffffffL
+
+def bytereverse(x):
+ return uint32(( ((x) << 24) | (((x) << 8) & 0x00ff0000) |
+ (((x) >> 8) & 0x0000ff00) | ((x) >> 24) ))
+
+def bufreverse(in_buf):
+ out_words = []
+ for i in range(0, len(in_buf), 4):
+ word = struct.unpack('@I', in_buf[i:i+4])[0]
+ out_words.append(struct.pack('@I', bytereverse(word)))
+ return ''.join(out_words)
+
+def wordreverse(in_buf):
+ out_words = []
+ for i in range(0, len(in_buf), 4):
+ out_words.append(in_buf[i:i+4])
+ out_words.reverse()
+ return ''.join(out_words)
+
+def calc_hdr_hash(blk_hdr):
+ hash1 = hashlib.sha256()
+ hash1.update(blk_hdr)
+ hash1_o = hash1.digest()
+
+ hash2 = hashlib.sha256()
+ hash2.update(hash1_o)
+ hash2_o = hash2.digest()
+
+ return hash2_o
+
+def calc_hash_str(blk_hdr):
+ hash = calc_hdr_hash(blk_hdr)
+ hash = bufreverse(hash)
+ hash = wordreverse(hash)
+ hash_str = hash.encode('hex')
+ return hash_str
+
+def get_blk_year(blk_hdr):
+ members = struct.unpack("<I", blk_hdr[68:68+4])
+ dt = datetime.datetime.fromtimestamp(members[0])
+ return dt.year
+
+def get_block_hashes(settings):
+ blkindex = []
+ f = open(settings['hashlist'], "r")
+ for line in f:
+ line = line.rstrip()
+ blkindex.append(line)
+
+ print("Read " + str(len(blkindex)) + " hashes")
+
+ return blkindex
+
+def mkblockset(blkindex):
+ blkmap = {}
+ for hash in blkindex:
+ blkmap[hash] = True
+ return blkmap
+
+def copydata(settings, blkindex, blkset):
+ inFn = 0
+ inF = None
+ outFn = 0
+ outsz = 0
+ outF = None
+ blkCount = 0
+
+ lastYear = 0
+ splitYear = False
+ fileOutput = True
+ maxOutSz = settings['max_out_sz']
+ if 'output' in settings:
+ fileOutput = False
+ if settings['split_year'] != 0:
+ splitYear = True
+
+ while True:
+ if not inF:
+ fname = "%s/blk%05d.dat" % (settings['input'], inFn)
+ print("Input file" + fname)
+ inF = open(fname, "rb")
+
+ inhdr = inF.read(8)
+ if (not inhdr or (inhdr[0] == "\0")):
+ inF.close()
+ inF = None
+ inFn = inFn + 1
+ continue
+
+ inMagic = inhdr[:4]
+ if (inMagic != settings['netmagic']):
+ print("Invalid magic:" + inMagic)
+ return
+ inLenLE = inhdr[4:]
+ su = struct.unpack("<I", inLenLE)
+ inLen = su[0]
+ rawblock = inF.read(inLen)
+ blk_hdr = rawblock[:80]
+
+ hash_str = calc_hash_str(blk_hdr)
+ if not hash_str in blkset:
+ print("Skipping unknown block " + hash_str)
+ continue
+
+ if not fileOutput and ((outsz + inLen) > maxOutSz):
+ outF.close()
+ outF = None
+ outFn = outFn + 1
+ outsz = 0
+
+ if splitYear:
+ blkYear = get_blk_year(blk_hdr)
+ if blkYear > lastYear:
+ print("New year " + str(blkYear) + " @ " + hash_str)
+ lastYear = blkYear
+ if outF:
+ outF.close()
+ outF = None
+ outFn = outFn + 1
+ outsz = 0
+
+ if not outF:
+ if fileOutput:
+ fname = settings['output_file']
+ else:
+ fname = "%s/blk%05d.dat" % (settings['output'], outFn)
+ print("Output file" + fname)
+ outF = open(fname, "wb")
+
+ outF.write(inhdr)
+ outF.write(rawblock)
+ outsz = outsz + inLen + 8
+
+ blkCount = blkCount + 1
+
+ if (blkCount % 1000) == 0:
+ print("Wrote " + str(blkCount) + " blocks")
+
+if __name__ == '__main__':
+ if len(sys.argv) != 2:
+ print "Usage: linearize-data.py CONFIG-FILE"
+ sys.exit(1)
+
+ f = open(sys.argv[1])
+ for line in f:
+ # skip comment lines
+ m = re.search('^\s*#', line)
+ if m:
+ continue
+
+ # parse key=value lines
+ m = re.search('^(\w+)\s*=\s*(\S.*)$', line)
+ if m is None:
+ continue
+ settings[m.group(1)] = m.group(2)
+ f.close()
+
+ if 'netmagic' not in settings:
+ settings['netmagic'] = 'f9beb4d9'
+ if 'input' not in settings:
+ settings['input'] = 'input'
+ if 'hashlist' not in settings:
+ settings['hashlist'] = 'hashlist.txt'
+ if 'split_year' not in settings:
+ settings['split_year'] = 0
+ if 'max_out_sz' not in settings:
+ settings['max_out_sz'] = 1000L * 1000 * 1000
+
+ settings['max_out_sz'] = long(settings['max_out_sz'])
+ settings['split_year'] = int(settings['split_year'])
+ settings['netmagic'] = settings['netmagic'].decode('hex')
+
+ if 'output_file' not in settings and 'output' not in settings:
+ print("Missing output file / directory")
+ sys.exit(1)
+
+ blkindex = get_block_hashes(settings)
+ blkset = mkblockset(blkindex)
+
+ if not "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" in blkset:
+ print("not found")
+ else:
+ copydata(settings, blkindex, blkset)
+
+
diff --git a/contrib/linearize/linearize.py b/contrib/linearize/linearize-hashes.py
index 650f7d3684..791b71bc33 100644..100755
--- a/contrib/linearize/linearize.py
+++ b/contrib/linearize/linearize-hashes.py
@@ -1,7 +1,6 @@
#!/usr/bin/python
#
-# linearize.py: Construct a linear, no-fork, best version of the blockchain.
-#
+# linearize-hashes.py: List blocks in a linear, no-fork version of the chain.
#
# Copyright (c) 2013 The Bitcoin developers
# Distributed under the MIT/X11 software license, see the accompanying
@@ -15,9 +14,6 @@ import base64
import httplib
import sys
-ERR_SLEEP = 15
-MAX_NONCE = 1000000L
-
settings = {}
class BitcoinRPC:
@@ -62,34 +58,18 @@ class BitcoinRPC:
def getblockhash(self, index):
return self.rpc('getblockhash', [index])
-def getblock(rpc, settings, n):
- hash = rpc.getblockhash(n)
- hexdata = rpc.getblock(hash, False)
- data = hexdata.decode('hex')
-
- return data
-
-def get_blocks(settings):
+def get_block_hashes(settings):
rpc = BitcoinRPC(settings['host'], settings['port'],
settings['rpcuser'], settings['rpcpassword'])
- outf = open(settings['output'], 'ab')
-
for height in xrange(settings['min_height'], settings['max_height']+1):
- data = getblock(rpc, settings, height)
-
- outhdr = settings['netmagic']
- outhdr += struct.pack("<i", len(data))
+ hash = rpc.getblockhash(height)
- outf.write(outhdr)
- outf.write(data)
-
- if (height % 1000) == 0:
- sys.stdout.write("Wrote block " + str(height) + "\n")
+ print(hash)
if __name__ == '__main__':
if len(sys.argv) != 2:
- print "Usage: linearize.py CONFIG-FILE"
+ print "Usage: linearize-hashes.py CONFIG-FILE"
sys.exit(1)
f = open(sys.argv[1])
@@ -106,10 +86,6 @@ if __name__ == '__main__':
settings[m.group(1)] = m.group(2)
f.close()
- if 'netmagic' not in settings:
- settings['netmagic'] = 'f9beb4d9'
- if 'output' not in settings:
- settings['output'] = 'bootstrap.dat'
if 'host' not in settings:
settings['host'] = '127.0.0.1'
if 'port' not in settings:
@@ -117,16 +93,14 @@ if __name__ == '__main__':
if 'min_height' not in settings:
settings['min_height'] = 0
if 'max_height' not in settings:
- settings['max_height'] = 279000
+ settings['max_height'] = 313000
if 'rpcuser' not in settings or 'rpcpassword' not in settings:
print "Missing username and/or password in cfg file"
sys.exit(1)
- settings['netmagic'] = settings['netmagic'].decode('hex')
settings['port'] = int(settings['port'])
settings['min_height'] = int(settings['min_height'])
settings['max_height'] = int(settings['max_height'])
- get_blocks(settings)
-
+ get_block_hashes(settings)
diff --git a/depends/Makefile b/depends/Makefile
index d431653068..bd5f0bf536 100644
--- a/depends/Makefile
+++ b/depends/Makefile
@@ -72,7 +72,7 @@ packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(qt_pack
native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages) $(qt_native_packages_)
all_packages = $(packages) $(native_packages)
-meta_depends = Makefile builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk
+meta_depends = Makefile funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk
$(host_arch)_$(host_os)_native_toolchain?=$($(host_os)_native_toolchain)
diff --git a/depends/funcs.mk b/depends/funcs.mk
index 4c47cc926e..b5d8b0ee2e 100644
--- a/depends/funcs.mk
+++ b/depends/funcs.mk
@@ -20,7 +20,11 @@ $(sort $(foreach dep,$(2),$(2) $(call int_get_all_dependencies,$(1),$($(dep)_dep
endef
define fetch_file
-(test -f $(SOURCES_PATH)/$(3) || ( mkdir -p $$($(1)_extract_dir) && $(build_DOWNLOAD) "$$($(1)_extract_dir)/$(3).temp" "$(2)" && echo "$(4) $$($(1)_extract_dir)/$(3).temp" | $(build_SHA256SUM) -c && mv $$($(1)_extract_dir)/$(3).temp $(SOURCES_PATH)/$(3) ))
+(test -f $(SOURCES_PATH)/$(3) || \
+ ( mkdir -p $$($(1)_extract_dir) && $(build_DOWNLOAD) "$$($(1)_extract_dir)/$(3).temp" "$(2)" && \
+ echo "$(4) $$($(1)_extract_dir)/$(3).temp" > $$($(1)_extract_dir)/.$(3).hash && \
+ $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$(3).hash && \
+ mv $$($(1)_extract_dir)/$(3).temp $(SOURCES_PATH)/$(3) ))
endef
define int_get_build_recipe_hash
@@ -62,7 +66,7 @@ $(1)_download_path_fixed=$(subst :,\:,$$($(1)_download_path))
#default commands
$(1)_fetch_cmds ?= $(call fetch_file,$(1),$(subst \:,:,$$($(1)_download_path_fixed)/$$($(1)_download_file)),$($(1)_file_name),$($(1)_sha256_hash))
-$(1)_extract_cmds ?= echo "$$($(1)_sha256_hash) $$($(1)_source)" | $(build_SHA256SUM) -c && tar --strip-components=1 -xf $$($(1)_source)
+$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && tar --strip-components=1 -xf $$($(1)_source)
$(1)_preprocess_cmds ?=
$(1)_build_cmds ?=
$(1)_config_cmds ?=
diff --git a/doc/README.md b/doc/README.md
index f8bb8020d4..10c9ad1799 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -46,7 +46,6 @@ The following are developer notes on how to build Bitcoin on your native platfor
- [OSX Build Notes](build-osx.md)
- [Unix Build Notes](build-unix.md)
-- [Windows Build Notes](build-msw.md)
Development
---------------------
diff --git a/doc/build-osx.md b/doc/build-osx.md
index bc42723b12..ade9eb466b 100644
--- a/doc/build-osx.md
+++ b/doc/build-osx.md
@@ -69,21 +69,30 @@ Instructions: Homebrew
#### Install dependencies using Homebrew
- brew install autoconf automake libtool berkeley-db4 boost miniupnpc openssl pkg-config protobuf qt
+ brew install autoconf automake libtool boost miniupnpc openssl pkg-config protobuf qt
-Note: After you have installed the dependencies, you should check that the Homebrew installed version of OpenSSL is the one available for compilation. You can check this by typing
+#### Installing berkeley-db4 using Homebrew
- openssl version
+The homebrew package for berkeley-db4 has been broken for some time. It will install without Java though.
-into Terminal. You should see OpenSSL 1.0.1h 5 Jun 2014.
+Running this command takes you into brew's interactive mode, which allows you to configure, make, and install by hand:
+```
+$ brew install https://raw.github.com/mxcl/homebrew/master/Library/Formula/berkeley-db4.rb -–without-java
+```
-If not, you can ensure that the Homebrew OpenSSL is correctly linked by running
+These rest of these commands are run inside brew interactive mode:
+```
+/private/tmp/berkeley-db4-UGpd0O/db-4.8.30 $ cd ..
+/private/tmp/berkeley-db4-UGpd0O $ db-4.8.30/dist/configure --prefix=/usr/local/Cellar/berkeley-db4/4.8.30 --mandir=/usr/local/Cellar/berkeley-db4/4.8.30/share/man --enable-cxx
+/private/tmp/berkeley-db4-UGpd0O $ make
+/private/tmp/berkeley-db4-UGpd0O $ make install
+/private/tmp/berkeley-db4-UGpd0O $ exit
+```
- brew link openssl --force
+After exiting, you'll get a warning that the install is keg-only, which means it wasn't symlinked to `/usr/local`. You don't need it to link it to build bitcoin, but if you want to, here's how:
+
+ $ brew --force link berkeley-db4
-Rerunning "openssl version" should now return the correct version. If it
-doesn't, make sure `/usr/local/bin` comes before `/usr/bin` in your
-PATH.
### Building `bitcoind`
diff --git a/doc/build-unix.md b/doc/build-unix.md
index 0f381d56c5..8a76a8b2cd 100644
--- a/doc/build-unix.md
+++ b/doc/build-unix.md
@@ -76,10 +76,6 @@ for Ubuntu 12.04 and later:
Ubuntu 12.04 and later have packages for libdb5.1-dev and libdb5.1++-dev,
but using these will break binary wallet compatibility, and is not recommended.
-for Ubuntu 13.10:
- libboost1.54 will not work,
- remove libboost1.54-all-dev and install libboost1.53-all-dev instead.
-
for Debian 7 (Wheezy) and later:
The oldstable repository contains db4.8 packages.
Add the following line to /etc/apt/sources.list,
@@ -113,7 +109,7 @@ To build with Qt 4 you need the following:
For Qt 5 you need the following:
- sudo apt-get install libqt5gui5 libqt5core5 libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev
+ sudo apt-get install libqt5gui5 libqt5core5 libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
libqrencode (optional) can be installed with:
diff --git a/src/Makefile.am b/src/Makefile.am
index 2c00f8b572..6c67dee7d5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -55,12 +55,10 @@ if BUILD_BITCOIND
bin_PROGRAMS += bitcoind
endif
-if BUILD_BITCOIN_CLI
- bin_PROGRAMS += bitcoin-cli
+if BUILD_BITCOIN_UTILS
+ bin_PROGRAMS += bitcoin-cli bitcoin-tx
endif
-bin_PROGRAMS += bitcoin-tx
-
.PHONY: FORCE
# bitcoin core #
BITCOIN_CORE_H = \
@@ -187,6 +185,7 @@ univalue_libbitcoin_univalue_a_SOURCES = \
univalue/univalue.cpp \
univalue/univalue_read.cpp \
univalue/univalue_write.cpp \
+ univalue/univalue_escapes.h \
univalue/univalue.h
# common: shared between bitcoind, and bitcoin-qt and non-server tools
diff --git a/src/Makefile.test.include b/src/Makefile.test.include
index b54c9be664..cc407f679f 100644
--- a/src/Makefile.test.include
+++ b/src/Makefile.test.include
@@ -1,8 +1,20 @@
-TESTS += test/test_bitcoin
+TESTS += test/test_bitcoin test/bitcoin-util-test.py
bin_PROGRAMS += test/test_bitcoin
TEST_SRCDIR = test
TEST_BINARY=test/test_bitcoin$(EXEEXT)
+
+EXTRA_DIST += \
+ test/bctest.py \
+ test/bitcoin-util-test.py \
+ test/data/bitcoin-util-test.json \
+ test/data/blanktx.hex \
+ test/data/tt-delin1-out.hex \
+ test/data/tt-delout1-out.hex \
+ test/data/tt-locktime317000-out.hex \
+ test/data/tx394b54bb.hex \
+ test/data/txcreate1.hex
+
JSON_TEST_FILES = \
test/data/script_valid.json \
test/data/base58_keys_valid.json \
@@ -51,6 +63,7 @@ BITCOIN_TESTS =\
test/test_bitcoin.cpp \
test/transaction_tests.cpp \
test/uint256_tests.cpp \
+ test/univalue_tests.cpp \
test/util_tests.cpp \
test/scriptnum_tests.cpp \
test/sighash_tests.cpp
diff --git a/src/addrman.cpp b/src/addrman.cpp
index 3628af2eab..704766dbf8 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -492,17 +492,23 @@ int CAddrMan::Check_()
void CAddrMan::GetAddr_(std::vector<CAddress> &vAddr)
{
- int nNodes = ADDRMAN_GETADDR_MAX_PCT*vRandom.size()/100;
+ unsigned int nNodes = ADDRMAN_GETADDR_MAX_PCT * vRandom.size() / 100;
if (nNodes > ADDRMAN_GETADDR_MAX)
nNodes = ADDRMAN_GETADDR_MAX;
- // perform a random shuffle over the first nNodes elements of vRandom (selecting from all)
- for (int n = 0; n<nNodes; n++)
+ // gather a list of random nodes, skipping those of low quality
+ for (unsigned int n = 0; n < vRandom.size(); n++)
{
+ if (vAddr.size() >= nNodes)
+ break;
+
int nRndPos = GetRandInt(vRandom.size() - n) + n;
SwapRandom(n, nRndPos);
assert(mapInfo.count(vRandom[n]) == 1);
- vAddr.push_back(mapInfo[vRandom[n]]);
+
+ const CAddrInfo& ai = mapInfo[vRandom[n]];
+ if (!ai.IsTerrible())
+ vAddr.push_back(ai);
}
}
diff --git a/src/alert.cpp b/src/alert.cpp
index 258a2b52c4..2cd684cc4c 100644
--- a/src/alert.cpp
+++ b/src/alert.cpp
@@ -80,11 +80,6 @@ std::string CUnsignedAlert::ToString() const
strStatusBar);
}
-void CUnsignedAlert::print() const
-{
- LogPrintf("%s", ToString());
-}
-
void CAlert::SetNull()
{
CUnsignedAlert::SetNull();
diff --git a/src/alert.h b/src/alert.h
index da140be5e5..b9d850b565 100644
--- a/src/alert.h
+++ b/src/alert.h
@@ -60,15 +60,14 @@ public:
READWRITE(setSubVer);
READWRITE(nPriority);
- READWRITE(strComment);
- READWRITE(strStatusBar);
- READWRITE(strReserved);
+ READWRITE(LIMITED_STRING(strComment, 65536));
+ READWRITE(LIMITED_STRING(strStatusBar, 256));
+ READWRITE(LIMITED_STRING(strReserved, 256));
)
void SetNull();
std::string ToString() const;
- void print() const;
};
/** An alert is a combination of a serialized CUnsignedAlert and a signature. */
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp
index ffe87298f6..6cd2768d70 100644
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -13,6 +13,7 @@
#include <stdio.h>
#include <boost/assign/list_of.hpp>
+#include <boost/algorithm/string.hpp>
using namespace std;
using namespace boost::assign;
@@ -501,13 +502,34 @@ static void OutputTx(const CTransaction& tx)
OutputTxHex(tx);
}
+static string readStdin()
+{
+ char buf[4096];
+ string ret;
+
+ while (!feof(stdin)) {
+ size_t bread = fread(buf, 1, sizeof(buf), stdin);
+ ret.append(buf, bread);
+ if (bread < sizeof(buf))
+ break;
+ }
+
+ if (ferror(stdin))
+ throw runtime_error("error reading stdin");
+
+ boost::algorithm::trim_right(ret);
+
+ return ret;
+}
+
static int CommandLineRawTx(int argc, char* argv[])
{
string strPrint;
int nRet = 0;
try {
- // Skip switches
- while (argc > 1 && IsSwitchChar(argv[1][0])) {
+ // Skip switches; Permit common stdin convention "-"
+ while (argc > 1 && IsSwitchChar(argv[1][0]) &&
+ (argv[1][1] != 0)) {
argc--;
argv++;
}
@@ -522,6 +544,8 @@ static int CommandLineRawTx(int argc, char* argv[])
// param: hex-encoded bitcoin transaction
string strHexTx(argv[1]);
+ if (strHexTx == "-") // "-" implies standard input
+ strHexTx = readStdin();
if (!DecodeHexTx(txDecodeTmp, strHexTx))
throw runtime_error("invalid transaction encoding");
diff --git a/src/coins.cpp b/src/coins.cpp
index fe40911db7..6137b51c55 100644
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -57,7 +57,7 @@ bool CCoinsView::SetCoins(const uint256 &txid, const CCoins &coins) { return fal
bool CCoinsView::HaveCoins(const uint256 &txid) { return false; }
uint256 CCoinsView::GetBestBlock() { return uint256(0); }
bool CCoinsView::SetBestBlock(const uint256 &hashBlock) { return false; }
-bool CCoinsView::BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock) { return false; }
+bool CCoinsView::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { return false; }
bool CCoinsView::GetStats(CCoinsStats &stats) { return false; }
@@ -68,7 +68,7 @@ bool CCoinsViewBacked::HaveCoins(const uint256 &txid) { return base->HaveCoins(t
uint256 CCoinsViewBacked::GetBestBlock() { return base->GetBestBlock(); }
bool CCoinsViewBacked::SetBestBlock(const uint256 &hashBlock) { return base->SetBestBlock(hashBlock); }
void CCoinsViewBacked::SetBackend(CCoinsView &viewIn) { base = &viewIn; }
-bool CCoinsViewBacked::BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock) { return base->BatchWrite(mapCoins, hashBlock); }
+bool CCoinsViewBacked::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { return base->BatchWrite(mapCoins, hashBlock); }
bool CCoinsViewBacked::GetStats(CCoinsStats &stats) { return base->GetStats(stats); }
CCoinsKeyHasher::CCoinsKeyHasher() : salt(GetRandHash()) {}
@@ -130,17 +130,19 @@ bool CCoinsViewCache::SetBestBlock(const uint256 &hashBlockIn) {
return true;
}
-bool CCoinsViewCache::BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlockIn) {
- for (CCoinsMap::const_iterator it = mapCoins.begin(); it != mapCoins.end(); it++)
- cacheCoins[it->first] = it->second;
+bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlockIn) {
+ for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end();) {
+ cacheCoins[it->first].swap(it->second);
+ CCoinsMap::iterator itOld = it++;
+ mapCoins.erase(itOld);
+ }
hashBlock = hashBlockIn;
return true;
}
bool CCoinsViewCache::Flush() {
bool fOk = base->BatchWrite(cacheCoins, hashBlock);
- if (fOk)
- cacheCoins.clear();
+ cacheCoins.clear();
return fOk;
}
diff --git a/src/coins.h b/src/coins.h
index ff60288163..2b657299e3 100644
--- a/src/coins.h
+++ b/src/coins.h
@@ -291,8 +291,9 @@ public:
// Modify the currently active block hash
virtual bool SetBestBlock(const uint256 &hashBlock);
- // Do a bulk modification (multiple SetCoins + one SetBestBlock)
- virtual bool BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock);
+ // Do a bulk modification (multiple SetCoins + one SetBestBlock).
+ // The passed mapCoins can be modified.
+ virtual bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock);
// Calculate statistics about the unspent transaction output set
virtual bool GetStats(CCoinsStats &stats);
@@ -316,7 +317,7 @@ public:
uint256 GetBestBlock();
bool SetBestBlock(const uint256 &hashBlock);
void SetBackend(CCoinsView &viewIn);
- bool BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock);
+ bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock);
bool GetStats(CCoinsStats &stats);
};
@@ -337,7 +338,7 @@ public:
bool HaveCoins(const uint256 &txid);
uint256 GetBestBlock();
bool SetBestBlock(const uint256 &hashBlock);
- bool BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock);
+ bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock);
// Return a modifiable reference to a CCoins. Check HaveCoins first.
// Many methods explicitly require a CCoinsViewCache because of this method, to reduce
@@ -346,6 +347,7 @@ public:
// Push the modifications applied to this cache to its base.
// Failure to call this method before destruction will cause the changes to be forgotten.
+ // If false is returned, the state of this cache (and its backing view) will be undefined.
bool Flush();
// Calculate the size of the cache (in number of transactions)
diff --git a/src/core.cpp b/src/core.cpp
index 149b3532a1..71d6fea610 100644
--- a/src/core.cpp
+++ b/src/core.cpp
@@ -5,18 +5,13 @@
#include "core.h"
-#include "util.h"
+#include "tinyformat.h"
std::string COutPoint::ToString() const
{
return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n);
}
-void COutPoint::print() const
-{
- LogPrintf("%s\n", ToString());
-}
-
CTxIn::CTxIn(COutPoint prevoutIn, CScript scriptSigIn, unsigned int nSequenceIn)
{
prevout = prevoutIn;
@@ -46,11 +41,6 @@ std::string CTxIn::ToString() const
return str;
}
-void CTxIn::print() const
-{
- LogPrintf("%s\n", ToString());
-}
-
CTxOut::CTxOut(int64_t nValueIn, CScript scriptPubKeyIn)
{
nValue = nValueIn;
@@ -67,11 +57,6 @@ std::string CTxOut::ToString() const
return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue / COIN, nValue % COIN, scriptPubKey.ToString().substr(0,30));
}
-void CTxOut::print() const
-{
- LogPrintf("%s\n", ToString());
-}
-
CFeeRate::CFeeRate(int64_t nFeePaid, size_t nSize)
{
if (nSize > 0)
@@ -92,8 +77,7 @@ int64_t CFeeRate::GetFee(size_t nSize) const
std::string CFeeRate::ToString() const
{
- std::string result = FormatMoney(nSatoshisPerK) + " BTC/kB";
- return result;
+ return strprintf("%d.%08d BTC/kB", nSatoshisPerK / COIN, nSatoshisPerK % COIN);
}
CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::CURRENT_VERSION), nLockTime(0) {}
@@ -171,11 +155,6 @@ std::string CTransaction::ToString() const
return str;
}
-void CTransaction::print() const
-{
- LogPrintf("%s", ToString());
-}
-
// Amount compression:
// * If the amount is 0, output 0
// * first, divide the amount (in base units) by the largest power of 10 possible; call the exponent e (e is max 9)
@@ -285,9 +264,10 @@ uint256 CBlock::CheckMerkleBranch(uint256 hash, const std::vector<uint256>& vMer
return hash;
}
-void CBlock::print() const
+std::string CBlock::ToString() const
{
- LogPrintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
+ std::stringstream s;
+ s << strprintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
GetHash().ToString(),
nVersion,
hashPrevBlock.ToString(),
@@ -296,11 +276,11 @@ void CBlock::print() const
vtx.size());
for (unsigned int i = 0; i < vtx.size(); i++)
{
- LogPrintf(" ");
- vtx[i].print();
+ s << " " << vtx[i].ToString() << "\n";
}
- LogPrintf(" vMerkleTree: ");
+ s << " vMerkleTree: ";
for (unsigned int i = 0; i < vMerkleTree.size(); i++)
- LogPrintf("%s ", vMerkleTree[i].ToString());
- LogPrintf("\n");
+ s << " " << vMerkleTree[i].ToString();
+ s << "\n";
+ return s.str();
}
diff --git a/src/core.h b/src/core.h
index fb64e6c08e..9552f70254 100644
--- a/src/core.h
+++ b/src/core.h
@@ -47,7 +47,6 @@ public:
}
std::string ToString() const;
- void print() const;
};
/** An inpoint - a combination of a transaction and an index n into its vin */
@@ -107,7 +106,6 @@ public:
}
std::string ToString() const;
- void print() const;
};
@@ -200,7 +198,6 @@ public:
}
std::string ToString() const;
- void print() const;
};
@@ -279,7 +276,6 @@ public:
}
std::string ToString() const;
- void print() const;
};
/** A mutable version of CTransaction. */
@@ -497,7 +493,7 @@ public:
std::vector<uint256> GetMerkleBranch(int nIndex) const;
static uint256 CheckMerkleBranch(uint256 hash, const std::vector<uint256>& vMerkleBranch, int nIndex);
- void print() const;
+ std::string ToString() const;
};
diff --git a/src/crypter.cpp b/src/crypter.cpp
index 4c43e3a798..122e06d97e 100644
--- a/src/crypter.cpp
+++ b/src/crypter.cpp
@@ -152,6 +152,8 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn)
if (!SetCrypted())
return false;
+ bool keyPass = false;
+ bool keyFail = false;
CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin();
for (; mi != mapCryptedKeys.end(); ++mi)
{
@@ -159,16 +161,35 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn)
const std::vector<unsigned char> &vchCryptedSecret = (*mi).second.second;
CKeyingMaterial vchSecret;
if(!DecryptSecret(vMasterKeyIn, vchCryptedSecret, vchPubKey.GetHash(), vchSecret))
- return false;
+ {
+ keyFail = true;
+ break;
+ }
if (vchSecret.size() != 32)
- return false;
+ {
+ keyFail = true;
+ break;
+ }
CKey key;
key.Set(vchSecret.begin(), vchSecret.end(), vchPubKey.IsCompressed());
- if (key.GetPubKey() == vchPubKey)
+ if (key.GetPubKey() != vchPubKey)
+ {
+ keyFail = true;
break;
- return false;
+ }
+ keyPass = true;
+ if (fDecryptionThoroughlyChecked)
+ break;
+ }
+ if (keyPass && keyFail)
+ {
+ LogPrintf("The wallet is probably corrupted: Some keys decrypt but not all.");
+ assert(false);
}
+ if (keyFail || !keyPass)
+ return false;
vMasterKey = vMasterKeyIn;
+ fDecryptionThoroughlyChecked = true;
}
NotifyStatusChanged(this);
return true;
diff --git a/src/crypter.h b/src/crypter.h
index 4791428b48..f16fcef9c7 100644
--- a/src/crypter.h
+++ b/src/crypter.h
@@ -121,6 +121,9 @@ private:
// if fUseCrypto is false, vMasterKey must be empty
bool fUseCrypto;
+ // keeps track of whether Unlock has run a thourough check before
+ bool fDecryptionThoroughlyChecked;
+
protected:
bool SetCrypted();
@@ -130,7 +133,7 @@ protected:
bool Unlock(const CKeyingMaterial& vMasterKeyIn);
public:
- CCryptoKeyStore() : fUseCrypto(false)
+ CCryptoKeyStore() : fUseCrypto(false), fDecryptionThoroughlyChecked(false)
{
}
diff --git a/src/db.h b/src/db.h
index 66d7f31917..bba267b84f 100644
--- a/src/db.h
+++ b/src/db.h
@@ -17,7 +17,6 @@
#include <boost/filesystem/path.hpp>
#include <db_cxx.h>
-class CAddrMan;
struct CBlockLocator;
class CDiskBlockIndex;
class COutPoint;
diff --git a/src/init.cpp b/src/init.cpp
index 8ae228bbbe..708e6386aa 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -247,7 +247,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += " -maxreceivebuffer=<n> " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)") + "\n";
strUsage += " -maxsendbuffer=<n> " + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)") + "\n";
strUsage += " -onion=<ip:port> " + _("Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: -proxy)") + "\n";
- strUsage += " -onlynet=<net> " + _("Only connect to nodes in network <net> (IPv4, IPv6 or Tor)") + "\n";
+ strUsage += " -onlynet=<net> " + _("Only connect to nodes in network <net> (ipv4, ipv6 or onion)") + "\n";
strUsage += " -permitbaremultisig " + _("Relay non-P2SH multisig (default: 1)") + "\n";
strUsage += " -port=<port> " + _("Listen for connections on <port> (default: 8333 or testnet: 18333)") + "\n";
strUsage += " -proxy=<ip:port> " + _("Connect through SOCKS5 proxy") + "\n";
@@ -1029,8 +1029,7 @@ bool AppInit2(boost::thread_group& threadGroup)
CBlock block;
ReadBlockFromDisk(block, pindex);
block.BuildMerkleTree();
- block.print();
- LogPrintf("\n");
+ LogPrintf("%s\n", block.ToString());
nFound++;
}
}
diff --git a/src/m4/ax_boost_base.m4 b/src/m4/ax_boost_base.m4
index e025a7e1ca..3f24d5ddc6 100644
--- a/src/m4/ax_boost_base.m4
+++ b/src/m4/ax_boost_base.m4
@@ -112,6 +112,12 @@ if test "x$want_boost" = "xyes"; then
;;
esac
+ dnl some arches may advertise a cpu type that doesn't line up with their
+ dnl prefix's cpu type. For example, uname may report armv7l while libs are
+ dnl installed to /usr/lib/arm-linux-gnueabihf. Try getting the compiler's
+ dnl value for an extra chance of finding the correct path.
+ libsubdirs="lib/`$CXX -dumpmachine 2>/dev/null` $libsubdirs"
+
dnl first we check the system location for boost libraries
dnl this location ist chosen if boost libraries are installed with the --layout=system option
dnl or if you install boost with RPM
diff --git a/src/m4/bitcoin_qt.m4 b/src/m4/bitcoin_qt.m4
index 4c1d40c394..e141033b19 100644
--- a/src/m4/bitcoin_qt.m4
+++ b/src/m4/bitcoin_qt.m4
@@ -48,8 +48,8 @@ dnl CAUTION: Do not use this inside of a conditional.
AC_DEFUN([BITCOIN_QT_INIT],[
dnl enable qt support
AC_ARG_WITH([gui],
- [AS_HELP_STRING([--with-gui],
- [with GUI (no|qt4|qt5|auto. default is auto, qt4 tried first.)])],
+ [AS_HELP_STRING([--with-gui@<:@=no|qt4|qt5|auto@:>@],
+ [build bitcoin-qt GUI (default=auto, qt4 tried first)])],
[
bitcoin_qt_want_version=$withval
if test x$bitcoin_qt_want_version = xyes; then
@@ -112,11 +112,7 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
if test x$qt_plugin_path != x; then
QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible"
- if test x$bitcoin_qt_got_major_vers == x5; then
- QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms"
- else
- QT_LIBS="$QT_LIBS -L$qt_plugin_path/codecs"
- fi
+ QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms"
fi
if test x$use_pkgconfig = xyes; then
PKG_CHECK_MODULES([QTPLATFORM], [Qt5PlatformSupport], [QT_LIBS="$QTPLATFORM_LIBS $QT_LIBS"])
@@ -141,6 +137,10 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
else
if test x$TARGET_OS == xwindows; then
AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
+ if test x$qt_plugin_path != x; then
+ QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible"
+ QT_LIBS="$QT_LIBS -L$qt_plugin_path/codecs"
+ fi
_BITCOIN_QT_CHECK_STATIC_PLUGINS([
Q_IMPORT_PLUGIN(qcncodecs)
Q_IMPORT_PLUGIN(qjpcodecs)
diff --git a/src/main.cpp b/src/main.cpp
index d8f96ed2c3..947494ce62 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -20,6 +20,7 @@
#include <sstream>
+#include <boost/dynamic_bitset.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
@@ -3233,7 +3234,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
}
}
uint64_t nRewind = blkdat.GetPos();
- while (blkdat.good() && !blkdat.eof()) {
+ while (!blkdat.eof()) {
boost::this_thread::interruption_point();
blkdat.SetPos(nRewind);
@@ -3517,6 +3518,75 @@ void static ProcessGetData(CNode* pfrom)
}
}
+struct CCoin {
+ uint32_t nTxVer; // Don't call this nVersion, that name has a special meaning inside IMPLEMENT_SERIALIZE
+ uint32_t nHeight;
+ CTxOut out;
+
+ IMPLEMENT_SERIALIZE(
+ READWRITE(nTxVer);
+ READWRITE(nHeight);
+ READWRITE(out);
+ )
+};
+
+bool ProcessGetUTXOs(const vector<COutPoint> &vOutPoints, bool fCheckMemPool, vector<unsigned char> *result, vector<CCoin> *resultCoins)
+{
+ // Defined by BIP 64.
+ //
+ // Allows a peer to retrieve the CTxOut structures corresponding to the given COutPoints.
+ // Note that this data is not authenticated by anything: this code could just invent any
+ // old rubbish and hand it back, with the peer being unable to tell unless they are checking
+ // the outpoints against some out of band data.
+ //
+ // Also the answer could change the moment after we give it. However some apps can tolerate
+ // this, because they're only using the result as a hint or are willing to trust the results
+ // based on something else. For example we may be a "trusted node" for the peer, or it may
+ // be checking the results given by several nodes for consistency, it may
+ // run the UTXOs returned against scriptSigs of transactions obtained elsewhere (after checking
+ // for a standard script form), and because the height in which the UTXO was defined is provided
+ // a client that has a map of heights to block headers (as SPV clients do, for recent blocks)
+ // can request the creating block via hash.
+ //
+ // IMPORTANT: Clients expect ordering to be preserved!
+ if (vOutPoints.size() > MAX_INV_SZ)
+ return error("message getutxos size() = %u", vOutPoints.size());
+
+ LogPrint("net", "getutxos for %d queries %s mempool\n", vOutPoints.size(), fCheckMemPool ? "with" : "without");
+
+ boost::dynamic_bitset<unsigned char> hits(vOutPoints.size());
+ {
+ LOCK2(cs_main, mempool.cs);
+ CCoinsViewMemPool cvMemPool(*pcoinsTip, mempool);
+ CCoinsViewCache view(fCheckMemPool ? cvMemPool : *pcoinsTip);
+ for (size_t i = 0; i < vOutPoints.size(); i++)
+ {
+ CCoins coins;
+ uint256 hash = vOutPoints[i].hash;
+ if (view.GetCoins(hash, coins))
+ {
+ mempool.pruneSpent(hash, coins);
+ if (coins.IsAvailable(vOutPoints[i].n))
+ {
+ hits[i] = true;
+ // Safe to index into vout here because IsAvailable checked if it's off the end of the array, or if
+ // n is valid but points to an already spent output (IsNull).
+ CCoin coin;
+ coin.nTxVer = coins.nVersion;
+ coin.nHeight = coins.nHeight;
+ coin.out = coins.vout.at(vOutPoints[i].n);
+ assert(!coin.out.IsNull());
+ resultCoins->push_back(coin);
+ }
+ }
+ }
+ }
+
+ boost::to_block_range(hits, std::back_inserter(*result));
+ return true;
+}
+
+
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived)
{
RandAddSeedPerfmon();
@@ -3564,7 +3634,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
if (!vRecv.empty())
vRecv >> addrFrom >> nNonce;
if (!vRecv.empty()) {
- vRecv >> pfrom->strSubVer;
+ vRecv >> LIMITED_STRING(pfrom->strSubVer, 256);
pfrom->cleanSubVer = SanitizeString(pfrom->strSubVer);
}
if (!vRecv.empty())
@@ -3865,6 +3935,22 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
}
+ else if (strCommand == "getutxos")
+ {
+ bool fCheckMemPool;
+ vector<COutPoint> vOutPoints;
+ vRecv >> fCheckMemPool;
+ vRecv >> vOutPoints;
+
+ vector<unsigned char> bitmap;
+ vector<CCoin> outs;
+ if (ProcessGetUTXOs(vOutPoints, fCheckMemPool, &bitmap, &outs))
+ pfrom->PushMessage("utxos", chainActive.Height(), chainActive.Tip()->GetBlockHash(), bitmap, outs);
+ else
+ Misbehaving(pfrom->GetId(), 20);
+ }
+
+
else if (strCommand == "tx")
{
vector<uint256> vWorkQueue;
@@ -3964,7 +4050,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
vRecv >> block;
LogPrint("net", "received block %s peer=%d\n", block.GetHash().ToString(), pfrom->id);
- // block.print();
CInv inv(MSG_BLOCK, block.GetHash());
pfrom->AddInventoryKnown(inv);
@@ -4188,7 +4273,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
if (fDebug)
{
string strMsg; unsigned char ccode; string strReason;
- vRecv >> strMsg >> ccode >> strReason;
+ vRecv >> LIMITED_STRING(strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING(strReason, 111);
ostringstream ss;
ss << strMsg << " code " << itostr(ccode) << ": " << strReason;
@@ -4199,10 +4284,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
vRecv >> hash;
ss << ": hash " << hash.ToString();
}
- // Truncate to reasonable length and sanitize before printing:
- string s = ss.str();
- if (s.size() > 111) s.erase(111, string::npos);
- LogPrint("net", "Reject %s\n", SanitizeString(s));
+ LogPrint("net", "Reject %s\n", SanitizeString(ss.str()));
}
}
diff --git a/src/main.h b/src/main.h
index 01d3f119e1..886cac1507 100644
--- a/src/main.h
+++ b/src/main.h
@@ -839,11 +839,6 @@ public:
GetBlockHash().ToString());
}
- void print() const
- {
- LogPrintf("%s\n", ToString());
- }
-
// Check whether this block index entry is valid up to the passed validity level.
bool IsValid(enum BlockStatus nUpTo = BLOCK_VALID_TRANSACTIONS) const
{
@@ -935,11 +930,6 @@ public:
hashPrev.ToString());
return str;
}
-
- void print() const
- {
- LogPrintf("%s\n", ToString());
- }
};
/** Capture information about block/transaction validation */
diff --git a/src/miner.cpp b/src/miner.cpp
index 9408d2c5aa..06acff1c33 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -42,14 +42,6 @@ public:
COrphan(const CTransaction* ptxIn) : ptx(ptxIn), feeRate(0), dPriority(0)
{
}
-
- void print() const
- {
- LogPrintf("COrphan(hash=%s, dPriority=%.1f, fee=%s)\n",
- ptx->GetHash().ToString(), dPriority, feeRate.ToString());
- BOOST_FOREACH(uint256 hash, setDependsOn)
- LogPrintf(" setDependsOn %s\n", hash.ToString());
- }
};
uint64_t nLastBlockTx = 0;
@@ -404,7 +396,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
{
- pblock->print();
+ LogPrintf("%s\n", pblock->ToString());
LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue));
// Found a solution
diff --git a/src/net.cpp b/src/net.cpp
index ec58f84b06..cae9b70da7 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -66,7 +66,7 @@ namespace {
//
bool fDiscover = true;
bool fListen = true;
-uint64_t nLocalServices = NODE_NETWORK;
+uint64_t nLocalServices = NODE_NETWORK | NODE_GETUTXOS;
CCriticalSection cs_mapLocalHost;
map<CNetAddr, LocalServiceInfo> mapLocalHost;
static bool vfReachable[NET_MAX] = {};
@@ -307,12 +307,18 @@ bool IsLocal(const CService& addr)
return mapLocalHost.count(addr) > 0;
}
+/** check whether a given network is one we can probably connect to */
+bool IsReachable(enum Network net)
+{
+ LOCK(cs_mapLocalHost);
+ return vfReachable[net] && !vfLimited[net];
+}
+
/** check whether a given address is in a network we can probably connect to */
bool IsReachable(const CNetAddr& addr)
{
- LOCK(cs_mapLocalHost);
enum Network net = addr.GetNetwork();
- return vfReachable[net] && !vfLimited[net];
+ return IsReachable(net);
}
bool GetMyExternalIP2(const CService& addrConnect, const char* pszGet, const char* pszKeyword, CNetAddr& ipRet)
diff --git a/src/net.h b/src/net.h
index a8795a4760..1a7b3c00b8 100644
--- a/src/net.h
+++ b/src/net.h
@@ -106,6 +106,7 @@ bool AddLocal(const CNetAddr& addr, int nScore = LOCAL_NONE);
bool SeenLocal(const CService& addr);
bool IsLocal(const CService& addr);
bool GetLocal(CService &addr, const CNetAddr *paddrPeer = NULL);
+bool IsReachable(enum Network net);
bool IsReachable(const CNetAddr &addr);
void SetReachable(enum Network net, bool fFlag = true);
CAddress GetLocalAddress(const CNetAddr *paddrPeer = NULL);
diff --git a/src/netbase.cpp b/src/netbase.cpp
index 1031e7e38a..e9207da330 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -47,10 +47,20 @@ enum Network ParseNetwork(std::string net) {
boost::to_lower(net);
if (net == "ipv4") return NET_IPV4;
if (net == "ipv6") return NET_IPV6;
- if (net == "tor") return NET_TOR;
+ if (net == "tor" || net == "onion") return NET_TOR;
return NET_UNROUTABLE;
}
+std::string GetNetworkName(enum Network net) {
+ switch(net)
+ {
+ case NET_IPV4: return "ipv4";
+ case NET_IPV6: return "ipv6";
+ case NET_TOR: return "onion";
+ default: return "";
+ }
+}
+
void SplitHostPort(std::string in, int &portOut, std::string &hostOut) {
size_t colon = in.find_last_of(':');
// if a : is found, and it either follows a [...], or no other : is in the string, treat it as port separator
@@ -864,11 +874,6 @@ uint64_t CNetAddr::GetHash() const
return nRet;
}
-void CNetAddr::print() const
-{
- LogPrintf("CNetAddr(%s)\n", ToString());
-}
-
// private extensions to enum Network, only returned by GetExtNetwork,
// and only used in GetReachabilityFrom
static const int NET_UNKNOWN = NET_MAX + 0;
@@ -1097,11 +1102,6 @@ std::string CService::ToString() const
return ToStringIPPort();
}
-void CService::print() const
-{
- LogPrintf("CService(%s)\n", ToString());
-}
-
void CService::SetPort(unsigned short portIn)
{
port = portIn;
diff --git a/src/netbase.h b/src/netbase.h
index 7d83e35344..2df3c4474d 100644
--- a/src/netbase.h
+++ b/src/netbase.h
@@ -26,7 +26,7 @@ extern bool fNameLookup;
enum Network
{
- NET_UNROUTABLE,
+ NET_UNROUTABLE = 0,
NET_IPV4,
NET_IPV6,
NET_TOR,
@@ -80,7 +80,6 @@ class CNetAddr
bool GetInAddr(struct in_addr* pipv4Addr) const;
std::vector<unsigned char> GetGroup() const;
int GetReachabilityFrom(const CNetAddr *paddrPartner = NULL) const;
- void print() const;
CNetAddr(const struct in6_addr& pipv6Addr);
bool GetIn6Addr(struct in6_addr* pipv6Addr) const;
@@ -145,7 +144,6 @@ class CService : public CNetAddr
std::string ToString() const;
std::string ToStringPort() const;
std::string ToStringIPPort() const;
- void print() const;
CService(const struct in6_addr& ipv6Addr, unsigned short port);
CService(const struct sockaddr_in6& addr);
@@ -164,6 +162,7 @@ class CService : public CNetAddr
typedef CService proxyType;
enum Network ParseNetwork(std::string net);
+std::string GetNetworkName(enum Network net);
void SplitHostPort(std::string in, int &portOut, std::string &hostOut);
bool SetProxy(enum Network net, CService addrProxy);
bool GetProxy(enum Network net, proxyType &proxyInfoOut);
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 87b2f23873..341de0602a 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -144,9 +144,3 @@ std::string CInv::ToString() const
{
return strprintf("%s %s", GetCommand(), hash.ToString());
}
-
-void CInv::print() const
-{
- LogPrintf("CInv(%s)\n", ToString());
-}
-
diff --git a/src/protocol.h b/src/protocol.h
index 1f23274299..94d313e9c0 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -64,6 +64,7 @@ class CMessageHeader
enum
{
NODE_NETWORK = (1 << 0),
+ NODE_GETUTXOS = (1 << 1),
// Bits 24-31 are reserved for temporary experiments. Just pick a bit that
// isn't getting used, or one not being used much, and notify the
@@ -98,8 +99,6 @@ class CAddress : public CService
READWRITE(*pip);
)
- void print() const;
-
// TODO: make private (improves encapsulation)
public:
uint64_t nServices;
@@ -130,7 +129,6 @@ class CInv
bool IsKnownType() const;
const char* GetCommand() const;
std::string ToString() const;
- void print() const;
// TODO: make private (improves encapsulation)
public:
diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui
index 7784a862d7..53d416ef38 100644
--- a/src/qt/forms/overviewpage.ui
+++ b/src/qt/forms/overviewpage.ui
@@ -13,8 +13,8 @@
<property name="windowTitle">
<string>Form</string>
</property>
- <layout class="QFormLayout" name="formLayout_3">
- <item row="0" column="0" colspan="2">
+ <layout class="QVBoxLayout" name="topLayout">
+ <item>
<widget class="QLabel" name="labelAlerts">
<property name="visible">
<bool>false</bool>
@@ -30,7 +30,7 @@
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index 389a08d9e8..304177ee11 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -810,7 +810,7 @@ QString formatDurationStr(int secs)
return strList.join(" ");
}
-QString formatServicesStr(uint64_t mask)
+QString formatServicesStr(quint64 mask)
{
QStringList strList;
diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h
index 0ae5154d4b..67e11e59a0 100644
--- a/src/qt/guiutil.h
+++ b/src/qt/guiutil.h
@@ -180,7 +180,7 @@ namespace GUIUtil
QString formatDurationStr(int secs);
/* Format CNodeStats.nServices bitmask into a user-readable string */
- QString formatServicesStr(uint64_t mask);
+ QString formatServicesStr(quint64 mask);
/* Format a CNodeCombinedStats.dPingTime into a user-readable string or display N/A, if 0*/
QString formatPingTime(double dPingTime);
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 0ad123f39d..c5f8fb6a9c 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -31,7 +31,6 @@ WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *p
transactionTableModel(0),
recentRequestsTableModel(0),
cachedBalance(0), cachedUnconfirmedBalance(0), cachedImmatureBalance(0),
- cachedNumTransactions(0),
cachedEncryptionStatus(Unencrypted),
cachedNumBlocks(0)
{
@@ -96,18 +95,6 @@ qint64 WalletModel::getWatchImmatureBalance() const
return wallet->GetImmatureWatchOnlyBalance();
}
-int WalletModel::getNumTransactions() const
-{
- int numTransactions = 0;
- {
- LOCK(wallet->cs_wallet);
- // the size of mapWallet contains the number of unique transaction IDs
- // (e.g. payments to yourself generate 2 transactions, but both share the same transaction ID)
- numTransactions = wallet->mapWallet.size();
- }
- return numTransactions;
-}
-
void WalletModel::updateStatus()
{
EncryptionStatus newEncryptionStatus = getEncryptionStatus();
@@ -169,13 +156,6 @@ void WalletModel::updateTransaction(const QString &hash, int status)
// Balance and number of transactions might have changed
checkBalanceChanged();
-
- int newNumTransactions = getNumTransactions();
- if(cachedNumTransactions != newNumTransactions)
- {
- cachedNumTransactions = newNumTransactions;
- emit numTransactionsChanged(newNumTransactions);
- }
}
void WalletModel::updateAddressBook(const QString &address, const QString &label,
diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h
index 2bb91d85a9..2a74a6aa79 100644
--- a/src/qt/walletmodel.h
+++ b/src/qt/walletmodel.h
@@ -131,7 +131,6 @@ public:
qint64 getWatchBalance() const;
qint64 getWatchUnconfirmedBalance() const;
qint64 getWatchImmatureBalance() const;
- int getNumTransactions() const;
EncryptionStatus getEncryptionStatus() const;
bool processingQueuedTransactions() { return fProcessingQueuedTransactions; }
@@ -214,7 +213,6 @@ private:
qint64 cachedWatchOnlyBalance;
qint64 cachedWatchUnconfBalance;
qint64 cachedWatchImmatureBalance;
- qint64 cachedNumTransactions;
EncryptionStatus cachedEncryptionStatus;
int cachedNumBlocks;
@@ -229,9 +227,6 @@ signals:
void balanceChanged(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance,
qint64 watchOnlyBalance, qint64 watchUnconfBalance, qint64 watchImmatureBalance);
- // Number of transactions in wallet changed
- void numTransactionsChanged(int count);
-
// Encryption status of wallet changed
void encryptionStatusChanged(int status);
diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp
index 88e7c4ab07..2baa481c4e 100644
--- a/src/rpcnet.cpp
+++ b/src/rpcnet.cpp
@@ -338,6 +338,26 @@ Value getnettotals(const Array& params, bool fHelp)
return obj;
}
+static Array GetNetworksInfo()
+{
+ Array networks;
+ for(int n=0; n<NET_MAX; ++n)
+ {
+ enum Network network = static_cast<enum Network>(n);
+ if(network == NET_UNROUTABLE)
+ continue;
+ proxyType proxy;
+ Object obj;
+ GetProxy(network, proxy);
+ obj.push_back(Pair("name", GetNetworkName(network)));
+ obj.push_back(Pair("limited", IsLimited(network)));
+ obj.push_back(Pair("reachable", IsReachable(network)));
+ obj.push_back(Pair("proxy", proxy.IsValid() ? proxy.ToStringIPPort() : string()));
+ networks.push_back(obj);
+ }
+ return networks;
+}
+
Value getnetworkinfo(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
@@ -351,7 +371,13 @@ Value getnetworkinfo(const Array& params, bool fHelp)
" \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n"
" \"timeoffset\": xxxxx, (numeric) the time offset\n"
" \"connections\": xxxxx, (numeric) the number of connections\n"
- " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n"
+ " \"networks\": [ (array) information per network\n"
+ " \"name\": \"xxx\", (string) network (ipv4, ipv6 or onion)\n"
+ " \"limited\": xxx, (boolean) is the network limited using -onlynet?\n"
+ " \"reachable\": xxx, (boolean) is the network reachable?\n"
+ " \"proxy\": \"host:port\" (string) the proxy that is used for this network, or empty if none\n"
+ " },\n"
+ " ],\n"
" \"relayfee\": x.xxxx, (numeric) minimum relay fee for non-free transactions in btc/kb\n"
" \"localaddresses\": [, (array) list of local addresses\n"
" \"address\": \"xxxx\", (string) network address\n"
@@ -364,16 +390,13 @@ Value getnetworkinfo(const Array& params, bool fHelp)
+ HelpExampleRpc("getnetworkinfo", "")
);
- proxyType proxy;
- GetProxy(NET_IPV4, proxy);
-
Object obj;
obj.push_back(Pair("version", (int)CLIENT_VERSION));
obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION));
obj.push_back(Pair("localservices", strprintf("%016x", nLocalServices)));
obj.push_back(Pair("timeoffset", GetTimeOffset()));
obj.push_back(Pair("connections", (int)vNodes.size()));
- obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.ToStringIPPort() : string())));
+ obj.push_back(Pair("networks", GetNetworksInfo()));
obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())));
Array localAddresses;
{
diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp
index 3b51c91e7c..524627e2de 100644
--- a/src/rpcserver.cpp
+++ b/src/rpcserver.cpp
@@ -849,11 +849,10 @@ static bool HTTPReq_JSONRPC(AcceptedConnection *conn,
if (!HTTPAuthorized(mapHeaders))
{
LogPrintf("ThreadRPCServer incorrect password attempt from %s\n", conn->peer_address_to_string());
- /* Deter brute-forcing short passwords.
+ /* Deter brute-forcing
If this results in a DoS the user really
shouldn't have their RPC port exposed. */
- if (mapArgs["-rpcpassword"].size() < 20)
- MilliSleep(250);
+ MilliSleep(250);
conn->stream() << HTTPError(HTTP_UNAUTHORIZED, false) << std::flush;
return false;
diff --git a/src/script.h b/src/script.h
index 7cb863d1c9..1e2cc94efe 100644
--- a/src/script.h
+++ b/src/script.h
@@ -730,6 +730,12 @@ public:
{
return CScriptID(Hash160(*this));
}
+
+ void clear()
+ {
+ // The default std::vector::clear() does not release memory.
+ std::vector<unsigned char>().swap(*this);
+ }
};
/** Compact serializer for scripts.
diff --git a/src/serialize.h b/src/serialize.h
index f876efd9b5..17cb724bee 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -68,7 +68,7 @@ inline const T* end_ptr(const std::vector<T,TAl>& v)
/////////////////////////////////////////////////////////////////
//
// Templates for serializing to anything that looks like a stream,
-// i.e. anything that supports .read(char*, int) and .write(char*, int)
+// i.e. anything that supports .read(char*, size_t) and .write(char*, size_t)
//
enum
@@ -334,8 +334,9 @@ I ReadVarInt(Stream& is)
}
}
-#define FLATDATA(obj) REF(CFlatData((char*)&(obj), (char*)&(obj) + sizeof(obj)))
-#define VARINT(obj) REF(WrapVarInt(REF(obj)))
+#define FLATDATA(obj) REF(CFlatData((char*)&(obj), (char*)&(obj) + sizeof(obj)))
+#define VARINT(obj) REF(WrapVarInt(REF(obj)))
+#define LIMITED_STRING(obj,n) REF(LimitedString< n >(REF(obj)))
/** Wrapper for serializing arrays and POD.
*/
@@ -398,6 +399,40 @@ public:
}
};
+template<size_t Limit>
+class LimitedString
+{
+protected:
+ std::string& string;
+public:
+ LimitedString(std::string& string) : string(string) {}
+
+ template<typename Stream>
+ void Unserialize(Stream& s, int, int=0)
+ {
+ size_t size = ReadCompactSize(s);
+ if (size > Limit) {
+ throw std::ios_base::failure("String length limit exceeded");
+ }
+ string.resize(size);
+ if (size != 0)
+ s.read((char*)&string[0], size);
+ }
+
+ template<typename Stream>
+ void Serialize(Stream& s, int, int=0) const
+ {
+ WriteCompactSize(s, string.size());
+ if (!string.empty())
+ s.write((char*)&string[0], string.size());
+ }
+
+ unsigned int GetSerializeSize(int, int=0) const
+ {
+ return GetSizeOfCompactSize(string.size()) + string.size();
+ }
+};
+
template<typename I>
CVarInt<I> WrapVarInt(I& n) { return CVarInt<I>(n); }
@@ -841,7 +876,7 @@ public:
CSizeComputer(int nTypeIn, int nVersionIn) : nSize(0), nType(nTypeIn), nVersion(nVersionIn) {}
- CSizeComputer& write(const char *psz, int nSize)
+ CSizeComputer& write(const char *psz, size_t nSize)
{
this->nSize += nSize;
return *this;
@@ -870,8 +905,6 @@ protected:
typedef CSerializeData vector_type;
vector_type vch;
unsigned int nReadPos;
- short state;
- short exceptmask;
public:
int nType;
int nVersion;
@@ -923,8 +956,6 @@ public:
nReadPos = 0;
nType = nTypeIn;
nVersion = nVersionIn;
- state = 0;
- exceptmask = std::ios::badbit | std::ios::failbit;
}
CDataStream& operator+=(const CDataStream& b)
@@ -1047,19 +1078,7 @@ public:
//
// Stream subset
//
- void setstate(short bits, const char* psz)
- {
- state |= bits;
- if (state & exceptmask)
- throw std::ios_base::failure(psz);
- }
-
bool eof() const { return size() == 0; }
- bool fail() const { return state & (std::ios::badbit | std::ios::failbit); }
- bool good() const { return !eof() && (state == 0); }
- void clear(short n) { state = n; } // name conflict with vector clear()
- short exceptions() { return exceptmask; }
- short exceptions(short mask) { short prev = exceptmask; exceptmask = mask; setstate(0, "CDataStream"); return prev; }
CDataStream* rdbuf() { return this; }
int in_avail() { return size(); }
@@ -1070,18 +1089,15 @@ public:
void ReadVersion() { *this >> nVersion; }
void WriteVersion() { *this << nVersion; }
- CDataStream& read(char* pch, int nSize)
+ CDataStream& read(char* pch, size_t nSize)
{
// Read from the beginning of the buffer
- assert(nSize >= 0);
unsigned int nReadPosNext = nReadPos + nSize;
if (nReadPosNext >= vch.size())
{
if (nReadPosNext > vch.size())
{
- setstate(std::ios::failbit, "CDataStream::read() : end of data");
- memset(pch, 0, nSize);
- nSize = vch.size() - nReadPos;
+ throw std::ios_base::failure("CDataStream::read() : end of data");
}
memcpy(pch, &vch[nReadPos], nSize);
nReadPos = 0;
@@ -1101,7 +1117,7 @@ public:
if (nReadPosNext >= vch.size())
{
if (nReadPosNext > vch.size())
- setstate(std::ios::failbit, "CDataStream::ignore() : end of data");
+ throw std::ios_base::failure("CDataStream::ignore() : end of data");
nReadPos = 0;
vch.clear();
return (*this);
@@ -1110,10 +1126,9 @@ public:
return (*this);
}
- CDataStream& write(const char* pch, int nSize)
+ CDataStream& write(const char* pch, size_t nSize)
{
// Write to the end of the buffer
- assert(nSize >= 0);
vch.insert(vch.end(), pch, pch + nSize);
return (*this);
}
@@ -1174,8 +1189,6 @@ class CAutoFile
{
protected:
FILE* file;
- short state;
- short exceptmask;
public:
int nType;
int nVersion;
@@ -1185,8 +1198,6 @@ public:
file = filenew;
nType = nTypeIn;
nVersion = nVersionIn;
- state = 0;
- exceptmask = std::ios::badbit | std::ios::failbit;
}
~CAutoFile()
@@ -1213,19 +1224,6 @@ public:
//
// Stream subset
//
- void setstate(short bits, const char* psz)
- {
- state |= bits;
- if (state & exceptmask)
- throw std::ios_base::failure(psz);
- }
-
- bool fail() const { return state & (std::ios::badbit | std::ios::failbit); }
- bool good() const { return state == 0; }
- void clear(short n = 0) { state = n; }
- short exceptions() { return exceptmask; }
- short exceptions(short mask) { short prev = exceptmask; exceptmask = mask; setstate(0, "CAutoFile"); return prev; }
-
void SetType(int n) { nType = n; }
int GetType() { return nType; }
void SetVersion(int n) { nVersion = n; }
@@ -1238,7 +1236,7 @@ public:
if (!file)
throw std::ios_base::failure("CAutoFile::read : file handle is NULL");
if (fread(pch, 1, nSize, file) != nSize)
- setstate(std::ios::failbit, feof(file) ? "CAutoFile::read : end of file" : "CAutoFile::read : fread failed");
+ throw std::ios_base::failure(feof(file) ? "CAutoFile::read : end of file" : "CAutoFile::read : fread failed");
return (*this);
}
@@ -1247,7 +1245,7 @@ public:
if (!file)
throw std::ios_base::failure("CAutoFile::write : file handle is NULL");
if (fwrite(pch, 1, nSize, file) != nSize)
- setstate(std::ios::failbit, "CAutoFile::write : write failed");
+ throw std::ios_base::failure("CAutoFile::write : write failed");
return (*this);
}
@@ -1292,16 +1290,7 @@ private:
uint64_t nRewind; // how many bytes we guarantee to rewind
std::vector<char> vchBuf; // the buffer
- short state;
- short exceptmask;
-
protected:
- void setstate(short bits, const char *psz) {
- state |= bits;
- if (state & exceptmask)
- throw std::ios_base::failure(psz);
- }
-
// read data from the source to fill the buffer
bool Fill() {
unsigned int pos = nSrcPos % vchBuf.size();
@@ -1313,8 +1302,7 @@ protected:
return false;
size_t read = fread((void*)&vchBuf[pos], 1, readNow, src);
if (read == 0) {
- setstate(std::ios_base::failbit, feof(src) ? "CBufferedFile::Fill : end of file" : "CBufferedFile::Fill : fread failed");
- return false;
+ throw std::ios_base::failure(feof(src) ? "CBufferedFile::Fill : end of file" : "CBufferedFile::Fill : fread failed");
} else {
nSrcPos += read;
return true;
@@ -1327,12 +1315,7 @@ public:
CBufferedFile(FILE *fileIn, uint64_t nBufSize, uint64_t nRewindIn, int nTypeIn, int nVersionIn) :
src(fileIn), nSrcPos(0), nReadPos(0), nReadLimit((uint64_t)(-1)), nRewind(nRewindIn), vchBuf(nBufSize, 0),
- state(0), exceptmask(std::ios_base::badbit | std::ios_base::failbit), nType(nTypeIn), nVersion(nVersionIn) {
- }
-
- // check whether no error occurred
- bool good() const {
- return state == 0;
+ nType(nTypeIn), nVersion(nVersionIn) {
}
// check whether we're at the end of the source file
@@ -1391,7 +1374,6 @@ public:
nLongPos = ftell(src);
nSrcPos = nLongPos;
nReadPos = nLongPos;
- state = 0;
return true;
}
diff --git a/src/test/alert_tests.cpp b/src/test/alert_tests.cpp
index b16f3f7f57..e3066a51ab 100644
--- a/src/test/alert_tests.cpp
+++ b/src/test/alert_tests.cpp
@@ -83,7 +83,7 @@ struct ReadAlerts
std::vector<unsigned char> vch(alert_tests::alertTests, alert_tests::alertTests + sizeof(alert_tests::alertTests));
CDataStream stream(vch, SER_DISK, CLIENT_VERSION);
try {
- while (stream.good())
+ while (!stream.eof())
{
CAlert alert;
stream >> alert;
diff --git a/src/test/bctest.py b/src/test/bctest.py
new file mode 100644
index 0000000000..1839f4fef4
--- /dev/null
+++ b/src/test/bctest.py
@@ -0,0 +1,53 @@
+# Copyright 2014 BitPay, Inc.
+# Distributed under the MIT/X11 software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+import subprocess
+import os
+import json
+import sys
+
+def bctest(testDir, testObj):
+ execargs = testObj['exec']
+
+ stdinCfg = None
+ inputData = None
+ if "input" in testObj:
+ filename = testDir + "/" + testObj['input']
+ inputData = open(filename).read()
+ stdinCfg = subprocess.PIPE
+
+ outputFn = None
+ outputData = None
+ if "output_cmp" in testObj:
+ outputFn = testObj['output_cmp']
+ outputData = open(testDir + "/" + outputFn).read()
+
+ proc = subprocess.Popen(execargs, stdin=stdinCfg, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ try:
+ outs = proc.communicate(input=inputData)
+ except OSError:
+ print("OSError, Failed to execute " + execargs[0])
+ sys.exit(1)
+
+ if outputData and (outs[0] != outputData):
+ print("Output data mismatch for " + outputFn)
+ sys.exit(1)
+
+ wantRC = 0
+ if "return_code" in testObj:
+ wantRC = testObj['return_code']
+ if proc.returncode != wantRC:
+ print("Return code mismatch for " + outputFn)
+ sys.exit(1)
+
+def bctester(testDir, input_basename):
+ input_filename = testDir + "/" + input_basename
+ raw_data = open(input_filename).read()
+ input_data = json.loads(raw_data)
+
+ for testObj in input_data:
+ bctest(testDir, testObj)
+
+ sys.exit(0)
+
diff --git a/src/test/bitcoin-util-test.py b/src/test/bitcoin-util-test.py
new file mode 100755
index 0000000000..40690c2fed
--- /dev/null
+++ b/src/test/bitcoin-util-test.py
@@ -0,0 +1,12 @@
+#!/usr/bin/python
+# Copyright 2014 BitPay, Inc.
+# Distributed under the MIT/X11 software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+import os
+import bctest
+
+if __name__ == '__main__':
+ bctest.bctester(os.environ["srcdir"] + "/test/data",
+ "bitcoin-util-test.json")
+
diff --git a/src/test/data/bitcoin-util-test.json b/src/test/data/bitcoin-util-test.json
new file mode 100644
index 0000000000..7db87d7c11
--- /dev/null
+++ b/src/test/data/bitcoin-util-test.json
@@ -0,0 +1,38 @@
+[
+ { "exec": ["./bitcoin-tx", "-create"],
+ "output_cmp": "blanktx.hex"
+ },
+ { "exec": ["./bitcoin-tx", "-"],
+ "input": "blanktx.hex",
+ "output_cmp": "blanktx.hex"
+ },
+ { "exec": ["./bitcoin-tx", "-", "delin=1"],
+ "input": "tx394b54bb.hex",
+ "output_cmp": "tt-delin1-out.hex"
+ },
+ { "exec": ["./bitcoin-tx", "-", "delin=31"],
+ "input": "tx394b54bb.hex",
+ "return_code": 1
+ },
+ { "exec": ["./bitcoin-tx", "-", "delout=1"],
+ "input": "tx394b54bb.hex",
+ "output_cmp": "tt-delout1-out.hex"
+ },
+ { "exec": ["./bitcoin-tx", "-", "delout=2"],
+ "input": "tx394b54bb.hex",
+ "return_code": 1
+ },
+ { "exec": ["./bitcoin-tx", "-", "locktime=317000"],
+ "input": "tx394b54bb.hex",
+ "output_cmp": "tt-locktime317000-out.hex"
+ },
+ { "exec":
+ ["./bitcoin-tx", "-create",
+ "in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0",
+ "in=bf829c6bcf84579331337659d31f89dfd138f7f7785802d5501c92333145ca7c:18",
+ "in=22a6f904655d53ae2ff70e701a0bbd90aa3975c0f40bfc6cc996a9049e31cdfc:1",
+ "outaddr=0.18:13tuJJDR2RgArmgfv6JScSdreahzgc4T6o",
+ "outaddr=4:1P8yWvZW8jVihP1bzHeqfE4aoXNX8AVa46"],
+ "output_cmp": "txcreate1.hex"
+ }
+]
diff --git a/src/test/data/blanktx.hex b/src/test/data/blanktx.hex
new file mode 100644
index 0000000000..36b6f00fb6
--- /dev/null
+++ b/src/test/data/blanktx.hex
@@ -0,0 +1 @@
+01000000000000000000
diff --git a/src/test/data/tt-delin1-out.hex b/src/test/data/tt-delin1-out.hex
new file mode 100644
index 0000000000..42ad840f43
--- /dev/null
+++ b/src/test/data/tt-delin1-out.hex
@@ -0,0 +1 @@
+0100000014fd5c23522d31761c50175453daa6edaabe47a602a592d39ce933d8271a1a87274c0100006c493046022100b4251ecd63778a3dde0155abe4cd162947620ae9ee45a874353551092325b116022100db307baf4ff3781ec520bd18f387948cedd15dc27bafe17c894b0fe6ffffcafa012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffffc1b37ae964f605978022f94ce2f3f676d66a46d1aef7c2c17d6315b9697f2f75010000006a473044022079bd62ee09621a3be96b760c39e8ef78170101d46313923c6b07ae60a95c90670220238e51ea29fc70b04b65508450523caedbb11cb4dd5aa608c81487de798925ba0121027a759be8df971a6a04fafcb4f6babf75dc811c5cdaa0734cddbe9b942ce75b34ffffffffedd005dc7790ef65c206abd1ab718e75252a40f4b1310e4102cd692eca9cacb0d10000006b48304502207722d6f9038673c86a1019b1c4de2d687ae246477cd4ca7002762be0299de385022100e594a11e3a313942595f7666dcf7078bcb14f1330f4206b95c917e7ec0e82fac012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffffdf28d6e26fb7a85a1e6a229b972c1bae0edc1c11cb9ca51e4caf5e59fbea35a1000000006b483045022100a63a4788027b79b65c6f9d9e054f68cf3b4eed19efd82a2d53f70dcbe64683390220526f243671425b2bd05745fcf2729361f985cfe84ea80c7cfc817b93d8134374012103a621f08be22d1bbdcbe4e527ee4927006aa555fc65e2aafa767d4ea2fe9dfa52ffffffffae2a2320a1582faa24469eff3024a6b98bfe00eb4f554d8a0b1421ba53bfd6a5010000006c493046022100b200ac6db16842f76dab9abe807ce423c992805879bc50abd46ed8275a59d9cf022100c0d518e85dd345b3c29dd4dc47b9a420d3ce817b18720e94966d2fe23413a408012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffffb3cc5a12548aa1794b4d2bbf076838cfd7fbafb7716da51ee8221a4ff19c291b000000006b483045022100ededc441c3103a6f2bd6cab7639421af0f6ec5e60503bce1e603cf34f00aee1c02205cb75f3f519a13fb348783b21db3085cb5ec7552c59e394fdbc3e1feea43f967012103a621f08be22d1bbdcbe4e527ee4927006aa555fc65e2aafa767d4ea2fe9dfa52ffffffff85145367313888d2cf2747274a32e20b2df074027bafd6f970003fcbcdf11d07150000006b483045022100d9eed5413d2a4b4b98625aa6e3169edc4fb4663e7862316d69224454e70cd8ca022061e506521d5ced51dd0ea36496e75904d756a4c4f9fb111568555075d5f68d9a012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff8292c11f6d35abab5bac3ebb627a4ff949e8ecd62d33ed137adf7aeb00e512b0090000006b48304502207e84b27139c4c19c828cb1e30c349bba88e4d9b59be97286960793b5ddc0a2af0221008cdc7a951e7f31c20953ed5635fbabf228e80b7047f32faaa0313e7693005177012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff883dcf9a86063db088ad064d0953258d4b0ff3425857402d2f3f839cee0f84581e0000006a4730440220426540dfed9c4ab5812e5f06df705b8bcf307dd7d20f7fa6512298b2a6314f420220064055096e3ca62f6c7352c66a5447767c53f946acdf35025ab3807ddb2fa404012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff6697dbb3ed98afe481b568459fa67e503f8a4254532465a670e54669d19c9fe6720000006a47304402200a5e673996f2fc88e21cc8613611f08a650bc0370338803591d85d0ec5663764022040b6664a0d1ec83a7f01975b8fde5232992b8ca58bf48af6725d2f92a936ab2e012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff023ffc2182517e1d3fa0896c5b0bd7b4d2ef8a1e42655abe2ced54f657125d59670000006c493046022100d93b30219c5735f673be5c3b4688366d96f545561c74cb62c6958c00f6960806022100ec8200adcb028f2184fa2a4f6faac7f8bb57cb4503bb7584ac11051fece31b3d012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffff16f8c77166b0df3d7cc8b5b2ce825afbea9309ad7acd8e2461a255958f81fc06010000006b483045022100a13934e68d3f5b22b130c4cb33f4da468cffc52323a47fbfbe06b64858162246022047081e0a70ff770e64a2e2d31e5d520d9102268b57a47009a72fe73ec766901801210234b9d9413f247bb78cd3293b7b65a2c38018ba5621ea9ee737f3a6a3523fb4cdffffffff197b96f3c87a3adfaa17f63fddc2a738a690ca665439f9431dbbd655816c41fb000000006c49304602210097f1f35d5bdc1a3a60390a1b015b8e7c4f916aa3847aafd969e04975e15bbe70022100a9052eb25517d481f1fda1b129eb1b534da50ea1a51f3ee012dca3601c11b86a0121027a759be8df971a6a04fafcb4f6babf75dc811c5cdaa0734cddbe9b942ce75b34ffffffff20d9a261ee27aa1bd92e7db2fdca935909a40b648e974cd24a10d63b68b94039dd0000006b483045022012b3138c591bf7154b6fef457f2c4a3c7162225003788ac0024a99355865ff13022100b71b125ae1ffb2e1d1571f580cd3ebc8cd049a2d7a8a41f138ba94aeb982106f012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffff50f179d5d16cd872f9a63c26c448464ae9bd95cd9421c0476113b5d314571b71010000006b483045022100f834ccc8b22ee72712a3e5e6ef4acb8b2fb791b5385b70e2cd4332674d6667f4022024fbda0a997e0c253503f217501f508a4d56edce2c813ecdd9ad796dbeba907401210234b9d9413f247bb78cd3293b7b65a2c38018ba5621ea9ee737f3a6a3523fb4cdffffffff551b865d1568ac0a305e5f9c5dae6c540982334efbe789074318e0efc5b564631b0000006b48304502203b2fd1e39ae0e469d7a15768f262661b0de41470daf0fe8c4fd0c26542a0870002210081c57e331f9a2d214457d953e3542904727ee412c63028113635d7224da3dccc012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff57503e5a016189d407a721791459280875264f908ca2c5d4862c01386e7fb50b470400006b48304502206947a9c54f0664ece4430fd4ae999891dc50bb6126bc36b6a15a3189f29d25e9022100a86cfc4e2fdd9e39a20e305cfd1b76509c67b3e313e0f118229105caa0e823c9012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff3f16c1fb9d3e1a26d872933e955df85ee7f3f817711062b00b54a2144827349b250000006b483045022100c7128fe10b2d38744ae8177776054c29fc8ec13f07207723e70766ab7164847402201d2cf09009b9596de74c0183d1ab832e5edddb7a9965880bb400097e850850f8012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff4142a69d85b8498af214f0dd427b6ab29c240a0b8577e2944d37a7d8c05c6bb8140000006b48304502203b89a71628a28cc3703d170ca3be77786cff6b867e38a18b719705f8a326578f022100b2a9879e1acf621faa6466c207746a7f3eb4c8514c1482969aba3f2a957f1321012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff36e2feecc0a4bff7480015d42c12121932db389025ed0ac1d344ecee53230a3df20000006c493046022100ef794a8ef7fd6752d2a183c18866ff6e8dc0f5bd889a63e2c21cf303a6302461022100c1b09662d9e92988c3f9fcf17d1bcc79b5403647095d7212b9f8a1278a532d68012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffff0260f73608000000001976a9148fd139bb39ced713f231c58a4d07bf6954d1c20188ac41420f00000000001976a9146c772e9cf96371bba3da8cb733da70a2fcf2007888ac00000000
diff --git a/src/test/data/tt-delout1-out.hex b/src/test/data/tt-delout1-out.hex
new file mode 100644
index 0000000000..cc60c3fac6
--- /dev/null
+++ b/src/test/data/tt-delout1-out.hex
@@ -0,0 +1 @@
+0100000015fd5c23522d31761c50175453daa6edaabe47a602a592d39ce933d8271a1a87274c0100006c493046022100b4251ecd63778a3dde0155abe4cd162947620ae9ee45a874353551092325b116022100db307baf4ff3781ec520bd18f387948cedd15dc27bafe17c894b0fe6ffffcafa012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffffcb4ed1baba3a1eb2171e00ddec8e5b72b346dd8c07f9c2b0d122d0d06bc92ea7000000006c493046022100a9b617843b68c284715d3e02fd120479cd0d96a6c43bf01e697fb0a460a21a3a022100ba0a12fbe8b993d4e7911fa3467615765dbe421ddf5c51b57a9c1ee19dcc00ba012103e633b4fa4ceb705c2da712390767199be8ef2448b3095dc01652e11b2b751505ffffffffc1b37ae964f605978022f94ce2f3f676d66a46d1aef7c2c17d6315b9697f2f75010000006a473044022079bd62ee09621a3be96b760c39e8ef78170101d46313923c6b07ae60a95c90670220238e51ea29fc70b04b65508450523caedbb11cb4dd5aa608c81487de798925ba0121027a759be8df971a6a04fafcb4f6babf75dc811c5cdaa0734cddbe9b942ce75b34ffffffffedd005dc7790ef65c206abd1ab718e75252a40f4b1310e4102cd692eca9cacb0d10000006b48304502207722d6f9038673c86a1019b1c4de2d687ae246477cd4ca7002762be0299de385022100e594a11e3a313942595f7666dcf7078bcb14f1330f4206b95c917e7ec0e82fac012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffffdf28d6e26fb7a85a1e6a229b972c1bae0edc1c11cb9ca51e4caf5e59fbea35a1000000006b483045022100a63a4788027b79b65c6f9d9e054f68cf3b4eed19efd82a2d53f70dcbe64683390220526f243671425b2bd05745fcf2729361f985cfe84ea80c7cfc817b93d8134374012103a621f08be22d1bbdcbe4e527ee4927006aa555fc65e2aafa767d4ea2fe9dfa52ffffffffae2a2320a1582faa24469eff3024a6b98bfe00eb4f554d8a0b1421ba53bfd6a5010000006c493046022100b200ac6db16842f76dab9abe807ce423c992805879bc50abd46ed8275a59d9cf022100c0d518e85dd345b3c29dd4dc47b9a420d3ce817b18720e94966d2fe23413a408012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffffb3cc5a12548aa1794b4d2bbf076838cfd7fbafb7716da51ee8221a4ff19c291b000000006b483045022100ededc441c3103a6f2bd6cab7639421af0f6ec5e60503bce1e603cf34f00aee1c02205cb75f3f519a13fb348783b21db3085cb5ec7552c59e394fdbc3e1feea43f967012103a621f08be22d1bbdcbe4e527ee4927006aa555fc65e2aafa767d4ea2fe9dfa52ffffffff85145367313888d2cf2747274a32e20b2df074027bafd6f970003fcbcdf11d07150000006b483045022100d9eed5413d2a4b4b98625aa6e3169edc4fb4663e7862316d69224454e70cd8ca022061e506521d5ced51dd0ea36496e75904d756a4c4f9fb111568555075d5f68d9a012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff8292c11f6d35abab5bac3ebb627a4ff949e8ecd62d33ed137adf7aeb00e512b0090000006b48304502207e84b27139c4c19c828cb1e30c349bba88e4d9b59be97286960793b5ddc0a2af0221008cdc7a951e7f31c20953ed5635fbabf228e80b7047f32faaa0313e7693005177012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff883dcf9a86063db088ad064d0953258d4b0ff3425857402d2f3f839cee0f84581e0000006a4730440220426540dfed9c4ab5812e5f06df705b8bcf307dd7d20f7fa6512298b2a6314f420220064055096e3ca62f6c7352c66a5447767c53f946acdf35025ab3807ddb2fa404012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff6697dbb3ed98afe481b568459fa67e503f8a4254532465a670e54669d19c9fe6720000006a47304402200a5e673996f2fc88e21cc8613611f08a650bc0370338803591d85d0ec5663764022040b6664a0d1ec83a7f01975b8fde5232992b8ca58bf48af6725d2f92a936ab2e012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff023ffc2182517e1d3fa0896c5b0bd7b4d2ef8a1e42655abe2ced54f657125d59670000006c493046022100d93b30219c5735f673be5c3b4688366d96f545561c74cb62c6958c00f6960806022100ec8200adcb028f2184fa2a4f6faac7f8bb57cb4503bb7584ac11051fece31b3d012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffff16f8c77166b0df3d7cc8b5b2ce825afbea9309ad7acd8e2461a255958f81fc06010000006b483045022100a13934e68d3f5b22b130c4cb33f4da468cffc52323a47fbfbe06b64858162246022047081e0a70ff770e64a2e2d31e5d520d9102268b57a47009a72fe73ec766901801210234b9d9413f247bb78cd3293b7b65a2c38018ba5621ea9ee737f3a6a3523fb4cdffffffff197b96f3c87a3adfaa17f63fddc2a738a690ca665439f9431dbbd655816c41fb000000006c49304602210097f1f35d5bdc1a3a60390a1b015b8e7c4f916aa3847aafd969e04975e15bbe70022100a9052eb25517d481f1fda1b129eb1b534da50ea1a51f3ee012dca3601c11b86a0121027a759be8df971a6a04fafcb4f6babf75dc811c5cdaa0734cddbe9b942ce75b34ffffffff20d9a261ee27aa1bd92e7db2fdca935909a40b648e974cd24a10d63b68b94039dd0000006b483045022012b3138c591bf7154b6fef457f2c4a3c7162225003788ac0024a99355865ff13022100b71b125ae1ffb2e1d1571f580cd3ebc8cd049a2d7a8a41f138ba94aeb982106f012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffff50f179d5d16cd872f9a63c26c448464ae9bd95cd9421c0476113b5d314571b71010000006b483045022100f834ccc8b22ee72712a3e5e6ef4acb8b2fb791b5385b70e2cd4332674d6667f4022024fbda0a997e0c253503f217501f508a4d56edce2c813ecdd9ad796dbeba907401210234b9d9413f247bb78cd3293b7b65a2c38018ba5621ea9ee737f3a6a3523fb4cdffffffff551b865d1568ac0a305e5f9c5dae6c540982334efbe789074318e0efc5b564631b0000006b48304502203b2fd1e39ae0e469d7a15768f262661b0de41470daf0fe8c4fd0c26542a0870002210081c57e331f9a2d214457d953e3542904727ee412c63028113635d7224da3dccc012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff57503e5a016189d407a721791459280875264f908ca2c5d4862c01386e7fb50b470400006b48304502206947a9c54f0664ece4430fd4ae999891dc50bb6126bc36b6a15a3189f29d25e9022100a86cfc4e2fdd9e39a20e305cfd1b76509c67b3e313e0f118229105caa0e823c9012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff3f16c1fb9d3e1a26d872933e955df85ee7f3f817711062b00b54a2144827349b250000006b483045022100c7128fe10b2d38744ae8177776054c29fc8ec13f07207723e70766ab7164847402201d2cf09009b9596de74c0183d1ab832e5edddb7a9965880bb400097e850850f8012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff4142a69d85b8498af214f0dd427b6ab29c240a0b8577e2944d37a7d8c05c6bb8140000006b48304502203b89a71628a28cc3703d170ca3be77786cff6b867e38a18b719705f8a326578f022100b2a9879e1acf621faa6466c207746a7f3eb4c8514c1482969aba3f2a957f1321012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff36e2feecc0a4bff7480015d42c12121932db389025ed0ac1d344ecee53230a3df20000006c493046022100ef794a8ef7fd6752d2a183c18866ff6e8dc0f5bd889a63e2c21cf303a6302461022100c1b09662d9e92988c3f9fcf17d1bcc79b5403647095d7212b9f8a1278a532d68012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffff0160f73608000000001976a9148fd139bb39ced713f231c58a4d07bf6954d1c20188ac00000000
diff --git a/src/test/data/tt-locktime317000-out.hex b/src/test/data/tt-locktime317000-out.hex
new file mode 100644
index 0000000000..287f420a40
--- /dev/null
+++ b/src/test/data/tt-locktime317000-out.hex
@@ -0,0 +1 @@
+0100000015fd5c23522d31761c50175453daa6edaabe47a602a592d39ce933d8271a1a87274c0100006c493046022100b4251ecd63778a3dde0155abe4cd162947620ae9ee45a874353551092325b116022100db307baf4ff3781ec520bd18f387948cedd15dc27bafe17c894b0fe6ffffcafa012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffffcb4ed1baba3a1eb2171e00ddec8e5b72b346dd8c07f9c2b0d122d0d06bc92ea7000000006c493046022100a9b617843b68c284715d3e02fd120479cd0d96a6c43bf01e697fb0a460a21a3a022100ba0a12fbe8b993d4e7911fa3467615765dbe421ddf5c51b57a9c1ee19dcc00ba012103e633b4fa4ceb705c2da712390767199be8ef2448b3095dc01652e11b2b751505ffffffffc1b37ae964f605978022f94ce2f3f676d66a46d1aef7c2c17d6315b9697f2f75010000006a473044022079bd62ee09621a3be96b760c39e8ef78170101d46313923c6b07ae60a95c90670220238e51ea29fc70b04b65508450523caedbb11cb4dd5aa608c81487de798925ba0121027a759be8df971a6a04fafcb4f6babf75dc811c5cdaa0734cddbe9b942ce75b34ffffffffedd005dc7790ef65c206abd1ab718e75252a40f4b1310e4102cd692eca9cacb0d10000006b48304502207722d6f9038673c86a1019b1c4de2d687ae246477cd4ca7002762be0299de385022100e594a11e3a313942595f7666dcf7078bcb14f1330f4206b95c917e7ec0e82fac012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffffdf28d6e26fb7a85a1e6a229b972c1bae0edc1c11cb9ca51e4caf5e59fbea35a1000000006b483045022100a63a4788027b79b65c6f9d9e054f68cf3b4eed19efd82a2d53f70dcbe64683390220526f243671425b2bd05745fcf2729361f985cfe84ea80c7cfc817b93d8134374012103a621f08be22d1bbdcbe4e527ee4927006aa555fc65e2aafa767d4ea2fe9dfa52ffffffffae2a2320a1582faa24469eff3024a6b98bfe00eb4f554d8a0b1421ba53bfd6a5010000006c493046022100b200ac6db16842f76dab9abe807ce423c992805879bc50abd46ed8275a59d9cf022100c0d518e85dd345b3c29dd4dc47b9a420d3ce817b18720e94966d2fe23413a408012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffffb3cc5a12548aa1794b4d2bbf076838cfd7fbafb7716da51ee8221a4ff19c291b000000006b483045022100ededc441c3103a6f2bd6cab7639421af0f6ec5e60503bce1e603cf34f00aee1c02205cb75f3f519a13fb348783b21db3085cb5ec7552c59e394fdbc3e1feea43f967012103a621f08be22d1bbdcbe4e527ee4927006aa555fc65e2aafa767d4ea2fe9dfa52ffffffff85145367313888d2cf2747274a32e20b2df074027bafd6f970003fcbcdf11d07150000006b483045022100d9eed5413d2a4b4b98625aa6e3169edc4fb4663e7862316d69224454e70cd8ca022061e506521d5ced51dd0ea36496e75904d756a4c4f9fb111568555075d5f68d9a012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff8292c11f6d35abab5bac3ebb627a4ff949e8ecd62d33ed137adf7aeb00e512b0090000006b48304502207e84b27139c4c19c828cb1e30c349bba88e4d9b59be97286960793b5ddc0a2af0221008cdc7a951e7f31c20953ed5635fbabf228e80b7047f32faaa0313e7693005177012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff883dcf9a86063db088ad064d0953258d4b0ff3425857402d2f3f839cee0f84581e0000006a4730440220426540dfed9c4ab5812e5f06df705b8bcf307dd7d20f7fa6512298b2a6314f420220064055096e3ca62f6c7352c66a5447767c53f946acdf35025ab3807ddb2fa404012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff6697dbb3ed98afe481b568459fa67e503f8a4254532465a670e54669d19c9fe6720000006a47304402200a5e673996f2fc88e21cc8613611f08a650bc0370338803591d85d0ec5663764022040b6664a0d1ec83a7f01975b8fde5232992b8ca58bf48af6725d2f92a936ab2e012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff023ffc2182517e1d3fa0896c5b0bd7b4d2ef8a1e42655abe2ced54f657125d59670000006c493046022100d93b30219c5735f673be5c3b4688366d96f545561c74cb62c6958c00f6960806022100ec8200adcb028f2184fa2a4f6faac7f8bb57cb4503bb7584ac11051fece31b3d012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffff16f8c77166b0df3d7cc8b5b2ce825afbea9309ad7acd8e2461a255958f81fc06010000006b483045022100a13934e68d3f5b22b130c4cb33f4da468cffc52323a47fbfbe06b64858162246022047081e0a70ff770e64a2e2d31e5d520d9102268b57a47009a72fe73ec766901801210234b9d9413f247bb78cd3293b7b65a2c38018ba5621ea9ee737f3a6a3523fb4cdffffffff197b96f3c87a3adfaa17f63fddc2a738a690ca665439f9431dbbd655816c41fb000000006c49304602210097f1f35d5bdc1a3a60390a1b015b8e7c4f916aa3847aafd969e04975e15bbe70022100a9052eb25517d481f1fda1b129eb1b534da50ea1a51f3ee012dca3601c11b86a0121027a759be8df971a6a04fafcb4f6babf75dc811c5cdaa0734cddbe9b942ce75b34ffffffff20d9a261ee27aa1bd92e7db2fdca935909a40b648e974cd24a10d63b68b94039dd0000006b483045022012b3138c591bf7154b6fef457f2c4a3c7162225003788ac0024a99355865ff13022100b71b125ae1ffb2e1d1571f580cd3ebc8cd049a2d7a8a41f138ba94aeb982106f012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffff50f179d5d16cd872f9a63c26c448464ae9bd95cd9421c0476113b5d314571b71010000006b483045022100f834ccc8b22ee72712a3e5e6ef4acb8b2fb791b5385b70e2cd4332674d6667f4022024fbda0a997e0c253503f217501f508a4d56edce2c813ecdd9ad796dbeba907401210234b9d9413f247bb78cd3293b7b65a2c38018ba5621ea9ee737f3a6a3523fb4cdffffffff551b865d1568ac0a305e5f9c5dae6c540982334efbe789074318e0efc5b564631b0000006b48304502203b2fd1e39ae0e469d7a15768f262661b0de41470daf0fe8c4fd0c26542a0870002210081c57e331f9a2d214457d953e3542904727ee412c63028113635d7224da3dccc012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff57503e5a016189d407a721791459280875264f908ca2c5d4862c01386e7fb50b470400006b48304502206947a9c54f0664ece4430fd4ae999891dc50bb6126bc36b6a15a3189f29d25e9022100a86cfc4e2fdd9e39a20e305cfd1b76509c67b3e313e0f118229105caa0e823c9012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff3f16c1fb9d3e1a26d872933e955df85ee7f3f817711062b00b54a2144827349b250000006b483045022100c7128fe10b2d38744ae8177776054c29fc8ec13f07207723e70766ab7164847402201d2cf09009b9596de74c0183d1ab832e5edddb7a9965880bb400097e850850f8012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff4142a69d85b8498af214f0dd427b6ab29c240a0b8577e2944d37a7d8c05c6bb8140000006b48304502203b89a71628a28cc3703d170ca3be77786cff6b867e38a18b719705f8a326578f022100b2a9879e1acf621faa6466c207746a7f3eb4c8514c1482969aba3f2a957f1321012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff36e2feecc0a4bff7480015d42c12121932db389025ed0ac1d344ecee53230a3df20000006c493046022100ef794a8ef7fd6752d2a183c18866ff6e8dc0f5bd889a63e2c21cf303a6302461022100c1b09662d9e92988c3f9fcf17d1bcc79b5403647095d7212b9f8a1278a532d68012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffff0260f73608000000001976a9148fd139bb39ced713f231c58a4d07bf6954d1c20188ac41420f00000000001976a9146c772e9cf96371bba3da8cb733da70a2fcf2007888ac48d60400
diff --git a/src/test/data/tx394b54bb.hex b/src/test/data/tx394b54bb.hex
new file mode 100644
index 0000000000..33f26cb4d6
--- /dev/null
+++ b/src/test/data/tx394b54bb.hex
@@ -0,0 +1 @@
+0100000015fd5c23522d31761c50175453daa6edaabe47a602a592d39ce933d8271a1a87274c0100006c493046022100b4251ecd63778a3dde0155abe4cd162947620ae9ee45a874353551092325b116022100db307baf4ff3781ec520bd18f387948cedd15dc27bafe17c894b0fe6ffffcafa012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffffcb4ed1baba3a1eb2171e00ddec8e5b72b346dd8c07f9c2b0d122d0d06bc92ea7000000006c493046022100a9b617843b68c284715d3e02fd120479cd0d96a6c43bf01e697fb0a460a21a3a022100ba0a12fbe8b993d4e7911fa3467615765dbe421ddf5c51b57a9c1ee19dcc00ba012103e633b4fa4ceb705c2da712390767199be8ef2448b3095dc01652e11b2b751505ffffffffc1b37ae964f605978022f94ce2f3f676d66a46d1aef7c2c17d6315b9697f2f75010000006a473044022079bd62ee09621a3be96b760c39e8ef78170101d46313923c6b07ae60a95c90670220238e51ea29fc70b04b65508450523caedbb11cb4dd5aa608c81487de798925ba0121027a759be8df971a6a04fafcb4f6babf75dc811c5cdaa0734cddbe9b942ce75b34ffffffffedd005dc7790ef65c206abd1ab718e75252a40f4b1310e4102cd692eca9cacb0d10000006b48304502207722d6f9038673c86a1019b1c4de2d687ae246477cd4ca7002762be0299de385022100e594a11e3a313942595f7666dcf7078bcb14f1330f4206b95c917e7ec0e82fac012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffffdf28d6e26fb7a85a1e6a229b972c1bae0edc1c11cb9ca51e4caf5e59fbea35a1000000006b483045022100a63a4788027b79b65c6f9d9e054f68cf3b4eed19efd82a2d53f70dcbe64683390220526f243671425b2bd05745fcf2729361f985cfe84ea80c7cfc817b93d8134374012103a621f08be22d1bbdcbe4e527ee4927006aa555fc65e2aafa767d4ea2fe9dfa52ffffffffae2a2320a1582faa24469eff3024a6b98bfe00eb4f554d8a0b1421ba53bfd6a5010000006c493046022100b200ac6db16842f76dab9abe807ce423c992805879bc50abd46ed8275a59d9cf022100c0d518e85dd345b3c29dd4dc47b9a420d3ce817b18720e94966d2fe23413a408012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffffb3cc5a12548aa1794b4d2bbf076838cfd7fbafb7716da51ee8221a4ff19c291b000000006b483045022100ededc441c3103a6f2bd6cab7639421af0f6ec5e60503bce1e603cf34f00aee1c02205cb75f3f519a13fb348783b21db3085cb5ec7552c59e394fdbc3e1feea43f967012103a621f08be22d1bbdcbe4e527ee4927006aa555fc65e2aafa767d4ea2fe9dfa52ffffffff85145367313888d2cf2747274a32e20b2df074027bafd6f970003fcbcdf11d07150000006b483045022100d9eed5413d2a4b4b98625aa6e3169edc4fb4663e7862316d69224454e70cd8ca022061e506521d5ced51dd0ea36496e75904d756a4c4f9fb111568555075d5f68d9a012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff8292c11f6d35abab5bac3ebb627a4ff949e8ecd62d33ed137adf7aeb00e512b0090000006b48304502207e84b27139c4c19c828cb1e30c349bba88e4d9b59be97286960793b5ddc0a2af0221008cdc7a951e7f31c20953ed5635fbabf228e80b7047f32faaa0313e7693005177012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff883dcf9a86063db088ad064d0953258d4b0ff3425857402d2f3f839cee0f84581e0000006a4730440220426540dfed9c4ab5812e5f06df705b8bcf307dd7d20f7fa6512298b2a6314f420220064055096e3ca62f6c7352c66a5447767c53f946acdf35025ab3807ddb2fa404012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff6697dbb3ed98afe481b568459fa67e503f8a4254532465a670e54669d19c9fe6720000006a47304402200a5e673996f2fc88e21cc8613611f08a650bc0370338803591d85d0ec5663764022040b6664a0d1ec83a7f01975b8fde5232992b8ca58bf48af6725d2f92a936ab2e012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff023ffc2182517e1d3fa0896c5b0bd7b4d2ef8a1e42655abe2ced54f657125d59670000006c493046022100d93b30219c5735f673be5c3b4688366d96f545561c74cb62c6958c00f6960806022100ec8200adcb028f2184fa2a4f6faac7f8bb57cb4503bb7584ac11051fece31b3d012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffff16f8c77166b0df3d7cc8b5b2ce825afbea9309ad7acd8e2461a255958f81fc06010000006b483045022100a13934e68d3f5b22b130c4cb33f4da468cffc52323a47fbfbe06b64858162246022047081e0a70ff770e64a2e2d31e5d520d9102268b57a47009a72fe73ec766901801210234b9d9413f247bb78cd3293b7b65a2c38018ba5621ea9ee737f3a6a3523fb4cdffffffff197b96f3c87a3adfaa17f63fddc2a738a690ca665439f9431dbbd655816c41fb000000006c49304602210097f1f35d5bdc1a3a60390a1b015b8e7c4f916aa3847aafd969e04975e15bbe70022100a9052eb25517d481f1fda1b129eb1b534da50ea1a51f3ee012dca3601c11b86a0121027a759be8df971a6a04fafcb4f6babf75dc811c5cdaa0734cddbe9b942ce75b34ffffffff20d9a261ee27aa1bd92e7db2fdca935909a40b648e974cd24a10d63b68b94039dd0000006b483045022012b3138c591bf7154b6fef457f2c4a3c7162225003788ac0024a99355865ff13022100b71b125ae1ffb2e1d1571f580cd3ebc8cd049a2d7a8a41f138ba94aeb982106f012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffff50f179d5d16cd872f9a63c26c448464ae9bd95cd9421c0476113b5d314571b71010000006b483045022100f834ccc8b22ee72712a3e5e6ef4acb8b2fb791b5385b70e2cd4332674d6667f4022024fbda0a997e0c253503f217501f508a4d56edce2c813ecdd9ad796dbeba907401210234b9d9413f247bb78cd3293b7b65a2c38018ba5621ea9ee737f3a6a3523fb4cdffffffff551b865d1568ac0a305e5f9c5dae6c540982334efbe789074318e0efc5b564631b0000006b48304502203b2fd1e39ae0e469d7a15768f262661b0de41470daf0fe8c4fd0c26542a0870002210081c57e331f9a2d214457d953e3542904727ee412c63028113635d7224da3dccc012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff57503e5a016189d407a721791459280875264f908ca2c5d4862c01386e7fb50b470400006b48304502206947a9c54f0664ece4430fd4ae999891dc50bb6126bc36b6a15a3189f29d25e9022100a86cfc4e2fdd9e39a20e305cfd1b76509c67b3e313e0f118229105caa0e823c9012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff3f16c1fb9d3e1a26d872933e955df85ee7f3f817711062b00b54a2144827349b250000006b483045022100c7128fe10b2d38744ae8177776054c29fc8ec13f07207723e70766ab7164847402201d2cf09009b9596de74c0183d1ab832e5edddb7a9965880bb400097e850850f8012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff4142a69d85b8498af214f0dd427b6ab29c240a0b8577e2944d37a7d8c05c6bb8140000006b48304502203b89a71628a28cc3703d170ca3be77786cff6b867e38a18b719705f8a326578f022100b2a9879e1acf621faa6466c207746a7f3eb4c8514c1482969aba3f2a957f1321012103f1575d6124ac78be398c25b31146d08313c6072d23a4d7df5ac6a9f87346c64cffffffff36e2feecc0a4bff7480015d42c12121932db389025ed0ac1d344ecee53230a3df20000006c493046022100ef794a8ef7fd6752d2a183c18866ff6e8dc0f5bd889a63e2c21cf303a6302461022100c1b09662d9e92988c3f9fcf17d1bcc79b5403647095d7212b9f8a1278a532d68012103091137f3ef23f4acfc19a5953a68b2074fae942ad3563ef28c33b0cac9a93adcffffffff0260f73608000000001976a9148fd139bb39ced713f231c58a4d07bf6954d1c20188ac41420f00000000001976a9146c772e9cf96371bba3da8cb733da70a2fcf2007888ac00000000
diff --git a/src/test/data/txcreate1.hex b/src/test/data/txcreate1.hex
new file mode 100644
index 0000000000..e2981a51c9
--- /dev/null
+++ b/src/test/data/txcreate1.hex
@@ -0,0 +1 @@
+01000000031f5c38dfcf6f1a5f5a87c416076d392c87e6d41970d5ad5e477a02d66bde97580000000000ffffffff7cca453133921c50d5025878f7f738d1df891fd359763331935784cf6b9c82bf1200000000fffffffffccd319e04a996c96cfc0bf4c07539aa90bd0b1a700ef72fae535d6504f9a6220100000000ffffffff0280a81201000000001976a9141fc11f39be1729bf973a7ab6a615ca4729d6457488ac0084d717000000001976a914f2d4db28cad6502226ee484ae24505c2885cb12d88ac00000000
diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp
index 107c0f06e7..d5475a92bf 100644
--- a/src/test/rpc_tests.cpp
+++ b/src/test/rpc_tests.cpp
@@ -110,14 +110,14 @@ BOOST_AUTO_TEST_CASE(rpc_rawsign)
BOOST_AUTO_TEST_CASE(rpc_format_monetary_values)
{
- BOOST_CHECK(write_string(ValueFromAmount(0LL), false) == "0.00000000");
- BOOST_CHECK(write_string(ValueFromAmount(1LL), false) == "0.00000001");
- BOOST_CHECK(write_string(ValueFromAmount(17622195LL), false) == "0.17622195");
- BOOST_CHECK(write_string(ValueFromAmount(50000000LL), false) == "0.50000000");
- BOOST_CHECK(write_string(ValueFromAmount(89898989LL), false) == "0.89898989");
- BOOST_CHECK(write_string(ValueFromAmount(100000000LL), false) == "1.00000000");
- BOOST_CHECK(write_string(ValueFromAmount(2099999999999990LL), false) == "20999999.99999990");
- BOOST_CHECK(write_string(ValueFromAmount(2099999999999999LL), false) == "20999999.99999999");
+ BOOST_CHECK_EQUAL(write_string(ValueFromAmount(0LL), false), "0.00000000");
+ BOOST_CHECK_EQUAL(write_string(ValueFromAmount(1LL), false), "0.00000001");
+ BOOST_CHECK_EQUAL(write_string(ValueFromAmount(17622195LL), false), "0.17622195");
+ BOOST_CHECK_EQUAL(write_string(ValueFromAmount(50000000LL), false), "0.50000000");
+ BOOST_CHECK_EQUAL(write_string(ValueFromAmount(89898989LL), false), "0.89898989");
+ BOOST_CHECK_EQUAL(write_string(ValueFromAmount(100000000LL), false), "1.00000000");
+ BOOST_CHECK_EQUAL(write_string(ValueFromAmount(2099999999999990LL), false), "20999999.99999990");
+ BOOST_CHECK_EQUAL(write_string(ValueFromAmount(2099999999999999LL), false), "20999999.99999999");
}
static Value ValueFromString(const std::string &str)
@@ -129,14 +129,14 @@ static Value ValueFromString(const std::string &str)
BOOST_AUTO_TEST_CASE(rpc_parse_monetary_values)
{
- BOOST_CHECK(AmountFromValue(ValueFromString("0.00000001")) == 1LL);
- BOOST_CHECK(AmountFromValue(ValueFromString("0.17622195")) == 17622195LL);
- BOOST_CHECK(AmountFromValue(ValueFromString("0.5")) == 50000000LL);
- BOOST_CHECK(AmountFromValue(ValueFromString("0.50000000")) == 50000000LL);
- BOOST_CHECK(AmountFromValue(ValueFromString("0.89898989")) == 89898989LL);
- BOOST_CHECK(AmountFromValue(ValueFromString("1.00000000")) == 100000000LL);
- BOOST_CHECK(AmountFromValue(ValueFromString("20999999.9999999")) == 2099999999999990LL);
- BOOST_CHECK(AmountFromValue(ValueFromString("20999999.99999999")) == 2099999999999999LL);
+ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000001")), 1LL);
+ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.17622195")), 17622195LL);
+ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.5")), 50000000LL);
+ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.50000000")), 50000000LL);
+ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.89898989")), 89898989LL);
+ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("1.00000000")), 100000000LL);
+ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("20999999.9999999")), 2099999999999990LL);
+ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("20999999.99999999")), 2099999999999999LL);
}
BOOST_AUTO_TEST_CASE(rpc_boostasiotocnetaddr)
diff --git a/src/test/univalue_tests.cpp b/src/test/univalue_tests.cpp
new file mode 100644
index 0000000000..23bc5f6b12
--- /dev/null
+++ b/src/test/univalue_tests.cpp
@@ -0,0 +1,275 @@
+// Copyright 2014 BitPay, Inc.
+// Distributed under the MIT/X11 software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include <stdint.h>
+#include <vector>
+#include <string>
+#include <map>
+#include "univalue/univalue.h"
+
+#include <boost/test/unit_test.hpp>
+
+using namespace std;
+
+BOOST_AUTO_TEST_SUITE(univalue_tests)
+
+BOOST_AUTO_TEST_CASE(univalue_constructor)
+{
+ UniValue v1;
+ BOOST_CHECK(v1.isNull());
+
+ UniValue v2(UniValue::VSTR);
+ BOOST_CHECK(v2.isStr());
+
+ UniValue v3(UniValue::VSTR, "foo");
+ BOOST_CHECK(v3.isStr());
+ BOOST_CHECK_EQUAL(v3.getValStr(), "foo");
+
+ UniValue numTest;
+ BOOST_CHECK(numTest.setNumStr("82"));
+ BOOST_CHECK(numTest.isNum());
+ BOOST_CHECK_EQUAL(numTest.getValStr(), "82");
+
+ uint64_t vu64 = 82;
+ UniValue v4(vu64);
+ BOOST_CHECK(v4.isNum());
+ BOOST_CHECK_EQUAL(v4.getValStr(), "82");
+
+ int64_t vi64 = -82;
+ UniValue v5(vi64);
+ BOOST_CHECK(v5.isNum());
+ BOOST_CHECK_EQUAL(v5.getValStr(), "-82");
+
+ int vi = -688;
+ UniValue v6(vi);
+ BOOST_CHECK(v6.isNum());
+ BOOST_CHECK_EQUAL(v6.getValStr(), "-688");
+
+ double vd = -7.21;
+ UniValue v7(vd);
+ BOOST_CHECK(v7.isNum());
+ BOOST_CHECK_EQUAL(v7.getValStr(), "-7.21");
+
+ string vs("yawn");
+ UniValue v8(vs);
+ BOOST_CHECK(v8.isStr());
+ BOOST_CHECK_EQUAL(v8.getValStr(), "yawn");
+
+ const char *vcs = "zappa";
+ UniValue v9(vcs);
+ BOOST_CHECK(v9.isStr());
+ BOOST_CHECK_EQUAL(v9.getValStr(), "zappa");
+}
+
+BOOST_AUTO_TEST_CASE(univalue_set)
+{
+ UniValue v(UniValue::VSTR, "foo");
+ v.clear();
+ BOOST_CHECK(v.isNull());
+ BOOST_CHECK_EQUAL(v.getValStr(), "");
+
+ BOOST_CHECK(v.setObject());
+ BOOST_CHECK(v.isObject());
+ BOOST_CHECK_EQUAL(v.count(), 0);
+ BOOST_CHECK_EQUAL(v.getType(), UniValue::VOBJ);
+ BOOST_CHECK(v.empty());
+
+ BOOST_CHECK(v.setArray());
+ BOOST_CHECK(v.isArray());
+ BOOST_CHECK_EQUAL(v.count(), 0);
+
+ BOOST_CHECK(v.setStr("zum"));
+ BOOST_CHECK(v.isStr());
+ BOOST_CHECK_EQUAL(v.getValStr(), "zum");
+
+ BOOST_CHECK(v.setFloat(-1.01));
+ BOOST_CHECK(v.isNum());
+ BOOST_CHECK_EQUAL(v.getValStr(), "-1.01");
+
+ BOOST_CHECK(v.setInt((int)1023));
+ BOOST_CHECK(v.isNum());
+ BOOST_CHECK_EQUAL(v.getValStr(), "1023");
+
+ BOOST_CHECK(v.setInt((int64_t)-1023LL));
+ BOOST_CHECK(v.isNum());
+ BOOST_CHECK_EQUAL(v.getValStr(), "-1023");
+
+ BOOST_CHECK(v.setInt((uint64_t)1023ULL));
+ BOOST_CHECK(v.isNum());
+ BOOST_CHECK_EQUAL(v.getValStr(), "1023");
+
+ BOOST_CHECK(v.setNumStr("-688"));
+ BOOST_CHECK(v.isNum());
+ BOOST_CHECK_EQUAL(v.getValStr(), "-688");
+
+ BOOST_CHECK(v.setBool(false));
+ BOOST_CHECK_EQUAL(v.isBool(), true);
+ BOOST_CHECK_EQUAL(v.isTrue(), false);
+ BOOST_CHECK_EQUAL(v.isFalse(), true);
+ BOOST_CHECK_EQUAL(v.getBool(), false);
+
+ BOOST_CHECK(v.setBool(true));
+ BOOST_CHECK_EQUAL(v.isBool(), true);
+ BOOST_CHECK_EQUAL(v.isTrue(), true);
+ BOOST_CHECK_EQUAL(v.isFalse(), false);
+ BOOST_CHECK_EQUAL(v.getBool(), true);
+
+ BOOST_CHECK(!v.setNumStr("zombocom"));
+
+ BOOST_CHECK(v.setNull());
+ BOOST_CHECK(v.isNull());
+}
+
+BOOST_AUTO_TEST_CASE(univalue_array)
+{
+ UniValue arr(UniValue::VARR);
+
+ UniValue v((int64_t)1023LL);
+ BOOST_CHECK(arr.push_back(v));
+
+ string vStr("zippy");
+ BOOST_CHECK(arr.push_back(vStr));
+
+ const char *s = "pippy";
+ BOOST_CHECK(arr.push_back(s));
+
+ vector<UniValue> vec;
+ v.setStr("boing");
+ vec.push_back(v);
+
+ v.setStr("going");
+ vec.push_back(v);
+
+ BOOST_CHECK(arr.push_backV(vec));
+
+ BOOST_CHECK_EQUAL(arr.empty(), false);
+ BOOST_CHECK_EQUAL(arr.count(), 5);
+
+ BOOST_CHECK_EQUAL(arr[0].getValStr(), "1023");
+ BOOST_CHECK_EQUAL(arr[1].getValStr(), "zippy");
+ BOOST_CHECK_EQUAL(arr[2].getValStr(), "pippy");
+ BOOST_CHECK_EQUAL(arr[3].getValStr(), "boing");
+ BOOST_CHECK_EQUAL(arr[4].getValStr(), "going");
+
+ BOOST_CHECK_EQUAL(arr[999].getValStr(), "");
+
+ arr.clear();
+ BOOST_CHECK(arr.empty());
+ BOOST_CHECK_EQUAL(arr.count(), 0);
+}
+
+BOOST_AUTO_TEST_CASE(univalue_object)
+{
+ UniValue obj(UniValue::VOBJ);
+ string strKey, strVal;
+ UniValue v;
+
+ strKey = "age";
+ v.setInt(100);
+ BOOST_CHECK(obj.pushKV(strKey, v));
+
+ strKey = "first";
+ strVal = "John";
+ BOOST_CHECK(obj.pushKV(strKey, strVal));
+
+ strKey = "last";
+ const char *cVal = "Smith";
+ BOOST_CHECK(obj.pushKV(strKey, cVal));
+
+ strKey = "distance";
+ BOOST_CHECK(obj.pushKV(strKey, (int64_t) 25));
+
+ strKey = "time";
+ BOOST_CHECK(obj.pushKV(strKey, (uint64_t) 3600));
+
+ strKey = "calories";
+ BOOST_CHECK(obj.pushKV(strKey, (int) 12));
+
+ strKey = "temperature";
+ BOOST_CHECK(obj.pushKV(strKey, (double) 90.012));
+
+ UniValue obj2(UniValue::VOBJ);
+ BOOST_CHECK(obj2.pushKV("cat1", 9000));
+ BOOST_CHECK(obj2.pushKV("cat2", 12345));
+
+ BOOST_CHECK(obj.pushKVs(obj2));
+
+ BOOST_CHECK_EQUAL(obj.empty(), false);
+ BOOST_CHECK_EQUAL(obj.count(), 9);
+
+ BOOST_CHECK_EQUAL(obj["age"].getValStr(), "100");
+ BOOST_CHECK_EQUAL(obj["first"].getValStr(), "John");
+ BOOST_CHECK_EQUAL(obj["last"].getValStr(), "Smith");
+ BOOST_CHECK_EQUAL(obj["distance"].getValStr(), "25");
+ BOOST_CHECK_EQUAL(obj["time"].getValStr(), "3600");
+ BOOST_CHECK_EQUAL(obj["calories"].getValStr(), "12");
+ BOOST_CHECK_EQUAL(obj["temperature"].getValStr(), "90.012");
+ BOOST_CHECK_EQUAL(obj["cat1"].getValStr(), "9000");
+ BOOST_CHECK_EQUAL(obj["cat2"].getValStr(), "12345");
+
+ BOOST_CHECK_EQUAL(obj["nyuknyuknyuk"].getValStr(), "");
+
+ BOOST_CHECK(obj.exists("age"));
+ BOOST_CHECK(obj.exists("first"));
+ BOOST_CHECK(obj.exists("last"));
+ BOOST_CHECK(obj.exists("distance"));
+ BOOST_CHECK(obj.exists("time"));
+ BOOST_CHECK(obj.exists("calories"));
+ BOOST_CHECK(obj.exists("temperature"));
+ BOOST_CHECK(obj.exists("cat1"));
+ BOOST_CHECK(obj.exists("cat2"));
+
+ BOOST_CHECK(!obj.exists("nyuknyuknyuk"));
+
+ map<string, UniValue::VType> objTypes;
+ objTypes["age"] = UniValue::VNUM;
+ objTypes["first"] = UniValue::VSTR;
+ objTypes["last"] = UniValue::VSTR;
+ objTypes["distance"] = UniValue::VNUM;
+ objTypes["time"] = UniValue::VNUM;
+ objTypes["calories"] = UniValue::VNUM;
+ objTypes["temperature"] = UniValue::VNUM;
+ objTypes["cat1"] = UniValue::VNUM;
+ objTypes["cat2"] = UniValue::VNUM;
+ BOOST_CHECK(obj.checkObject(objTypes));
+
+ objTypes["cat2"] = UniValue::VSTR;
+ BOOST_CHECK(!obj.checkObject(objTypes));
+
+ obj.clear();
+ BOOST_CHECK(obj.empty());
+ BOOST_CHECK_EQUAL(obj.count(), 0);
+}
+
+static const char *json1 =
+"[1.1,{\"key1\":\"str\",\"key2\":800,\"key3\":{\"name\":\"martian\"}}]";
+
+BOOST_AUTO_TEST_CASE(univalue_readwrite)
+{
+ UniValue v;
+ BOOST_CHECK(v.read(json1));
+
+ string strJson1(json1);
+ BOOST_CHECK(v.read(strJson1));
+
+ BOOST_CHECK(v.isArray());
+ BOOST_CHECK_EQUAL(v.count(), 2);
+
+ BOOST_CHECK_EQUAL(v[0].getValStr(), "1.1");
+
+ UniValue obj = v[1];
+ BOOST_CHECK(obj.isObject());
+ BOOST_CHECK_EQUAL(obj.count(), 3);
+
+ BOOST_CHECK(obj["key1"].isStr());
+ BOOST_CHECK_EQUAL(obj["key1"].getValStr(), "str");
+ BOOST_CHECK(obj["key2"].isNum());
+ BOOST_CHECK_EQUAL(obj["key2"].getValStr(), "800");
+ BOOST_CHECK(obj["key3"].isObject());
+
+ BOOST_CHECK_EQUAL(strJson1, v.write());
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
diff --git a/src/tinyformat.h b/src/tinyformat.h
index b6113029f5..929cb66e4d 100644
--- a/src/tinyformat.h
+++ b/src/tinyformat.h
@@ -1007,4 +1007,6 @@ TINYFORMAT_WRAP_FORMAT_N(16, returnType, funcName, funcDeclSuffix, bodyPrefix, s
} // namespace tinyformat
+#define strprintf tfm::format
+
#endif // TINYFORMAT_H_INCLUDED
diff --git a/src/txdb.cpp b/src/txdb.cpp
index d3d05c58d7..7c0683aaf3 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -54,12 +54,15 @@ bool CCoinsViewDB::SetBestBlock(const uint256 &hashBlock) {
return db.WriteBatch(batch);
}
-bool CCoinsViewDB::BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock) {
+bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) {
LogPrint("coindb", "Committing %u changed transactions to coin database...\n", (unsigned int)mapCoins.size());
CLevelDBBatch batch;
- for (CCoinsMap::const_iterator it = mapCoins.begin(); it != mapCoins.end(); it++)
+ for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end();) {
BatchWriteCoins(batch, it->first, it->second);
+ CCoinsMap::iterator itOld = it++;
+ mapCoins.erase(itOld);
+ }
if (hashBlock != uint256(0))
BatchWriteHashBestChain(batch, hashBlock);
diff --git a/src/txdb.h b/src/txdb.h
index 7d670c2542..099f151776 100644
--- a/src/txdb.h
+++ b/src/txdb.h
@@ -37,7 +37,7 @@ public:
bool HaveCoins(const uint256 &txid);
uint256 GetBestBlock();
bool SetBestBlock(const uint256 &hashBlock);
- bool BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock);
+ bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock);
bool GetStats(CCoinsStats &stats);
};
diff --git a/src/univalue/gen.cpp b/src/univalue/gen.cpp
new file mode 100644
index 0000000000..881948f46e
--- /dev/null
+++ b/src/univalue/gen.cpp
@@ -0,0 +1,78 @@
+// Copyright 2014 BitPay Inc.
+// Distributed under the MIT/X11 software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+//
+// To re-create univalue_escapes.h:
+// $ g++ -o gen gen.cpp
+// $ ./gen > univalue_escapes.h
+//
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include "univalue.h"
+
+using namespace std;
+
+static bool initEscapes;
+static const char *escapes[256];
+
+static void initJsonEscape()
+{
+ escapes[(int)'"'] = "\\\"";
+ escapes[(int)'\\'] = "\\\\";
+ escapes[(int)'/'] = "\\/";
+ escapes[(int)'\b'] = "\\b";
+ escapes[(int)'\f'] = "\\f";
+ escapes[(int)'\n'] = "\\n";
+ escapes[(int)'\r'] = "\\r";
+ escapes[(int)'\t'] = "\\t";
+
+ initEscapes = true;
+}
+
+static void outputEscape()
+{
+ printf( "// Automatically generated file. Do not modify.\n"
+ "#ifndef __UNIVALUE_ESCAPES_H__\n"
+ "#define __UNIVALUE_ESCAPES_H__\n"
+ "static const char *escapes[256] = {\n");
+
+ for (unsigned int i = 0; i < 256; i++) {
+ if (!escapes[i]) {
+ printf("\tNULL,\n");
+ } else {
+ printf("\t\"");
+
+ unsigned int si;
+ for (si = 0; si < strlen(escapes[i]); si++) {
+ char ch = escapes[i][si];
+ switch (ch) {
+ case '"':
+ printf("\\\"");
+ break;
+ case '\\':
+ printf("\\\\");
+ break;
+ default:
+ printf("%c", escapes[i][si]);
+ break;
+ }
+ }
+
+ printf("\",\n");
+ }
+ }
+
+ printf( "};\n"
+ "#endif // __UNIVALUE_ESCAPES_H__\n");
+}
+
+int main (int argc, char *argv[])
+{
+ initJsonEscape();
+ outputEscape();
+ return 0;
+}
+
diff --git a/src/univalue/univalue.cpp b/src/univalue/univalue.cpp
index afc208bffb..b0171e48c4 100644
--- a/src/univalue/univalue.cpp
+++ b/src/univalue/univalue.cpp
@@ -44,7 +44,7 @@ static bool validNumStr(const string& s)
bool UniValue::setNumStr(const string& val_)
{
- if (!validNumStr(val))
+ if (!validNumStr(val_))
return false;
clear();
diff --git a/src/univalue/univalue_escapes.h b/src/univalue/univalue_escapes.h
new file mode 100644
index 0000000000..1d3a70a968
--- /dev/null
+++ b/src/univalue/univalue_escapes.h
@@ -0,0 +1,262 @@
+// Automatically generated file. Do not modify.
+#ifndef __UNIVALUE_ESCAPES_H__
+#define __UNIVALUE_ESCAPES_H__
+static const char *escapes[256] = {
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "\\b",
+ "\\t",
+ "\\n",
+ NULL,
+ "\\f",
+ "\\r",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "\\\"",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "\\/",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "\\\\",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+};
+#endif // __UNIVALUE_ESCAPES_H__
diff --git a/src/univalue/univalue_write.cpp b/src/univalue/univalue_write.cpp
index 1818f5c6f9..042091a827 100644
--- a/src/univalue/univalue_write.cpp
+++ b/src/univalue/univalue_write.cpp
@@ -5,33 +5,14 @@
#include <ctype.h>
#include <stdio.h>
#include "univalue.h"
+#include "univalue_escapes.h"
// TODO: Using UTF8
using namespace std;
-static bool initEscapes;
-static const char *escapes[256];
-
-static void initJsonEscape()
-{
- escapes['"'] = "\\\"";
- escapes['\\'] = "\\\\";
- escapes['/'] = "\\/";
- escapes['\b'] = "\\b";
- escapes['\f'] = "\\f";
- escapes['\n'] = "\\n";
- escapes['\r'] = "\\r";
- escapes['\t'] = "\\t";
-
- initEscapes = true;
-}
-
static string json_escape(const string& inS)
{
- if (!initEscapes)
- initJsonEscape();
-
string outS;
outS.reserve(inS.size() * 2);
@@ -110,8 +91,11 @@ void UniValue::writeArray(unsigned int prettyIndent, unsigned int indentLevel, s
if (prettyIndent)
s += indentStr(prettyIndent, indentLevel);
s += values[i].write(prettyIndent, indentLevel + 1);
- if (i != (values.size() - 1))
- s += ", ";
+ if (i != (values.size() - 1)) {
+ s += ",";
+ if (prettyIndent)
+ s += " ";
+ }
if (prettyIndent)
s += "\n";
}
@@ -130,7 +114,9 @@ void UniValue::writeObject(unsigned int prettyIndent, unsigned int indentLevel,
for (unsigned int i = 0; i < keys.size(); i++) {
if (prettyIndent)
s += indentStr(prettyIndent, indentLevel);
- s += "\"" + json_escape(keys[i]) + "\": ";
+ s += "\"" + json_escape(keys[i]) + "\":";
+ if (prettyIndent)
+ s += " ";
s += values[i].write(prettyIndent, indentLevel + 1);
if (i != (values.size() - 1))
s += ",";
diff --git a/src/util.h b/src/util.h
index db2005337b..1fb42a7b7e 100644
--- a/src/util.h
+++ b/src/util.h
@@ -108,7 +108,6 @@ bool LogAcceptCategory(const char* category);
/* Send a string to the log output */
int LogPrintStr(const std::string &str);
-#define strprintf tfm::format
#define LogPrintf(...) LogPrint(NULL, __VA_ARGS__)
/* When we switch to C++11, this can be switched to variadic templates instead
diff --git a/src/version.h b/src/version.h
index 85c5dbf8d7..fbb731c91d 100644
--- a/src/version.h
+++ b/src/version.h
@@ -26,7 +26,7 @@ extern const std::string CLIENT_DATE;
// network protocol versioning
//
-static const int PROTOCOL_VERSION = 70002;
+static const int PROTOCOL_VERSION = 70003;
// initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;
diff --git a/src/wallet.h b/src/wallet.h
index 73fcfa24e0..34c699e979 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -824,11 +824,6 @@ public:
{
return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue).c_str());
}
-
- void print() const
- {
- LogPrintf("%s\n", ToString());
- }
};
@@ -858,7 +853,7 @@ public:
READWRITE(vchPrivKey);
READWRITE(nTimeCreated);
READWRITE(nTimeExpires);
- READWRITE(strComment);
+ READWRITE(LIMITED_STRING(strComment, 65536));
)
};
@@ -933,7 +928,7 @@ public:
// Note: strAccount is serialized as part of the key, not here.
READWRITE(nCreditDebit);
READWRITE(nTime);
- READWRITE(strOtherAccount);
+ READWRITE(LIMITED_STRING(strOtherAccount, 65536));
if (!fRead)
{
@@ -949,7 +944,7 @@ public:
}
}
- READWRITE(strComment);
+ READWRITE(LIMITED_STRING(strComment, 65536));
size_t nSepPos = strComment.find("\0", 0, 1);
if (fRead)