aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am6
-rw-r--r--README.md10
-rw-r--r--contrib/README.md50
-rw-r--r--contrib/bitrpc/README.md2
-rw-r--r--contrib/debian/README20
-rw-r--r--contrib/debian/README.md21
-rw-r--r--contrib/gitian-descriptors/README.md (renamed from contrib/gitian-descriptors/README)44
-rw-r--r--contrib/gitian-downloader/michagogo-key.pgp82
-rw-r--r--contrib/linearize/README.md2
-rw-r--r--contrib/linearize/example-linearize.cfg (renamed from contrib/misc/example-linearize.cfg)0
-rw-r--r--[-rwxr-xr-x]contrib/linearize/linearize.py (renamed from contrib/misc/linearize.py)0
-rw-r--r--contrib/macdeploy/README.md19
-rw-r--r--contrib/macdeploy/notes.txt14
-rw-r--r--contrib/pyminer/README.md (renamed from contrib/pyminer/README)3
-rw-r--r--contrib/qos/README.md (renamed from contrib/qos/README)2
-rw-r--r--contrib/seeds/README.md (renamed from contrib/seeds/README)6
-rw-r--r--contrib/spendfrom/README.md (renamed from contrib/spendfrom/README)16
-rw-r--r--contrib/test-patches/README.md (renamed from contrib/test-patches/README)5
-rw-r--r--contrib/testgen/README1
-rw-r--r--contrib/testgen/README.md8
-rw-r--r--contrib/verifysfbinaries/README.md7
-rw-r--r--contrib/wallettools/README.md4
-rw-r--r--doc/README.md22
-rw-r--r--doc/build-unix.md27
-rw-r--r--doc/multiwallet-qt.md14
-rw-r--r--doc/readme-qt.md101
-rw-r--r--doc/tor.md6
-rw-r--r--src/alert.h2
-rw-r--r--src/allocators.cpp3
-rw-r--r--src/allocators.h45
-rw-r--r--src/base58.h2
-rw-r--r--src/bignum.h2
-rw-r--r--src/bitcoind.cpp2
-rw-r--r--src/bitcoinrpc.cpp2
-rw-r--r--src/bitcoinrpc.h2
-rw-r--r--src/chainparams.cpp2
-rw-r--r--src/checkpoints.cpp2
-rw-r--r--src/checkpoints.h2
-rw-r--r--src/compat.h2
-rw-r--r--src/core.h34
-rw-r--r--src/crypter.cpp2
-rw-r--r--src/crypter.h10
-rw-r--r--src/db.cpp2
-rw-r--r--src/db.h4
-rw-r--r--src/hash.h2
-rw-r--r--src/init.cpp27
-rw-r--r--src/init.h2
-rw-r--r--src/key.cpp25
-rw-r--r--src/key.h3
-rw-r--r--src/keystore.cpp2
-rw-r--r--src/keystore.h2
-rw-r--r--src/main.cpp141
-rw-r--r--src/main.h61
-rw-r--r--src/miner.cpp18
-rw-r--r--src/miner.h2
-rw-r--r--src/net.cpp2
-rw-r--r--src/net.h2
-rw-r--r--src/netbase.cpp2
-rw-r--r--src/netbase.h2
-rw-r--r--src/noui.cpp2
-rw-r--r--src/protocol.cpp2
-rw-r--r--src/protocol.h2
-rw-r--r--src/qt/Makefile.am6
-rw-r--r--src/qt/bitcoin.cpp4
-rw-r--r--src/qt/bitcoinamountfield.cpp5
-rw-r--r--src/qt/bitcoingui.cpp5
-rw-r--r--src/qt/bitcoingui.h8
-rw-r--r--src/qt/clientmodel.cpp4
-rw-r--r--src/qt/forms/sendcoinsentry.ui8
-rw-r--r--src/qt/paymentserver.cpp54
-rw-r--r--src/qt/paymentserver.h4
-rw-r--r--src/qt/sendcoinsentry.cpp24
-rw-r--r--src/qt/sendcoinsentry.h2
-rw-r--r--src/qt/walletframe.cpp117
-rw-r--r--src/qt/walletframe.h16
-rw-r--r--src/qt/walletmodel.cpp32
-rw-r--r--src/qt/walletstack.cpp174
-rw-r--r--src/qt/walletstack.h104
-rw-r--r--src/qt/walletview.cpp35
-rw-r--r--src/qt/walletview.h3
-rw-r--r--src/rpcblockchain.cpp2
-rw-r--r--src/rpcdump.cpp2
-rw-r--r--src/rpcmining.cpp2
-rw-r--r--src/rpcnet.cpp2
-rw-r--r--src/rpcrawtransaction.cpp2
-rw-r--r--src/rpcwallet.cpp6
-rw-r--r--src/script.cpp148
-rw-r--r--src/script.h2
-rw-r--r--src/serialize.h8
-rw-r--r--src/sync.cpp4
-rw-r--r--src/sync.h2
-rw-r--r--src/test/Makefile.am2
-rw-r--r--src/test/multisig_tests.cpp2
-rw-r--r--src/test/script_tests.cpp2
-rw-r--r--src/test/serialize_tests.cpp60
-rw-r--r--src/test/sighash_tests.cpp120
-rw-r--r--src/txdb.cpp2
-rw-r--r--src/txdb.h2
-rw-r--r--src/uint256.h2
-rw-r--r--src/util.cpp4
-rw-r--r--src/util.h2
-rw-r--r--src/wallet.cpp19
-rw-r--r--src/wallet.h2
-rw-r--r--src/walletdb.cpp40
-rw-r--r--src/walletdb.h12
105 files changed, 1055 insertions, 912 deletions
diff --git a/Makefile.am b/Makefile.am
index b4ea94ad62..dc0e6d8f76 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -81,10 +81,10 @@ OSX_APP_BUILT=$(OSX_APP)/Contents/PkgInfo $(OSX_APP)/Contents/Resources/empty.lp
$(OSX_DMG): $(OSX_APP_BUILT) $(OSX_PACKAGING)
$(OSX_DEPLOY_SCRIPT) $(OSX_APP) -add-qt-tr da,de,es,hu,ru,uk,zh_CN,zh_TW -dmg -fancy $(OSX_FANCY_PLIST) -verbose 2
- rm -rf $(OSX_APP)
if TARGET_DARWIN
+appbundle: $(OSX_APP_BUILT)
deploy: $(OSX_DMG)
endif
if TARGET_WINDOWS
@@ -151,9 +151,9 @@ endif
EXTRA_DIST = $(top_srcdir)/share/genbuild.sh qa/pull-tester/pull-tester.sh $(WINDOWS_PACKAGING) $(OSX_PACKAGING)
-CLEANFILES = $(OSX_DMG) $(BITCOIN_WIN_INSTALLER)
+CLEANFILES = $(OSX_DMG) $(OSX_APP) $(BITCOIN_WIN_INSTALLER)
-.INTERMEDIATE: $(OSX_APP_BUILT) $(COVERAGE_INFO)
+.INTERMEDIATE: $(COVERAGE_INFO)
clean-local:
rm -rf test_bitcoin.coverage/ total.coverage/
diff --git a/README.md b/README.md
index 0ac3222328..2534a62b08 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ the Bitcoin client software, see http://www.bitcoin.org.
License
-------
-Bitcoin is released under the terms of the MIT license. See `COPYING` for more
+Bitcoin is released under the terms of the MIT license. See [COPYING](COPYING) for more
information or see http://opensource.org/licenses/MIT.
Development process
@@ -38,7 +38,7 @@ submitter will be asked to start a discussion (if they haven't already) on the
The patch will be accepted if there is broad consensus that it is a good thing.
Developers should expect to rework and resubmit patches if the code doesn't
-match the project's coding conventions (see `doc/coding.md`) or are
+match the project's coding conventions (see [doc/coding.md](doc/coding.md)) or are
controversial.
The `master` branch is regularly built and tested, but is not guaranteed to be
@@ -56,10 +56,7 @@ lots of money.
### Automated Testing
Developers are strongly encouraged to write unit tests for new code, and to
-submit new unit tests for old code.
-
-Unit tests can be compiled and run (assuming they weren't disabled in configure) with:
- make check
+submit new unit tests for old code. Unit tests can be compiled and run (assuming they weren't disabled in configure) with: `make check`
Every pull request is built for both Windows and Linux on a dedicated server,
and unit and sanity tests are automatically run. The binaries produced may be
@@ -71,5 +68,4 @@ for the build/test scripts.
Large changes should have a test plan, and should be tested by somebody other
than the developer who wrote the code.
-
See https://github.com/bitcoin/QA/ for how to create a test plan.
diff --git a/contrib/README.md b/contrib/README.md
new file mode 100644
index 0000000000..7128fd5eb0
--- /dev/null
+++ b/contrib/README.md
@@ -0,0 +1,50 @@
+Contrib Index
+---------------------
+
+### [BitRPC](/contrib/bitrpc) ###
+Added bitrpc.py which allows for sending of all standard Bitcoin commands via RPC rather than as command line args.
+
+### [Debian](/contrib/debian) ###
+Contains files used to package bitcoind/bitcoin-qt
+for Debian-based Linux systems. If you compile bitcoind/bitcoin-qt yourself, there are some useful files here.
+
+### [Gitian-descriptors](/contrib/gitian-descriptors) ###
+Gavin's notes on getting gitian builds up and running using KVM.
+
+### [Gitian-downloader](/contrib/gitian-downloader)
+Various PGP files of core developers.
+
+### [Linearize](/contrib/linearize) ###
+Construct a linear, no-fork, best version of the blockchain.
+
+### [MacDeploy](/contrib/macdeploy) ###
+Scripts and notes for Mac builds.
+
+### [PyMiner](/contrib/pyminer) ###
+
+This is a 'getwork' CPU mining client for Bitcoin. It is pure-python, and therefore very, very slow. The purpose is to provide a reference implementation of a miner, for study.
+
+### [Qos](/contrib/qos) ###
+
+A Linux bash script that will set up tc to limit the outgoing bandwidth for connections to the Bitcoin network. This means one can have an always-on bitcoind instance running, and another local bitcoind/bitcoin-qt instance which connects to this node and receives blocks from it.
+
+### [Seeds](/contrib/seeds) ###
+Utility to generate the pnSeed[] array that is compiled into the client.
+
+### [SpendFrom](/contrib/spendfrom) ###
+
+Use the raw transactions API to send coins received on a particular
+address (or addresses).
+
+### [TestGen](/contrib/testgen) ###
+Utilities to generate test vectors for the data-driven Bitcoin tests.
+
+### [Test Patches](/contrib/test-patches) ###
+These patches are applied when the automated pull-tester
+tests each pull and when master is tested using jenkins.
+
+### [Verify SF Binaries](/contrib/verifysfbinaries) ###
+This script attempts to download and verify the signature file SHA256SUMS.asc from SourceForge.
+
+### [Wallet Tools](/contrib/wallettools) ###
+Contains a wallet change password and unlock script.
diff --git a/contrib/bitrpc/README.md b/contrib/bitrpc/README.md
new file mode 100644
index 0000000000..2dde60a08e
--- /dev/null
+++ b/contrib/bitrpc/README.md
@@ -0,0 +1,2 @@
+### BitRPC ###
+Allows for sending of all standard Bitcoin commands via RPC rather than as command line args. \ No newline at end of file
diff --git a/contrib/debian/README b/contrib/debian/README
deleted file mode 100644
index 1cb9b75fbd..0000000000
--- a/contrib/debian/README
+++ /dev/null
@@ -1,20 +0,0 @@
-This directory contains files used to package bitcoind/bitcoin-qt
-for Debian-based Linux systems.
-
-If you compile bitcoind/bitcoin-qt yourself, there are some
-useful files here:
-
-bitcoin: URI support
---------------------
-
-bitcoin-qt.desktop (Gnome / Open Desktop)
-To install:
- sudo desktop-file-install bitcoin-qt.desktop
- sudo update-desktop-database
-
-If you build yourself, you will either need to modify the paths in
-the .desktop file or copy or symlink your bitcoin-qt binary to /usr/bin
-and the ../../share/pixmaps/bitcoin128.png to /usr/share/pixmaps
-
-bitcoin-qt.protocol (KDE)
-
diff --git a/contrib/debian/README.md b/contrib/debian/README.md
new file mode 100644
index 0000000000..fab9cc2381
--- /dev/null
+++ b/contrib/debian/README.md
@@ -0,0 +1,21 @@
+
+Debian
+====================
+This directory contains files used to package bitcoind/bitcoin-qt
+for Debian-based Linux systems. If you compile bitcoind/bitcoin-qt yourself, there are some useful files here.
+
+## bitcoin: URI support ##
+
+
+bitcoin-qt.desktop (Gnome / Open Desktop)
+To install:
+
+ sudo desktop-file-install bitcoin-qt.desktop
+ sudo update-desktop-database
+
+If you build yourself, you will either need to modify the paths in
+the .desktop file or copy or symlink your bitcoin-qt binary to `/usr/bin`
+and the `../../share/pixmaps/bitcoin128.png` to `/usr/share/pixmaps`
+
+bitcoin-qt.protocol (KDE)
+
diff --git a/contrib/gitian-descriptors/README b/contrib/gitian-descriptors/README.md
index e9c7d4efc2..40bdbd8e32 100644
--- a/contrib/gitian-descriptors/README
+++ b/contrib/gitian-descriptors/README.md
@@ -1,7 +1,7 @@
-Gavin's notes on getting gitian builds up and running using KVM:
+### Gavin's notes on getting gitian builds up and running using KVM:###
These instructions distilled from:
- https://help.ubuntu.com/community/KVM/Installation
+[ https://help.ubuntu.com/community/KVM/Installation]( https://help.ubuntu.com/community/KVM/Installation)
... see there for complete details.
You need the right hardware: you need a 64-bit-capable CPU with hardware virtualization support (Intel VT-x or AMD-V). Not all modern CPUs support hardware virtualization.
@@ -9,11 +9,13 @@ You need the right hardware: you need a 64-bit-capable CPU with hardware virtual
You probably need to enable hardware virtualization in your machine's BIOS.
You need to be running a recent version of 64-bit-Ubuntu, and you need to install several prerequisites:
- sudo apt-get install ruby apache2 git apt-cacher-ng python-vm-builder qemu-kvm
+
+ sudo apt-get install ruby apache2 git apt-cacher-ng python-vm-builder qemu-kvm
Sanity checks:
- sudo service apt-cacher-ng status # Should return apt-cacher-ng is running
- ls -l /dev/kvm # Should show a /dev/kvm device
+
+ sudo service apt-cacher-ng status # Should return apt-cacher-ng is running
+ ls -l /dev/kvm # Should show a /dev/kvm device
Once you've got the right hardware and software:
@@ -22,10 +24,12 @@ Once you've got the right hardware and software:
git clone git://github.com/devrandom/gitian-builder.git
mkdir gitian-builder/inputs
cd gitian-builder/inputs
+
# Inputs for Linux and Win32:
wget -O miniupnpc-1.6.tar.gz 'http://miniupnp.tuxfamily.org/files/download.php?file=miniupnpc-1.6.tar.gz'
wget 'http://fukuchi.org/works/qrencode/qrencode-3.2.0.tar.bz2'
- # Inputs for Win32: (Linux has packages for these)
+
+ # Inputs for Win32: (Linux has packages for these)
wget 'https://downloads.sourceforge.net/project/boost/boost/1.50.0/boost_1_50_0.tar.bz2'
wget 'http://www.openssl.org/source/openssl-1.0.1c.tar.gz'
wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
@@ -58,31 +62,29 @@ Once you've got the right hardware and software:
---------------------
-gitian-builder now also supports building using LXC. See
- https://help.ubuntu.com/12.04/serverguide/lxc.html
+`gitian-builder` now also supports building using LXC. See
+[ https://help.ubuntu.com/12.04/serverguide/lxc.html]( https://help.ubuntu.com/12.04/serverguide/lxc.html)
... for how to get LXC up and running under Ubuntu.
If your main machine is a 64-bit Mac or PC with a few gigabytes of memory
-and at least 10 gigabytes of free disk space, you can gitian-build using
+and at least 10 gigabytes of free disk space, you can `gitian-build` using
LXC running inside a virtual machine.
Here's a description of Gavin's setup on OSX 10.6:
-1. Download and install VirtualBox from https://www.virtualbox.org/
+1. Download and install VirtualBox from [https://www.virtualbox.org/](https://www.virtualbox.org/)
2. Download the 64-bit Ubuntu Desktop 12.04 LTS .iso CD image from
- http://www.ubuntu.com/
+ [http://www.ubuntu.com/](http://www.ubuntu.com/)
-3. Run VirtualBox and create a new virtual machine, using the
- Ubuntu .iso (see the VirtualBox documentation for details).
- Create it with at least 2 gigabytes of memory and a disk
- that is at least 20 gigabytes big.
+3. Run VirtualBox and create a new virtual machine, using the Ubuntu .iso (see the [VirtualBox documentation](https://www.virtualbox.org/wiki/Documentation) for details). Create it with at least 2 gigabytes of memory and a disk that is at least 20 gigabytes big.
4. Inside the running Ubuntu desktop, install:
- sudo apt-get install debootstrap lxc ruby apache2 git apt-cacher-ng python-vm-builder
-5. Still inside Ubuntu, tell gitian-builder to use LXC, then follow the "Once you've got the right
- hardware and software" instructions above:
- export USE_LXC=1
- git clone git://github.com/bitcoin/bitcoin.git
- ... etc
+ sudo apt-get install debootstrap lxc ruby apache2 git apt-cacher-ng python-vm-builder
+
+5. Still inside Ubuntu, tell gitian-builder to use LXC, then follow the "Once you've got the right hardware and software" instructions above:
+
+ export USE_LXC=1
+ git clone git://github.com/bitcoin/bitcoin.git
+ ... etc \ No newline at end of file
diff --git a/contrib/gitian-downloader/michagogo-key.pgp b/contrib/gitian-downloader/michagogo-key.pgp
index bc20629fa0..47bc404554 100644
--- a/contrib/gitian-downloader/michagogo-key.pgp
+++ b/contrib/gitian-downloader/michagogo-key.pgp
@@ -1,27 +1,59 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
-Version: SKS 1.1.0
+Version: GnuPG v1.4.12 (GNU/Linux)
-mQENBFGeqJ4BCADb7SI3/+q93gIvN0AGRg9Mtz73OLIOzCHeeoyn+tp7JcYNzxkQ9lfeXiEf
-n72Sh8gHkLtLIqr7HlIMo8DxSS8JPRVjlJGkNyAW4SeEwN2wNa5OV8k0N4jBa9a1csFyCyrE
-kPKvkUpBkQDvNXjNxyEhHwyZqPanKxy6NXIHOJji8ObOMQXIT9HwJrpjRth3u4uKG968JBTE
-yAXAmkt0Zidl1Ykgzcedk4mJSE9uZCW8DjSv2wMLXcQz8+dYsoskT3KRdkowLHxAfj1BNyNc
-1+rKLghliM5vSQWi+Lbhi1Bxh4sY1UwAlKnAGqrnAGyIvCtkwTq5QI6ufF2ZY44bvVgpABEB
-AAG0IU1pY2hhZ29nbyA8bWljaGFnb2dvQHNlcnZlci5mYWtlPokBOAQTAQIAIgUCUZ6ongIb
-AwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQgsXACWKOzwzMUAgAuqUmK10xE5C3lUym
-2f72z0t6a2NM5Wfjr9//Y1/okC36C5XAMEtN2UwckPzzJ5p5D5y5yzwfZq5Jd8Py29VQIMsV
-7FbC1a0H3D+bCyX+JJ6FAmUbnWOQ/+mydYc74RvD8iwjePNT6kziZNv6dMGctJTl0alwjtQY
-gyGkeYKnIxbcyjHX/IawLUrunb/6mSKun87T8+NM/omfFCTc3l8TakpM0wyNYRiUkIfUBvB8
-sDUU3A80qKN/hqRKvlFu3+/kMiAc9ZYQrbmsB+sYWdmM+4zw8NBw3yuYzWyPuoa4PR5ZmS9F
-11WLMR5vTRCdLudAqYsWu3LtV6vAIvlOUa2LMLkBDQRRnqieAQgAxZoEe6BBpBRQeal57jWB
-atZ1BgwIdHSzbQA9yehDMVGRF3Zqfg0BycOv3g0UGhvRG4zWYXsnG1VKCPCtmP2duvB0Lnhr
-iBCCb+nGWF6F3Vgmww+H5xzDVF9sDZaQ6lsW+zzVBLX1PYSN4Jhxpa+TohId4ldOromYOJ9q
-21j24+OZuSyc78KQq1APqS3JfV48NnGo2kk43Vx5PYL10wqOrNmUt/90OJfsbs2adTBjcz0B
-wEjCrMHnEiSpGIOlvCOVrFZT3fWvKEAnPzX8+wT8N9TEVUf0heRQDKml8ebi8IIVXRwdonC1
-EbDrSZQnz/FtOoAe8kvjB+OSav6MQUYiQQARAQABiQEfBBgBAgAJBQJRnqieAhsMAAoJEILF
-wAlijs8ME+MIAMuiAnJwWfZdo0rvpXcuexeo3+ZKSmYAfTVfFdpjADXmNcDEOFU1aVOLd7OB
-Ni2LRjSTZD0FR27dT3+HRj2rLzD2hzGpoMIMqoGIsarNMQ+T3Ss1a3548E06/2QBXXHEj5r8
-uf4W2NIHkP/ps3Wy9O/sWk+fCSKBuZ8kgyoZglXjr4Q2bVzFQIRFgQzxIIfx/bBLgYDIGa83
-xNY96vNNqol3kLOlrWnVpUNUTfSKtWcyIurvfwYnxCESNKTv1sCjmXVy03phVKGpKHu7k9wO
-+DferdBvS2VYoWGxKDvj3OSGhzwVeVS3kd0wdS554x1X/xcIvHJxsudJDVo3GzMhA2o=
-=YdfZ
------END PGP PUBLIC KEY BLOCK----- \ No newline at end of file
+mQENBFGeqJ4BCADb7SI3/+q93gIvN0AGRg9Mtz73OLIOzCHeeoyn+tp7JcYNzxkQ
+9lfeXiEfn72Sh8gHkLtLIqr7HlIMo8DxSS8JPRVjlJGkNyAW4SeEwN2wNa5OV8k0
+N4jBa9a1csFyCyrEkPKvkUpBkQDvNXjNxyEhHwyZqPanKxy6NXIHOJji8ObOMQXI
+T9HwJrpjRth3u4uKG968JBTEyAXAmkt0Zidl1Ykgzcedk4mJSE9uZCW8DjSv2wML
+XcQz8+dYsoskT3KRdkowLHxAfj1BNyNc1+rKLghliM5vSQWi+Lbhi1Bxh4sY1UwA
+lKnAGqrnAGyIvCtkwTq5QI6ufF2ZY44bvVgpABEBAAG0IU1pY2hhZ29nbyA8bWlj
+aGFnb2dvQHNlcnZlci5mYWtlPokBOAQTAQIAIgUCUZ6ongIbAwYLCQgHAwIGFQgC
+CQoLBBYCAwECHgECF4AACgkQgsXACWKOzwzMUAgAuqUmK10xE5C3lUym2f72z0t6
+a2NM5Wfjr9//Y1/okC36C5XAMEtN2UwckPzzJ5p5D5y5yzwfZq5Jd8Py29VQIMsV
+7FbC1a0H3D+bCyX+JJ6FAmUbnWOQ/+mydYc74RvD8iwjePNT6kziZNv6dMGctJTl
+0alwjtQYgyGkeYKnIxbcyjHX/IawLUrunb/6mSKun87T8+NM/omfFCTc3l8TakpM
+0wyNYRiUkIfUBvB8sDUU3A80qKN/hqRKvlFu3+/kMiAc9ZYQrbmsB+sYWdmM+4zw
+8NBw3yuYzWyPuoa4PR5ZmS9F11WLMR5vTRCdLudAqYsWu3LtV6vAIvlOUa2LMLRg
+TWljaGFnb2dvIChSZWdpc3RlcmVkIG5pY2sgbWljaGFnb2dvIG9uIGZyZWVub2Rl
+IGFzIG9mIE9jdG9iZXIgMTIsIDIwMTMpIDxtaWNoYWdvZ29Ac2VydmVyLmZha2U+
+iQE4BBMBAgAiBQJSWarzAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRCC
+xcAJYo7PDA7nB/91wAiaMlU5nHLUu0anhNQbGvUdFgKK1zO90S5KzUdJcY438jcS
+UJW1az8l9U9JBRIfPRYVhz/Z1TAJ+dCzD7D8BXHFeGEr0zNOh87ly9aB5du7dpN2
+oSBD6wLcJpqxt4h+XjSS2CX98/2ZIJxXENE2KySaTXP39Xl3eNwvJTUBA4XlcMey
+J8KMp/IERli4H0O7vRyLgu3yYpUArTqAonzG1g2lfB35PQJfeInrRSniQ336otnZ
+A8qwJ63kfUtWVDRz0g1fnvtiLGPivDJaI5hyIaUeJPaXU1+sg7YNroDu60o2NGZh
+F+0IjHlvRfzzA+F9Vw38rpSqR3BmCdjf6Sv3iQEcBBABAgAGBQJSWa9/AAoJEH+r
+EUJn5PoE/hgH/1T2dAthVucA/hzY0nl4SMjbg+dzNlYBq00Qwx8DRKVjk5et8+kY
+oPI3DGILcr+ELnxNekeMv9WQBBtJanUh1K5ohZ6ohoR7lG18LXf5HCdspflB5Me6
+LMA6iMryEP6gIs9GFuoGe2YQavm58YrkqhcPu34dGN7kdurfEXLvDfVlh5ZbKCsP
+Gyd7Pbz04SpqykgK1udiTsLVjc70Xhv+jAMqeaCugDX6TLEwjVmZH/xsyKk2Uh3V
+Oib5FXADAtKH+vSqqhFpXrw7R/NaBzvCbas8l61DFHiUg1/bo8vsV8MtGcyZmzXJ
+C5Gm0njtGOil/g7JF9siUrpxs9Yyt/h+T2W0W01pY2hhZ29nbyAoVXNlciBhY2Nv
+dW50IG1pY2hhZ29nbyBvbiBHaXRodWIgYXMgb2YgT2N0b2JlciAxMiwgMjAxMykg
+PG1pY2hhZ29nb0BzZXJ2ZXIuZmFrZT6JATcEEwECACIFAlJZqxkCGwMGCwkIBwMC
+BhUIAgkKCwQWAgMBAh4BAheAAAoJEILFwAlijs8M+1AH+IU78ARblqTnJeSl0iWH
+mEsg4IBK30Q6/exDAcqOEm1Yc171uw2WnGmIvPYOQqxrRTvj3LoQ816dU6jrj6vY
+s+XX0R2hxy7ILh17D/3UKnHcddu7rmc7pNEqZeBXaMughqQaPOWkAIe52+qK5tsl
+sWllzTYE4jo29uZ3dAtDcKEJjBo/pIXnu1GOslE1+V4X1H9WDlwrS/JXHzyDQAjt
+maPR+3gNesDanhrRmrnT3ZXW2ZVd3vGBibhia8PWUhU1uwOH23ySWXncgsHH0Zad
+UMjd4w3YliZP/mLn2ghAxHB70IO7lgAgN3HYZeFoufP3pcK440A+CezfQiRcjHl/
+oIkBHAQQAQIABgUCUlmvfwAKCRB/qxFCZ+T6BOq9CACItsrUZPKGeWSTkMHknMrV
+K5vxIXJVCBb+Tppc0Q/J5p4EkW/RFhTwIP2zw8NLDKMh5oO9md4LXhvfIZkqQJFo
+6ZtLa3Vf+Kj7uyxezBo4QHA+G7tDsRGaMKVrEMiyLCwS1+hg9VaNzsf7zmQW7mYE
+vTLMHp3cVaSU7Mh2Dl8rnAaM/DpTUZQwZ+32Qrb/Z4HSa4f278iqoFpjEbBE2KCr
+vT5yEVvpCZ4lwSgA2a+uTlRTvVV6NA/kpsxU64tmhuEOjy+ToDqJ8wv4mqvWZxMv
+C6OhfVaXBy3U9gG8aQV0ffXGs+TbCtv8ApHd6E1/AVk0oyZGJaBVrEl688bBIWd/
+uQENBFGeqJ4BCADFmgR7oEGkFFB5qXnuNYFq1nUGDAh0dLNtAD3J6EMxUZEXdmp+
+DQHJw6/eDRQaG9EbjNZheycbVUoI8K2Y/Z268HQueGuIEIJv6cZYXoXdWCbDD4fn
+HMNUX2wNlpDqWxb7PNUEtfU9hI3gmHGlr5OiEh3iV06uiZg4n2rbWPbj45m5LJzv
+wpCrUA+pLcl9Xjw2cajaSTjdXHk9gvXTCo6s2ZS3/3Q4l+xuzZp1MGNzPQHASMKs
+wecSJKkYg6W8I5WsVlPd9a8oQCc/Nfz7BPw31MRVR/SF5FAMqaXx5uLwghVdHB2i
+cLURsOtJlCfP8W06gB7yS+MH45Jq/oxBRiJBABEBAAGJAR8EGAECAAkFAlGeqJ4C
+GwwACgkQgsXACWKOzwwT4wgAy6ICcnBZ9l2jSu+ldy57F6jf5kpKZgB9NV8V2mMA
+NeY1wMQ4VTVpU4t3s4E2LYtGNJNkPQVHbt1Pf4dGPasvMPaHMamgwgyqgYixqs0x
+D5PdKzVrfnjwTTr/ZAFdccSPmvy5/hbY0geQ/+mzdbL07+xaT58JIoG5nySDKhmC
+VeOvhDZtXMVAhEWBDPEgh/H9sEuBgMgZrzfE1j3q802qiXeQs6WtadWlQ1RN9Iq1
+ZzIi6u9/BifEIRI0pO/WwKOZdXLTemFUoakoe7uT3A74N96t0G9LZVihYbEoO+Pc
+5IaHPBV5VLeR3TB1LnnjHVf/Fwi8cnGy50kNWjcbMyEDag==
+=jyQ4
+-----END PGP PUBLIC KEY BLOCK-----
diff --git a/contrib/linearize/README.md b/contrib/linearize/README.md
new file mode 100644
index 0000000000..70b9f034cd
--- /dev/null
+++ b/contrib/linearize/README.md
@@ -0,0 +1,2 @@
+### Linearize ###
+Construct a linear, no-fork, best version of the blockchain. \ No newline at end of file
diff --git a/contrib/misc/example-linearize.cfg b/contrib/linearize/example-linearize.cfg
index 9e5aa404c2..9e5aa404c2 100644
--- a/contrib/misc/example-linearize.cfg
+++ b/contrib/linearize/example-linearize.cfg
diff --git a/contrib/misc/linearize.py b/contrib/linearize/linearize.py
index 2d8509f83c..2d8509f83c 100755..100644
--- a/contrib/misc/linearize.py
+++ b/contrib/linearize/linearize.py
diff --git a/contrib/macdeploy/README.md b/contrib/macdeploy/README.md
new file mode 100644
index 0000000000..5f0611f20c
--- /dev/null
+++ b/contrib/macdeploy/README.md
@@ -0,0 +1,19 @@
+### MacDeploy ###
+
+You will need the appscript package for the fancy disk image creation to work:
+
+ sudo easy_install appscript
+
+For Snow Leopard (which uses [Python 2.6](http://www.python.org/download/releases/2.6/)), you will need the param_parser package:
+
+ sudo easy_install argparse
+
+This script should not be run manually, instead, after building as usual:
+
+ make deploy
+
+During the process, the disk image window will pop up briefly where the fancy
+settings are applied. This is normal, please do not interfere.
+
+When finished, it will produce `Bitcoin-Qt.dmg`.
+
diff --git a/contrib/macdeploy/notes.txt b/contrib/macdeploy/notes.txt
deleted file mode 100644
index e7f62c4a39..0000000000
--- a/contrib/macdeploy/notes.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-You will need the appscript package for the fancy disk image creation to work.
-Install it by invoking "sudo easy_install appscript".
-
-For Snow Leopard (which uses Python 2.6), you will need the param_parser package.
-Install it by invoking "sudo easy_install argparse"
-
-This script should not be run manually, instead, after building as usual:
-"make deploy"
-
-During the process, the disk image window will pop up briefly where the fancy
-settings are applied. This is normal, please do not interfere.
-
-When finished, it will produce Bitcoin-Qt.dmg.
-
diff --git a/contrib/pyminer/README b/contrib/pyminer/README.md
index d1596575dd..119d51bdc7 100644
--- a/contrib/pyminer/README
+++ b/contrib/pyminer/README.md
@@ -1,5 +1,6 @@
+### PyMiner ###
-This is a 'getwork' CPU mining client for bitcoin.
+This is a 'getwork' CPU mining client for Bitcoin.
It is pure-python, and therefore very, very slow. The purpose is to
provide a reference implementation of a miner, for study.
diff --git a/contrib/qos/README b/contrib/qos/README.md
index f419685744..5e0a975fc6 100644
--- a/contrib/qos/README
+++ b/contrib/qos/README.md
@@ -1,3 +1,5 @@
+### Qos ###
+
This is a Linux bash script that will set up tc to limit the outgoing bandwidth for connections to the Bitcoin network. It limits outbound TCP traffic with a source or destination port of 8333, but not if the destination IP is within a LAN (defined as 192.168.x.x).
This means one can have an always-on bitcoind instance running, and another local bitcoind/bitcoin-qt instance which connects to this node and receives blocks from it.
diff --git a/contrib/seeds/README b/contrib/seeds/README.md
index 97e3e1ec71..f9a0c277e2 100644
--- a/contrib/seeds/README
+++ b/contrib/seeds/README.md
@@ -1,9 +1,11 @@
+### Seeds ###
+
Utility to generate the pnSeed[] array that is compiled into the client
-(see src/net.cpp).
+(see [src/net.cpp](/src/net.cpp)).
The 600 seeds compiled into the 0.8 release were created from sipa's DNS seed data, like this:
-curl -s http://bitcoin.sipa.be/seeds.txt | head -1000 | makeseeds.py
+ curl -s http://bitcoin.sipa.be/seeds.txt | head -1000 | makeseeds.py
The input to makeseeds.py is assumed to be approximately sorted from most-reliable to least-reliable,
with IP:port first on each line (lines that don't match IPv4:port are ignored).
diff --git a/contrib/spendfrom/README b/contrib/spendfrom/README.md
index 8a087a0c1e..bc4def5f74 100644
--- a/contrib/spendfrom/README
+++ b/contrib/spendfrom/README.md
@@ -1,16 +1,18 @@
+### SpendFrom ###
+
Use the raw transactions API to send coins received on a particular
address (or addresses).
-Depends on jsonrpc
+Depends on `jsonrpc`
Usage:
-spendfrom.py --from=FROMADDRESS1[,FROMADDRESS2] --to=TOADDRESS --amount=amount \
- --fee=fee --datadir=/path/to/.bitcoin --testnet --dry_run
+ spendfrom.py --from=FROMADDRESS1[,FROMADDRESS2] --to=TOADDRESS --amount=amount \
+ --fee=fee --datadir=/path/to/.bitcoin --testnet --dry_run
With no arguments, outputs a list of amounts associated with addresses.
-With arguments, sends coins received by the FROMADDRESS addresses to the TOADDRESS.
+With arguments, sends coins received by the `FROMADDRESS` addresses to the `TOADDRESS`.
You may explictly specify how much fee to pay (a fee more than 1% of the amount
will fail, though, to prevent bitcoin-losing accidents). Spendfrom may fail if
@@ -18,11 +20,11 @@ it thinks the transaction would never be confirmed (if the amount being sent is
too small, or if the transaction is too many bytes for the fee).
If a change output needs to be created, the change will be sent to the last
-FROMADDRESS (if you specify just one FROMADDRESS, change will go back to it).
+`FROMADDRESS` (if you specify just one `FROMADDRESS`, change will go back to it).
-If --datadir is not specified, the default datadir is used.
+If `--datadir` is not specified, the default datadir is used.
-The --dry_run option will just create and sign the the transaction and print
+The `--dry_run` option will just create and sign the the transaction and print
the transaction data (as hexadecimal), instead of broadcasting it.
If the transaction is created and broadcast successfully, a transaction id
diff --git a/contrib/test-patches/README b/contrib/test-patches/README.md
index ed754cea7a..def40b0d6c 100644
--- a/contrib/test-patches/README
+++ b/contrib/test-patches/README.md
@@ -1,4 +1,7 @@
+### Test Patches ###
+
These patches are applied when the automated pull-tester
tests each pull and when master is tested using jenkins.
You can find more information about the tests run at
-http://jenkins.bluematt.me/pull-tester/files/
+[http://jenkins.bluematt.me/pull-tester/files/
+](http://jenkins.bluematt.me/pull-tester/files/) \ No newline at end of file
diff --git a/contrib/testgen/README b/contrib/testgen/README
deleted file mode 100644
index 02d6c4cdc2..0000000000
--- a/contrib/testgen/README
+++ /dev/null
@@ -1 +0,0 @@
-Utilities to generate test vectors for the data-driven Bitcoin tests
diff --git a/contrib/testgen/README.md b/contrib/testgen/README.md
new file mode 100644
index 0000000000..83624f443a
--- /dev/null
+++ b/contrib/testgen/README.md
@@ -0,0 +1,8 @@
+### TestGen ###
+
+Utilities to generate test vectors for the data-driven Bitcoin tests.
+
+Usage:
+
+ gen_base58_test_vectors.py valid 50 > ../../src/test/data/base58_keys_valid.json
+ gen_base58_test_vectors.py invalid 50 > ../../src/test/data/base58_keys_invalid.json \ No newline at end of file
diff --git a/contrib/verifysfbinaries/README.md b/contrib/verifysfbinaries/README.md
new file mode 100644
index 0000000000..caa4073605
--- /dev/null
+++ b/contrib/verifysfbinaries/README.md
@@ -0,0 +1,7 @@
+### Verify SF Binaries ###
+This script attempts to download the signature file `SHA256SUMS.asc` from SourceForge.
+
+It first checks if the signature passes, and then downloads the files specified in
+the file, and checks if the hashes of these files match those that are specified
+in the signature file. The script returns 0 if everything passes the checks. It returns 1 if either the
+signature check or the hash check doesn't pass. If an error occurs the return value is 2 \ No newline at end of file
diff --git a/contrib/wallettools/README.md b/contrib/wallettools/README.md
new file mode 100644
index 0000000000..3a71ba1436
--- /dev/null
+++ b/contrib/wallettools/README.md
@@ -0,0 +1,4 @@
+### Wallet Tools ###
+These are two simple python scripts which send the appropriate RPC commands to unlock a wallet and change a wallet password. **They are intended to prevent users from having to enter their password as a command-line argument which could then be stored in the console buffer/history in plaintext.**
+
+Both tools rely on bitcoin/bitcoind running with `server=1` and an `rpcuser` and `rpcpassword` set in `bitcoin.conf`. They can be easily modified for non-standard ports. [walletunlock.py](/contrib/wallettools/walletunlock.py) unlocks the wallet for 60 seconds by default, changeable in code, and both modules rely upon python-json-rpc.
diff --git a/doc/README.md b/doc/README.md
index 1238033fb7..068ed988d1 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -3,22 +3,15 @@ Bitcoin 0.8.2 BETA
Copyright (c) 2009-2013 Bitcoin Developers
+License
+---------------------
Distributed under the [MIT/X11 software license](http://www.opensource.org/licenses/mit-license.php).
This product includes software developed by the OpenSSL Project for use in the [OpenSSL Toolkit](http://www.openssl.org/). This product includes
cryptographic software written by Eric Young ([eay@cryptsoft.com](mailto:eay@cryptsoft.com)), and UPnP software written by Thomas Bernard.
-
-Intro
----------------------
-Bitcoin is a free open source peer-to-peer electronic cash system that is
-completely decentralized, without the need for a central server or trusted
-parties. Users hold the crypto keys to their own money and transact directly
-with each other, with the help of a P2P network to check for double-spending.
-
-
Setup
---------------------
-[Bitcoin-Qt](http://bitcoin.org/en/download) is the original Bitcoin client and it builds the backbone of the network. However, it downloads and stores the entire history of Bitcoin transactions; depending on the speed of your computer and network connection, the synchronization process can take anywhere from a few hours to a day or more.
+[Bitcoin-Qt](http://bitcoin.org/en/download) is the original Bitcoin client and it builds the backbone of the network. However, it downloads and stores the entire history of Bitcoin transactions (which is currently several GBs); depending on the speed of your computer and network connection, the synchronization process can take anywhere from a few hours to a day or more.
### Unix
@@ -44,17 +37,20 @@ Unpack the files into a directory and run bitcoin-qt.exe.
* See the documentation at the [Bitcoin Wiki](https://en.bitcoin.it/wiki/Main_Page)
for help and more information.
* Ask for help on [#bitcoin](http://webchat.freenode.net?channels=bitcoin) on Freenode. If you don't have an IRC client use [webchat here](http://webchat.freenode.net?channels=bitcoin).
-* Ask for help on the [BitcoinTalk](https://bitcointalk.org/) forums.
+* Ask for help on the [BitcoinTalk](https://bitcointalk.org/) forums, in the [technical support board](https://bitcointalk.org/index.php?board=4.0).
Building
---------------------
-- [Bitcoin-Qt Readme](readme-qt.md)
+The following are developer notes on how to build Bitcoin on your native platform. They are not complete guide, but include notes on the necessary libraries, compile flags, etc.
+
- [OSX Build Notes](build-osx.md)
- [Unix Build Notes](build-unix.md)
- [Windows Build Notes](build-msw.md)
Development
---------------------
+The Bitcoin repo's [root README](https://github.com/bitcoin/bitcoin/blob/master/README.md) contains relevant information on the development process and automated testing.
+
- [Coding Guidelines](coding.md)
- [Multiwallet Qt Development](multiwallet-qt.md)
- [Release Notes](release-notes.md)
@@ -67,4 +63,4 @@ Other Pages
---------------------
- [Assets Attribution](assets-attribution.md)
- [Files](files.md)
-- [Tor Support](tor.md) \ No newline at end of file
+- [Tor Support](tor.md)
diff --git a/doc/build-unix.md b/doc/build-unix.md
index 579341d2d9..422b46cc3a 100644
--- a/doc/build-unix.md
+++ b/doc/build-unix.md
@@ -21,6 +21,9 @@ Dependencies
libdb4.8 Berkeley DB Blockchain & wallet storage
libboost Boost C++ Library
miniupnpc UPnP Support Optional firewall-jumping support
+ qt GUI GUI toolkit
+ protobuf Payments in GUI Data interchange format used for payment protocol
+ libqrencode QR codes in GUI Optional for generating QR codes
[miniupnpc](http://miniupnp.free.fr/) may be used for UPnP port mapping. It can be downloaded from [here](
http://miniupnp.tuxfamily.org/files/). UPnP support is compiled in and
@@ -46,21 +49,25 @@ Licenses of statically linked libraries:
- Berkeley DB 4.8.30.NC
- Boost 1.37
- miniupnpc 1.6
+- qt 4.8.3
+- protobuf 2.5.0
+- libqrencode 3.2.0
Dependency Build Instructions: Ubuntu & Debian
----------------------------------------------
Build requirements:
sudo apt-get install build-essential
+ sudo apt-get install libtool autotools-dev
sudo apt-get install libssl-dev
-for Ubuntu 12.04:
+for Ubuntu 12.04 and later:
sudo apt-get install libboost-all-dev
db4.8 packages are available [here](https://launchpad.net/~bitcoin/+archive/bitcoin).
- Ubuntu precise has packages for libdb5.1-dev and libdb5.1++-dev,
+ 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 other Ubuntu & Debian:
@@ -74,6 +81,22 @@ Optional:
sudo apt-get install libminiupnpc-dev (see --with-miniupnpc and --enable-upnp-default)
+Dependencies for the GUI: Ubuntu & Debian
+-----------------------------------------
+
+If you want to build Bitcoin-Qt, make sure that the required packages for Qt development
+are installed. Qt 4 is currently necessary to build the GUI.
+
+To build with Qt 4 you need the following:
+
+ apt-get install libqt4-dev libprotobuf-dev
+
+libqrencode (optional) can be installed with:
+
+ apt-get install libqrencode-dev
+
+Once these are installed, they will be found by configure and a bitcoin-qt executable will be
+built by default.
Notes
-----
diff --git a/doc/multiwallet-qt.md b/doc/multiwallet-qt.md
index 8d695552b5..3caab81807 100644
--- a/doc/multiwallet-qt.md
+++ b/doc/multiwallet-qt.md
@@ -4,7 +4,7 @@ Multiwallet Qt Development and Integration Strategy
In order to support loading of multiple wallets in bitcoin-qt, a few changes in the UI architecture will be needed.
Fortunately, only four of the files in the existing project are affected by this change.
-Three new classes have been implemented in three new .h/.cpp file pairs, with much of the functionality that was previously
+Two new classes have been implemented in two new .h/.cpp file pairs, with much of the functionality that was previously
implemented in the BitcoinGUI class moved over to these new classes.
The two existing files most affected, by far, are bitcoingui.h and bitcoingui.cpp, as the BitcoinGUI class will require
@@ -12,7 +12,7 @@ some major retrofitting.
Only requiring some minor changes is bitcoin.cpp.
-Finally, three new headers and source files will have to be added to bitcoin-qt.pro.
+Finally, two new headers and source files will have to be added to bitcoin-qt.pro.
Changes to class BitcoinGUI
---------------------------
@@ -23,13 +23,9 @@ A new class called *WalletView* inheriting from QStackedWidget has been written
these page views. In addition to owning these five page views, a WalletView also has a pointer to a WalletModel instance.
This allows the construction of multiple WalletView objects, each rendering a distinct wallet.
-A second class called *WalletStack*, also inheriting from QStackedWidget, has been written to handle switching focus between
-different loaded wallets. In its current implementation, as a QStackedWidget, only one wallet can be viewed at a time -
-but this can be changed later.
-
-A third class called *WalletFrame* inheriting from QFrame has been written as a container for embedding all wallet-related
-controls into BitcoinGUI. At present it just contains a WalletStack instance and does little more than passing on messages
-from BitcoinGUI to the WalletStack, which in turn passes them to the individual WalletViews. It is a WalletFrame instance
+A second class called *WalletFrame* inheriting from QFrame has been written as a container for embedding all wallet-related
+controls into BitcoinGUI. At present it contains the WalletView instances for the wallets and does little more than passing on messages
+from BitcoinGUI to the currently selected WalletView. It is a WalletFrame instance
that takes the place of what used to be centralWidget in BitcoinGUI. The purpose of this class is to allow future
refinements of the wallet controls with minimal need for further modifications to BitcoinGUI, thus greatly simplifying
merges while reducing the risk of breaking top-level stuff.
diff --git a/doc/readme-qt.md b/doc/readme-qt.md
deleted file mode 100644
index 5aa849af10..0000000000
--- a/doc/readme-qt.md
+++ /dev/null
@@ -1,101 +0,0 @@
-Bitcoin-Qt Readme
-===============================
-Contains build and configuration instructions for Bitcoin-Qt (Qt4 GUI for Bitcoin).
-
-Build Instructions
----------------------
-
-### Debian
-
-
-First, make sure that the required packages for Qt4 development of your
-distribution are installed, these are
-
-
-
-for Debian and Ubuntu <= 11.10 :
-
-
- apt-get install qt4-qmake libqt4-dev build-essential libboost-dev libboost-system-dev \
- libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev \
- libssl-dev libdb4.8++-dev libprotobuf-dev protobuf-compiler
-
-for Ubuntu >= 12.04 (please read the 'Berkely DB version warning' below):
-
- apt-get install qt4-qmake libqt4-dev build-essential libboost-dev libboost-system-dev \
- libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev \
- libssl-dev libdb++-dev libminiupnpc-dev libprotobuf-dev protobuf-compiler
-
-For Qt 5 you need the following, otherwise you get an error with lrelease when running qmake:
-
-
- apt-get install qt5-qmake libqt5gui5 libqt5core5 libqt5dbus5 qttools5-dev-tools
-
-Once these are installed, they will be found by configure and bitcoin-qt will be
-built by default.
-
-
-### Mac OS X
-
-* Download and install the [Qt Mac OS X SDK](https://qt-project.org/downloads). It is recommended to also install Apple's Xcode with UNIX tools.
-* Download and install either [MacPorts](https://www.macports.org/) or [HomeBrew](http://mxcl.github.io/homebrew/).
-* Execute the following commands in a terminal to get the dependencies using MacPorts
-
- sudo port selfupdate
- sudo port install boost db48 miniupnpc protobuf-cpp
-
-* Execute the following commands in a terminal to get the dependencies using HomeBrew:
-
- brew update
- brew install boost miniupnpc openssl berkeley-db4 protobuf
-
-Build Configuration Options
----------------------
-
-### UPnP port forwarding
-
-UPnP support is compiled in when possible and turned off by default. See the
-configure options for upnp behavior desired:
-
- --with-miniupnpc No UPnP support miniupnp not required
- --disable-upnp-default (the default) UPnP support turned off by default at runtime
- --enable-upnp-default UPnP support turned on by default at runtime
-
-### Notification support for recent (k)ubuntu versions
-
-DBUS support is enabled by default if dependencies are met.
-
-See the --with-qtdbus configure option.
-
-### Generation of QR codes
-
-[libqrencode](http://fukuchi.org/works/qrencode/) may be used to generate QRCode images for payment requests.
-
-QR code support is enabled by default if dependencies are met.
-
-See the --with-qrencode configure option.
-
-Warnings
----------------------
-
-### Berkely DB Version Warning
-
-
-A warning for people using the *static binary* version of Bitcoin on a Linux/UNIX-ish system (tl;dr: **Berkely DB databases are not forward compatible**).
-
-The static binary version of Bitcoin is linked against libdb4.8 (see also [this Debian issue](http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=621425)).
-
-Now the nasty thing is that databases from 5.X are not compatible with 4.X.
-
-If the globally installed development package of Berkely DB installed on your system is 5.X, any source you build yourself will be linked against that. The first time you run with a 5.X version the database will be upgraded, and 4.X cannot open the new format. This means that you cannot go back to the old statically linked version without significant hassle!
-
-### Ubuntu 11.10 Warning
-
-
-Ubuntu 11.10 has a package called 'qt-at-spi' installed by default. At the time of writing, having that package installed causes bitcoin-qt to crash intermittently. The issue has been reported as [launchpad bug 857790](https://bugs.launchpad.net/ubuntu/+source/qt-at-spi/+bug/857790), but
-isn't yet fixed.
-
-Until the bug is fixed, you can remove the qt-at-spi package to work around the problem, though this will presumably disable screen reader functionality for Qt apps:
-
- sudo apt-get remove qt-at-spi
-
diff --git a/doc/tor.md b/doc/tor.md
index 6057801d34..41dd71209f 100644
--- a/doc/tor.md
+++ b/doc/tor.md
@@ -21,8 +21,8 @@ outgoing connections be anonimized, but more is possible.
-proxy=ip:port Set the proxy server. If SOCKS5 is selected (default), this proxy
server will be used to try to reach .onion addresses as well.
- -tor=ip:port Set the proxy server to use for tor hidden services. You do not
- need to set this if it's the same as -proxy. You can use -notor
+ -onion=ip:port Set the proxy server to use for tor hidden services. You do not
+ need to set this if it's the same as -proxy. You can use -noonion
to explicitly disable access to hidden service.
-listen When using -proxy, listening is disabled by default. If you want
@@ -86,5 +86,5 @@ and open port 8333 on your firewall (or use -upnp).
If you only want to use Tor to reach onion addresses, but not use it as a proxy
for normal IPv4/IPv6 communication, use:
- ./bitcoin -tor=127.0.0.1:9050 -externalip=57qr3yd1nyntf5k.onion -discover
+ ./bitcoin -onion=127.0.0.1:9050 -externalip=57qr3yd1nyntf5k.onion -discover
diff --git a/src/alert.h b/src/alert.h
index 25e140f573..e4841f9c3f 100644
--- a/src/alert.h
+++ b/src/alert.h
@@ -1,5 +1,5 @@
// Copyright (c) 2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/allocators.cpp b/src/allocators.cpp
index b239b623d8..15f34aa2c8 100644
--- a/src/allocators.cpp
+++ b/src/allocators.cpp
@@ -24,6 +24,9 @@
#include <unistd.h> // for sysconf
#endif
+LockedPageManager* LockedPageManager::_instance = NULL;
+boost::once_flag LockedPageManager::init_flag = BOOST_ONCE_INIT;
+
/** Determine system page size in bytes */
static inline size_t GetSystemPageSize()
{
diff --git a/src/allocators.h b/src/allocators.h
index fd6f51b27e..a806780ad3 100644
--- a/src/allocators.h
+++ b/src/allocators.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_ALLOCATORS_H
@@ -8,6 +8,7 @@
#include <string.h>
#include <string>
#include <boost/thread/mutex.hpp>
+#include <boost/thread/once.hpp>
#include <map>
#include <openssl/crypto.h> // for OPENSSL_cleanse()
@@ -34,6 +35,12 @@ public:
page_mask = ~(page_size - 1);
}
+ ~LockedPageManagerBase()
+ {
+ assert(this->GetLockedPageCount() == 0);
+ }
+
+
// For all pages in affected range, increase lock count
void LockRange(void *p, size_t size)
{
@@ -117,13 +124,39 @@ public:
/**
* Singleton class to keep track of locked (ie, non-swappable) memory pages, for use in
* std::allocator templates.
+ *
+ * Some implementations of the STL allocate memory in some constructors (i.e., see
+ * MSVC's vector<T> implementation where it allocates 1 byte of memory in the allocator.)
+ * Due to the unpredictable order of static initializers, we have to make sure the
+ * LockedPageManager instance exists before any other STL-based objects that use
+ * secure_allocator are created. So instead of having LockedPageManager also be
+ * static-intialized, it is created on demand.
*/
class LockedPageManager: public LockedPageManagerBase<MemoryPageLocker>
{
public:
- static LockedPageManager instance; // instantiated in util.cpp
+ static LockedPageManager& Instance()
+ {
+ boost::call_once(LockedPageManager::CreateInstance, LockedPageManager::init_flag);
+ return *LockedPageManager::_instance;
+ }
+
private:
LockedPageManager();
+
+ static void CreateInstance()
+ {
+ // Using a local static instance guarantees that the object is initialized
+ // when it's first needed and also deinitialized after all objects that use
+ // it are done with it. I can think of one unlikely scenario where we may
+ // have a static deinitialization order/problem, but the check in
+ // LockedPageManagerBase's destructor helps us detect if that ever happens.
+ static LockedPageManager instance;
+ LockedPageManager::_instance = &instance;
+ }
+
+ static LockedPageManager* _instance;
+ static boost::once_flag init_flag;
};
//
@@ -131,12 +164,12 @@ private:
// Intended for non-dynamically allocated structures.
//
template<typename T> void LockObject(const T &t) {
- LockedPageManager::instance.LockRange((void*)(&t), sizeof(T));
+ LockedPageManager::Instance().LockRange((void*)(&t), sizeof(T));
}
template<typename T> void UnlockObject(const T &t) {
OPENSSL_cleanse((void*)(&t), sizeof(T));
- LockedPageManager::instance.UnlockRange((void*)(&t), sizeof(T));
+ LockedPageManager::Instance().UnlockRange((void*)(&t), sizeof(T));
}
//
@@ -168,7 +201,7 @@ struct secure_allocator : public std::allocator<T>
T *p;
p = std::allocator<T>::allocate(n, hint);
if (p != NULL)
- LockedPageManager::instance.LockRange(p, sizeof(T) * n);
+ LockedPageManager::Instance().LockRange(p, sizeof(T) * n);
return p;
}
@@ -177,7 +210,7 @@ struct secure_allocator : public std::allocator<T>
if (p != NULL)
{
OPENSSL_cleanse(p, sizeof(T) * n);
- LockedPageManager::instance.UnlockRange(p, sizeof(T) * n);
+ LockedPageManager::Instance().UnlockRange(p, sizeof(T) * n);
}
std::allocator<T>::deallocate(p, n);
}
diff --git a/src/base58.h b/src/base58.h
index aabae8de88..44bf5281e1 100644
--- a/src/base58.h
+++ b/src/base58.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin Developers
+// Copyright (c) 2009-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.
diff --git a/src/bignum.h b/src/bignum.h
index 0881807d70..582e6f1517 100644
--- a/src/bignum.h
+++ b/src/bignum.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_BIGNUM_H
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index add3b4e1f0..1b40a868a1 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 798660dff3..29935d8f6c 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/bitcoinrpc.h b/src/bitcoinrpc.h
index 1cad12f14a..275369ddd2 100644
--- a/src/bitcoinrpc.h
+++ b/src/bitcoinrpc.h
@@ -1,5 +1,5 @@
// Copyright (c) 2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 0795f09765..82f41bcc50 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp
index bb551501f1..76ae911a5c 100644
--- a/src/checkpoints.cpp
+++ b/src/checkpoints.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/checkpoints.h b/src/checkpoints.h
index a49a908a38..4afd29326b 100644
--- a/src/checkpoints.h
+++ b/src/checkpoints.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_CHECKPOINT_H
diff --git a/src/compat.h b/src/compat.h
index b126df901a..c910f01cb4 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef _BITCOIN_COMPAT_H
diff --git a/src/core.h b/src/core.h
index ce21acd59e..9ee8b2edce 100644
--- a/src/core.h
+++ b/src/core.h
@@ -661,4 +661,38 @@ public:
void print() const;
};
+
+/** Describes a place in the block chain to another node such that if the
+ * other node doesn't have the same branch, it can find a recent common trunk.
+ * The further back it is, the further before the fork it may be.
+ */
+struct CBlockLocator
+{
+ std::vector<uint256> vHave;
+
+ CBlockLocator() {}
+
+ CBlockLocator(const std::vector<uint256>& vHaveIn)
+ {
+ vHave = vHaveIn;
+ }
+
+ IMPLEMENT_SERIALIZE
+ (
+ if (!(nType & SER_GETHASH))
+ READWRITE(nVersion);
+ READWRITE(vHave);
+ )
+
+ void SetNull()
+ {
+ vHave.clear();
+ }
+
+ bool IsNull()
+ {
+ return vHave.empty();
+ }
+};
+
#endif
diff --git a/src/crypter.cpp b/src/crypter.cpp
index 754de536a9..f3b9396dae 100644
--- a/src/crypter.cpp
+++ b/src/crypter.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2009-2012 The Bitcoin Developers
+// Copyright (c) 2009-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.
diff --git a/src/crypter.h b/src/crypter.h
index 4134c1b49b..22187791e9 100644
--- a/src/crypter.h
+++ b/src/crypter.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009-2012 The Bitcoin Developers
+// Copyright (c) 2009-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.
#ifndef __CRYPTER_H__
@@ -88,16 +88,16 @@ public:
// Try to keep the key data out of swap (and be a bit over-careful to keep the IV that we don't even use out of swap)
// Note that this does nothing about suspend-to-disk (which will put all our key data on disk)
// Note as well that at no point in this program is any attempt made to prevent stealing of keys by reading the memory of the running process.
- LockedPageManager::instance.LockRange(&chKey[0], sizeof chKey);
- LockedPageManager::instance.LockRange(&chIV[0], sizeof chIV);
+ LockedPageManager::Instance().LockRange(&chKey[0], sizeof chKey);
+ LockedPageManager::Instance().LockRange(&chIV[0], sizeof chIV);
}
~CCrypter()
{
CleanKey();
- LockedPageManager::instance.UnlockRange(&chKey[0], sizeof chKey);
- LockedPageManager::instance.UnlockRange(&chIV[0], sizeof chIV);
+ LockedPageManager::Instance().UnlockRange(&chKey[0], sizeof chKey);
+ LockedPageManager::Instance().UnlockRange(&chIV[0], sizeof chIV);
}
};
diff --git a/src/db.cpp b/src/db.cpp
index f722c52e93..7e58ff45fb 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/db.h b/src/db.h
index b3f269f3da..695e74ef2a 100644
--- a/src/db.h
+++ b/src/db.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_DB_H
@@ -16,7 +16,7 @@
#include <db_cxx.h>
class CAddrMan;
-class CBlockLocator;
+struct CBlockLocator;
class CDiskBlockIndex;
class CMasterKey;
class COutPoint;
diff --git a/src/hash.h b/src/hash.h
index 880468a2d2..ff7d57399a 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_HASH_H
diff --git a/src/init.cpp b/src/init.cpp
index dcd65198c3..2ac610b333 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
@@ -116,7 +116,7 @@ void Shutdown()
{
LOCK(cs_main);
if (pwalletMain)
- pwalletMain->SetBestChain(CBlockLocator(chainActive.Tip()));
+ pwalletMain->SetBestChain(chainActive.GetLocator());
if (pblocktree)
pblocktree->Flush();
if (pcoinsTip)
@@ -185,7 +185,7 @@ std::string HelpMessage()
strUsage += " -timeout=<n> " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n";
strUsage += " -proxy=<ip:port> " + _("Connect through socks proxy") + "\n";
strUsage += " -socks=<n> " + _("Select the version of socks proxy to use (4-5, default: 5)") + "\n";
- strUsage += " -tor=<ip:port> " + _("Use proxy to reach tor hidden services (default: same as -proxy)") + "\n";
+ strUsage += " -onion=<ip:port> " + _("Use proxy to reach tor hidden services (default: same as -proxy)") + "\n";
strUsage += " -dns " + _("Allow DNS lookups for -addnode, -seednode and -connect") + "\n";
strUsage += " -port=<port> " + _("Listen for connections on <port> (default: 8333 or testnet: 18333)") + "\n";
strUsage += " -maxconnections=<n> " + _("Maintain at most <n> connections to peers (default: 125)") + "\n";
@@ -642,15 +642,20 @@ bool AppInit2(boost::thread_group& threadGroup)
fProxy = true;
}
- // -tor can override normal proxy, -notor disables tor entirely
- if (!(mapArgs.count("-tor") && mapArgs["-tor"] == "0") && (fProxy || mapArgs.count("-tor"))) {
+ // -onion can override normal proxy, -noonion disables tor entirely
+ // -tor here is a temporary backwards compatibility measure
+ if (mapArgs.count("-tor"))
+ printf("Notice: option -tor has been replaced with -onion and will be removed in a later version.\n");
+ if (!(mapArgs.count("-onion") && mapArgs["-onion"] == "0") &&
+ !(mapArgs.count("-tor") && mapArgs["-tor"] == "0") &&
+ (fProxy || mapArgs.count("-onion") || mapArgs.count("-tor"))) {
CService addrOnion;
- if (!mapArgs.count("-tor"))
+ if (!mapArgs.count("-onion") && !mapArgs.count("-tor"))
addrOnion = addrProxy;
else
- addrOnion = CService(mapArgs["-tor"], 9050);
+ addrOnion = mapArgs.count("-onion")?CService(mapArgs["-onion"], 9050):CService(mapArgs["-tor"], 9050);
if (!addrOnion.IsValid())
- return InitError(strprintf(_("Invalid -tor address: '%s'"), mapArgs["-tor"].c_str()));
+ return InitError(strprintf(_("Invalid -onion address: '%s'"), mapArgs.count("-onion")?mapArgs["-onion"].c_str():mapArgs["-tor"].c_str()));
SetProxy(NET_TOR, addrOnion, 5);
SetReachable(NET_TOR);
}
@@ -912,7 +917,7 @@ bool AppInit2(boost::thread_group& threadGroup)
strErrors << _("Cannot write default address") << "\n";
}
- pwalletMain->SetBestChain(CBlockLocator(chainActive.Tip()));
+ pwalletMain->SetBestChain(chainActive.GetLocator());
}
LogPrintf("%s", strErrors.str().c_str());
@@ -928,7 +933,7 @@ bool AppInit2(boost::thread_group& threadGroup)
CWalletDB walletdb(strWalletFile);
CBlockLocator locator;
if (walletdb.ReadBestBlock(locator))
- pindexRescan = locator.GetBlockIndex();
+ pindexRescan = chainActive.FindFork(locator);
else
pindexRescan = chainActive.Genesis();
}
@@ -939,7 +944,7 @@ bool AppInit2(boost::thread_group& threadGroup)
nStart = GetTimeMillis();
pwalletMain->ScanForWalletTransactions(pindexRescan, true);
LogPrintf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart);
- pwalletMain->SetBestChain(CBlockLocator(chainActive.Tip()));
+ pwalletMain->SetBestChain(chainActive.GetLocator());
nWalletDBUpdated++;
}
diff --git a/src/init.h b/src/init.h
index a4d5a67252..e5a2a69293 100644
--- a/src/init.h
+++ b/src/init.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_INIT_H
diff --git a/src/key.cpp b/src/key.cpp
index 8ef1c414c4..996539dca5 100644
--- a/src/key.cpp
+++ b/src/key.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
@@ -166,9 +166,12 @@ public:
assert(nSize == nSize2);
}
- bool SetPrivKey(const CPrivKey &privkey) {
+ bool SetPrivKey(const CPrivKey &privkey, bool fSkipCheck=false) {
const unsigned char* pbegin = &privkey[0];
if (d2i_ECPrivateKey(&pkey, &pbegin, privkey.size())) {
+ if(fSkipCheck)
+ return true;
+
// d2i_ECPrivateKey returns true if parsing succeeds.
// This doesn't necessarily mean the key is valid.
if (EC_KEY_check_key(pkey))
@@ -411,6 +414,24 @@ bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig)
return true;
}
+bool CKey::Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck=false) {
+ CECKey key;
+ if (!key.SetPrivKey(privkey, fSkipCheck))
+ return false;
+
+ key.GetSecretBytes(vch);
+ fCompressed = vchPubKey.IsCompressed();
+ fValid = true;
+
+ if (fSkipCheck)
+ return true;
+
+ if (GetPubKey() != vchPubKey)
+ return false;
+
+ return true;
+}
+
bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig) const {
if (!IsValid())
return false;
diff --git a/src/key.h b/src/key.h
index 75431e944f..ac050356f2 100644
--- a/src/key.h
+++ b/src/key.h
@@ -261,6 +261,9 @@ public:
// Derive BIP32 child key.
bool Derive(CKey& keyChild, unsigned char ccChild[32], unsigned int nChild, const unsigned char cc[32]) const;
+
+ // Load private key and check that public key matches.
+ bool Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck);
};
struct CExtPubKey {
diff --git a/src/keystore.cpp b/src/keystore.cpp
index 808f8c24ef..301180737f 100644
--- a/src/keystore.cpp
+++ b/src/keystore.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/keystore.h b/src/keystore.h
index 49a7bf569d..4f28fba91b 100644
--- a/src/keystore.h
+++ b/src/keystore.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_KEYSTORE_H
diff --git a/src/main.cpp b/src/main.cpp
index f2e6b67f8a..a5a0f031af 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
@@ -190,105 +190,61 @@ void UnregisterNodeSignals(CNodeSignals& nodeSignals)
//////////////////////////////////////////////////////////////////////////////
//
-// CBlockLocator implementation
+// CChain implementation
//
-CBlockLocator::CBlockLocator(uint256 hashBlock)
-{
- std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock);
- if (mi != mapBlockIndex.end())
- Set((*mi).second);
+CBlockIndex *CChain::SetTip(CBlockIndex *pindex) {
+ if (pindex == NULL) {
+ vChain.clear();
+ return NULL;
+ }
+ vChain.resize(pindex->nHeight + 1);
+ while (pindex && vChain[pindex->nHeight] != pindex) {
+ vChain[pindex->nHeight] = pindex;
+ pindex = pindex->pprev;
+ }
+ return pindex;
}
-void CBlockLocator::Set(const CBlockIndex* pindex)
-{
- vHave.clear();
+CBlockLocator CChain::GetLocator(const CBlockIndex *pindex) const {
int nStep = 1;
- while (pindex)
- {
- vHave.push_back(pindex->GetBlockHash());
+ std::vector<uint256> vHave;
+ vHave.reserve(32);
- // Exponentially larger steps back
- for (int i = 0; pindex && i < nStep; i++)
+ if (!pindex)
+ pindex = Tip();
+ while (pindex) {
+ vHave.push_back(pindex->GetBlockHash());
+ // Stop when we have added the genesis block.
+ if (pindex->nHeight == 0)
+ break;
+ // Exponentially larger steps back, plus the genesis block.
+ int nHeight = std::max(pindex->nHeight - nStep, 0);
+ // In case pindex is not in this chain, iterate pindex->pprev to find blocks.
+ while (pindex->nHeight > nHeight && !Contains(pindex))
pindex = pindex->pprev;
+ // If pindex is in this chain, use direct height-based access.
+ if (pindex->nHeight > nHeight)
+ pindex = (*this)[nHeight];
if (vHave.size() > 10)
nStep *= 2;
}
- vHave.push_back(Params().HashGenesisBlock());
-}
-int CBlockLocator::GetDistanceBack()
-{
- // Retrace how far back it was in the sender's branch
- int nDistance = 0;
- int nStep = 1;
- BOOST_FOREACH(const uint256& hash, vHave)
- {
- std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);
- if (mi != mapBlockIndex.end())
- {
- CBlockIndex* pindex = (*mi).second;
- if (chainActive.Contains(pindex))
- return nDistance;
- }
- nDistance += nStep;
- if (nDistance > 10)
- nStep *= 2;
- }
- return nDistance;
+ return CBlockLocator(vHave);
}
-CBlockIndex *CBlockLocator::GetBlockIndex()
-{
+CBlockIndex *CChain::FindFork(const CBlockLocator &locator) const {
// Find the first block the caller has in the main chain
- BOOST_FOREACH(const uint256& hash, vHave)
- {
+ BOOST_FOREACH(const uint256& hash, locator.vHave) {
std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end())
{
CBlockIndex* pindex = (*mi).second;
- if (chainActive.Contains(pindex))
+ if (Contains(pindex))
return pindex;
}
}
- return chainActive.Genesis();
-}
-
-uint256 CBlockLocator::GetBlockHash()
-{
- // Find the first block the caller has in the main chain
- BOOST_FOREACH(const uint256& hash, vHave)
- {
- std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);
- if (mi != mapBlockIndex.end())
- {
- CBlockIndex* pindex = (*mi).second;
- if (chainActive.Contains(pindex))
- return hash;
- }
- }
- return Params().HashGenesisBlock();
-}
-
-int CBlockLocator::GetHeight()
-{
- CBlockIndex* pindex = GetBlockIndex();
- if (!pindex)
- return 0;
- return pindex->nHeight;
-}
-
-CBlockIndex *CChain::SetTip(CBlockIndex *pindex) {
- if (pindex == NULL) {
- std::vector<CBlockIndex*>().swap(vChain);
- return NULL;
- }
- vChain.resize(pindex->nHeight + 1);
- while (pindex && vChain[pindex->nHeight] != pindex) {
- vChain[pindex->nHeight] = pindex;
- pindex = pindex->pprev;
- }
- return pindex;
+ return Genesis();
}
//////////////////////////////////////////////////////////////////////////////
@@ -766,15 +722,18 @@ int64 GetMinFee(const CTransaction& tx, bool fAllowFree, enum GetMinFee_mode mod
{
// There is a free transaction area in blocks created by most miners,
// * If we are relaying we allow transactions up to DEFAULT_BLOCK_PRIORITY_SIZE - 1000
- // to be considered to fall into this category
- // * If we are creating a transaction we allow transactions up to DEFAULT_BLOCK_PRIORITY_SIZE - 17000
- // (= 10000) to be considered safe and assume they can likely make it into this section
- if (nBytes < (mode == GMF_SEND ? (DEFAULT_BLOCK_PRIORITY_SIZE - 17000) : (DEFAULT_BLOCK_PRIORITY_SIZE - 1000)))
+ // to be considered to fall into this category. We don't want to encourage sending
+ // multiple transactions instead of one big transaction to avoid fees.
+ // * If we are creating a transaction we allow transactions up to 1,000 bytes
+ // to be considered safe and assume they can likely make it into this section.
+ if (nBytes < (mode == GMF_SEND ? 1000 : (DEFAULT_BLOCK_PRIORITY_SIZE - 1000)))
nMinFee = 0;
}
- // To limit dust spam, require base fee if any output is less than 0.01
- if (nMinFee < nBaseFee)
+ // This code can be removed after enough miners have upgraded to version 0.9.
+ // Until then, be safe when sending and require a fee if any output
+ // is less than CENT:
+ if (nMinFee < nBaseFee && mode == GMF_SEND)
{
BOOST_FOREACH(const CTxOut& txout, tx.vout)
if (txout.nValue < CENT)
@@ -2156,10 +2115,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
// Update best block in wallet (so we can detect restored wallets)
if ((pindexNew->nHeight % 20160) == 0 || (!fIsInitialDownload && (pindexNew->nHeight % 144) == 0))
- {
- const CBlockLocator locator(pindexNew);
- ::SetBestChain(locator);
- }
+ ::SetBestChain(chainActive.GetLocator(pindexNew));
// New best block
nTimeBestReceived = GetTime();
@@ -2525,7 +2481,7 @@ void PushGetBlocks(CNode* pnode, CBlockIndex* pindexBegin, uint256 hashEnd)
pnode->pindexLastGetBlocksBegin = pindexBegin;
pnode->hashLastGetBlocksEnd = hashEnd;
- pnode->PushMessage("getblocks", CBlockLocator(pindexBegin), hashEnd);
+ pnode->PushMessage("getblocks", chainActive.GetLocator(pindexBegin), hashEnd);
}
bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBlockPos *dbp)
@@ -3661,7 +3617,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
LOCK(cs_main);
// Find the last block the caller has in the main chain
- CBlockIndex* pindex = locator.GetBlockIndex();
+ CBlockIndex* pindex = chainActive.FindFork(locator);
// Send the rest of the chain
if (pindex)
@@ -3708,7 +3664,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
else
{
// Find the last block the caller has in the main chain
- pindex = locator.GetBlockIndex();
+ pindex = chainActive.FindFork(locator);
if (pindex)
pindex = chainActive.Next(pindex);
}
@@ -3731,7 +3687,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
{
vector<uint256> vWorkQueue;
vector<uint256> vEraseQueue;
- CDataStream vMsg(vRecv);
CTransaction tx;
vRecv >> tx;
diff --git a/src/main.h b/src/main.h
index 46d629044a..76de47071e 100644
--- a/src/main.h
+++ b/src/main.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_MAIN_H
@@ -1033,6 +1033,12 @@ public:
/** Set/initialize a chain with a given tip. Returns the forking point. */
CBlockIndex *SetTip(CBlockIndex *pindex);
+
+ /** Return a CBlockLocator that refers to a block in this chain (by default the tip). */
+ CBlockLocator GetLocator(const CBlockIndex *pindex = NULL) const;
+
+ /** Find the last common block between this chain and a locator. */
+ CBlockIndex *FindFork(const CBlockLocator &locator) const;
};
/** The currently-connected chain of blocks. */
@@ -1040,59 +1046,6 @@ extern CChain chainActive;
-/** Describes a place in the block chain to another node such that if the
- * other node doesn't have the same branch, it can find a recent common trunk.
- * The further back it is, the further before the fork it may be.
- */
-class CBlockLocator
-{
-protected:
- std::vector<uint256> vHave;
-public:
- CBlockLocator() {}
-
- explicit CBlockLocator(const CBlockIndex* pindex)
- {
- Set(pindex);
- }
-
- explicit CBlockLocator(uint256 hashBlock);
-
- CBlockLocator(const std::vector<uint256>& vHaveIn)
- {
- vHave = vHaveIn;
- }
-
- IMPLEMENT_SERIALIZE
- (
- if (!(nType & SER_GETHASH))
- READWRITE(nVersion);
- READWRITE(vHave);
- )
-
- void SetNull()
- {
- vHave.clear();
- }
-
- bool IsNull()
- {
- return vHave.empty();
- }
-
- /** Given a block initialises the locator to that point in the chain. */
- void Set(const CBlockIndex* pindex);
- /** Returns the distance in blocks this locator is from our chain head. */
- int GetDistanceBack();
- /** Returns the first best-chain block the locator contains. */
- CBlockIndex* GetBlockIndex();
- /** Returns the hash of the first best chain block the locator contains. */
- uint256 GetBlockHash();
- /** Returns the height of the first best chain block the locator has. */
- int GetHeight();
-};
-
-
diff --git a/src/miner.cpp b/src/miner.cpp
index e9c1d9aff9..dca8609e17 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
@@ -238,9 +238,21 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
}
if (fMissingInputs) continue;
- // Priority is sum(valuein * age) / txsize
+ // Priority is sum(valuein * age) / modified_txsize
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
- dPriority /= nTxSize;
+ unsigned int nTxSizeMod = nTxSize;
+ // In order to avoid disincentivizing cleaning up the UTXO set we don't count
+ // the constant overhead for each txin and up to 110 bytes of scriptSig (which
+ // is enough to cover a compressed pubkey p2sh redemption) for priority.
+ // Providing any more cleanup incentive than making additional inputs free would
+ // risk encouraging people to create junk outputs to redeem later.
+ BOOST_FOREACH(const CTxIn& txin, tx.vin)
+ {
+ unsigned int offset = 41U + min(110U, (unsigned int)txin.scriptSig.size());
+ if (nTxSizeMod > offset)
+ nTxSizeMod -= offset;
+ }
+ dPriority /= nTxSizeMod;
// This is a more accurate fee-per-kilobyte than is used by the client code, because the
// client code rounds up the size to the nearest 1K. That's good, because it gives an
diff --git a/src/miner.h b/src/miner.h
index 7e60b9e53b..a2800341d8 100644
--- a/src/miner.h
+++ b/src/miner.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_MINER_H
diff --git a/src/net.cpp b/src/net.cpp
index e8baa8b383..dd7bf283a9 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/net.h b/src/net.h
index 9b76d1643d..2c2d3a768a 100644
--- a/src/net.h
+++ b/src/net.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_NET_H
diff --git a/src/netbase.cpp b/src/netbase.cpp
index 360ecdd959..36b90e0d4c 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/netbase.h b/src/netbase.h
index e1f80b4ee8..c14fa5075d 100644
--- a/src/netbase.h
+++ b/src/netbase.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_NETBASE_H
diff --git a/src/noui.cpp b/src/noui.cpp
index 67eac944c6..06c507d0e5 100644
--- a/src/noui.cpp
+++ b/src/noui.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/protocol.cpp b/src/protocol.cpp
index ba254be3e1..a841bbc14e 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/protocol.h b/src/protocol.h
index ae541dfdba..3d8eae55f9 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/qt/Makefile.am b/src/qt/Makefile.am
index e7ae0a905f..5892f6aca0 100644
--- a/src/qt/Makefile.am
+++ b/src/qt/Makefile.am
@@ -51,7 +51,7 @@ QT_MOC_CPP = moc_aboutdialog.cpp moc_addressbookpage.cpp \
moc_signverifymessagedialog.cpp moc_splashscreen.cpp moc_trafficgraphwidget.cpp moc_transactiondesc.cpp \
moc_transactiondescdialog.cpp moc_transactionfilterproxy.cpp \
moc_transactiontablemodel.cpp moc_transactionview.cpp moc_walletframe.cpp \
- moc_walletmodel.cpp moc_walletstack.cpp moc_walletview.cpp
+ moc_walletmodel.cpp moc_walletview.cpp
BITCOIN_MM = macdockiconhandler.mm macnotificationhandler.mm
QR_CPP = qrcodedialog.cpp
@@ -75,7 +75,7 @@ BITCOIN_QT_H = aboutdialog.h addressbookpage.h addresstablemodel.h \
sendcoinsdialog.h sendcoinsentry.h signverifymessagedialog.h splashscreen.h \
trafficgraphwidget.h transactiondescdialog.h transactiondesc.h transactionfilterproxy.h \
transactionrecord.h transactiontablemodel.h transactionview.h walletframe.h \
- walletmodel.h walletmodeltransaction.h walletstack.h walletview.h
+ walletmodel.h walletmodeltransaction.h walletview.h
RES_ICONS = res/icons/bitcoin.png res/icons/address-book.png \
res/icons/quit.png res/icons/send.png res/icons/toolbar.png \
@@ -105,7 +105,7 @@ BITCOIN_QT_CPP = aboutdialog.cpp addressbookpage.cpp \
signverifymessagedialog.cpp splashscreen.cpp trafficgraphwidget.cpp transactiondesc.cpp \
transactiondescdialog.cpp transactionfilterproxy.cpp transactionrecord.cpp \
transactiontablemodel.cpp transactionview.cpp walletframe.cpp \
- walletmodel.cpp walletmodeltransaction.cpp walletstack.cpp walletview.cpp
+ walletmodel.cpp walletmodeltransaction.cpp walletview.cpp
RES_IMAGES = res/images/about.png res/images/splash.png \
res/images/splash_testnet.png
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 78693971da..e73a82978a 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -333,8 +333,8 @@ int main(int argc, char *argv[])
paymentServer, SLOT(fetchPaymentACK(CWallet*,const SendCoinsRecipient&,QByteArray)));
QObject::connect(paymentServer, SIGNAL(receivedPaymentACK(QString)),
&window, SLOT(showPaymentACK(QString)));
- QObject::connect(paymentServer, SIGNAL(reportError(QString, QString, unsigned int)),
- guiref, SLOT(message(QString, QString, unsigned int)));
+ QObject::connect(paymentServer, SIGNAL(message(QString,QString,unsigned int)),
+ guiref, SLOT(message(QString,QString,unsigned int)));
QTimer::singleShot(100, paymentServer, SLOT(uiReady()));
app.exec();
diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp
index d9d4e3b23d..37b8743eff 100644
--- a/src/qt/bitcoinamountfield.cpp
+++ b/src/qt/bitcoinamountfield.cpp
@@ -130,9 +130,10 @@ void BitcoinAmountField::setValue(qint64 value)
setText(BitcoinUnits::format(currentUnit, value));
}
-void BitcoinAmountField::setReadOnly(bool fReadeOnly)
+void BitcoinAmountField::setReadOnly(bool fReadOnly)
{
- // TODO ...
+ amount->setReadOnly(fReadOnly);
+ unit->setEnabled(!fReadOnly);
}
void BitcoinAmountField::unitChanged(int idx)
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 23a221120f..3336a8afd3 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -447,26 +447,31 @@ void BitcoinGUI::aboutClicked()
void BitcoinGUI::gotoOverviewPage()
{
+ overviewAction->setChecked(true);
if (walletFrame) walletFrame->gotoOverviewPage();
}
void BitcoinGUI::gotoHistoryPage()
{
+ historyAction->setChecked(true);
if (walletFrame) walletFrame->gotoHistoryPage();
}
void BitcoinGUI::gotoAddressBookPage()
{
+ addressBookAction->setChecked(true);
if (walletFrame) walletFrame->gotoAddressBookPage();
}
void BitcoinGUI::gotoReceiveCoinsPage()
{
+ receiveCoinsAction->setChecked(true);
if (walletFrame) walletFrame->gotoReceiveCoinsPage();
}
void BitcoinGUI::gotoSendCoinsPage(QString addr)
{
+ sendCoinsAction->setChecked(true);
if (walletFrame) walletFrame->gotoSendCoinsPage(addr);
}
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index e2dd5dc6bc..e5a92fed93 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -61,14 +61,6 @@ public:
void removeAllWallets();
- /** Used by WalletView to allow access to needed QActions */
- // Todo: Use Qt signals for these
- QAction * getOverviewAction() { return overviewAction; }
- QAction * getHistoryAction() { return historyAction; }
- QAction * getAddressBookAction() { return addressBookAction; }
- QAction * getReceiveCoinsAction() { return receiveCoinsAction; }
- QAction * getSendCoinsAction() { return sendCoinsAction; }
-
protected:
void changeEvent(QEvent *e);
void closeEvent(QCloseEvent *event);
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index 2bab488135..212fa6974a 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -65,10 +65,8 @@ QDateTime ClientModel::getLastBlockDate() const
{
if (chainActive.Tip())
return QDateTime::fromTime_t(chainActive.Tip()->GetBlockTime());
- else if(!isTestNet())
- return QDateTime::fromTime_t(1231006505); // Genesis block's time
else
- return QDateTime::fromTime_t(1296688602); // Genesis block's time (testnet)
+ return QDateTime::fromTime_t(Params().GenesisBlock().nTime); // Genesis block's time of current network
}
double ClientModel::getVerificationProgress() const
diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui
index 2c1cec600c..5c6afd6c71 100644
--- a/src/qt/forms/sendcoinsentry.ui
+++ b/src/qt/forms/sendcoinsentry.ui
@@ -621,7 +621,7 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
- <cstring>payAmount</cstring>
+ <cstring>payAmount_s</cstring>
</property>
</widget>
</item>
@@ -640,15 +640,9 @@
</item>
<item row="5" column="2">
<widget class="BitcoinAmountField" name="payAmount_s">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="acceptDrops">
<bool>false</bool>
</property>
- <property name="readOnly">
- <bool>true</bool>
- </property>
</widget>
</item>
<item row="3" column="2">
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp
index 96ba997943..af75d6b4e5 100644
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
@@ -189,7 +189,7 @@ bool PaymentServer::ipcSendCommandLine(int argc, char* argv[])
if (arg.startsWith("-"))
continue;
- if (arg.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // bitcoin:
+ if (arg.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // bitcoin: URI
{
savedPaymentRequests.append(arg);
@@ -220,9 +220,9 @@ bool PaymentServer::ipcSendCommandLine(int argc, char* argv[])
}
else
{
- qDebug() << "PaymentServer::ipcSendCommandLine : Payment request file does not exist: " << argv[i];
// Printing to debug.log is about the best we can do here, the
// GUI hasn't started yet so we can't pop up a message box.
+ qDebug() << "PaymentServer::ipcSendCommandLine : Payment request file does not exist: " << arg;
}
}
@@ -246,6 +246,7 @@ bool PaymentServer::ipcSendCommandLine(int argc, char* argv[])
delete socket;
fResult = true;
}
+
return fResult;
}
@@ -255,7 +256,9 @@ PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) : QObject(p
// compatible with the version of the headers we compiled against.
GOOGLE_PROTOBUF_VERIFY_VERSION;
- // Install global event filter to catch QFileOpenEvents on the mac (sent when you click bitcoin: links)
+ // Install global event filter to catch QFileOpenEvents
+ // on Mac: sent when you click bitcoin: links
+ // other OSes: helpful when dealing with payment-request files (in the future)
if (parent)
parent->installEventFilter(this);
@@ -310,7 +313,7 @@ void PaymentServer::initNetManager()
if (netManager != NULL)
delete netManager;
- // netManager is used to fetch paymentrequests given in bitcoin: URI's
+ // netManager is used to fetch paymentrequests given in bitcoin: URIs
netManager = new QNetworkAccessManager(this);
// Use proxy settings from optionsModel:
@@ -360,7 +363,8 @@ void PaymentServer::handleURIOrFile(const QString& s)
#endif
if (uri.hasQueryItem("request"))
{
- QByteArray temp; temp.append(uri.queryItemValue("request"));
+ QByteArray temp;
+ temp.append(uri.queryItemValue("request"));
QString decoded = QUrl::fromPercentEncoding(temp);
QUrl fetchUrl(decoded, QUrl::StrictMode);
@@ -370,13 +374,17 @@ void PaymentServer::handleURIOrFile(const QString& s)
if (fetchUrl.isValid())
fetchRequest(fetchUrl);
else
- qDebug() << "PaymentServer::handleURIOrFile : Invalid url: " << fetchUrl;
+ qDebug() << "PaymentServer::handleURIOrFile : Invalid URL: " << fetchUrl;
return;
}
SendCoinsRecipient recipient;
if (GUIUtil::parseBitcoinURI(s, &recipient))
emit receivedPaymentRequest(recipient);
+ else
+ emit message(tr("URI handling"),
+ tr("URI can not be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."),
+ CClientUIInterface::ICON_WARNING);
return;
}
@@ -408,10 +416,10 @@ void PaymentServer::handleURIConnection()
if (clientConnection->bytesAvailable() < (int)sizeof(quint16)) {
return;
}
- QString message;
- in >> message;
+ QString msg;
+ in >> msg;
- handleURIOrFile(message);
+ handleURIOrFile(msg);
}
bool PaymentServer::readPaymentRequest(const QString& filename, PaymentRequestPlus& request)
@@ -444,11 +452,11 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList<Sen
foreach(const PAIRTYPE(CScript, qint64)& sendingTo, sendingTos) {
CTxOut txOut(sendingTo.second, sendingTo.first);
if (txOut.IsDust(CTransaction::nMinRelayTxFee)) {
- QString message = QObject::tr("Requested payment amount (%1) too small")
+ QString msg = QObject::tr("Requested payment amount (%1) too small")
.arg(BitcoinUnits::formatWithUnit(optionsModel->getDisplayUnit(), sendingTo.second));
- qDebug() << "PaymentServer::processPaymentRequest : " << message;
- emit reportError(tr("Payment request error"), message, CClientUIInterface::MODAL);
+ qDebug() << "PaymentServer::processPaymentRequest : " << msg;
+ emit message(tr("Payment request error"), msg, CClientUIInterface::MSG_ERROR);
return false;
}
@@ -485,9 +493,9 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, QList<Sen
// Insecure payments to custom bitcoin addresses are not supported
// (there is no good way to tell the user where they are paying in a way
// they'd have a chance of understanding).
- emit reportError(tr("Payment request error"),
- tr("Insecure requests to custom payment scripts unsupported"),
- CClientUIInterface::MODAL);
+ emit message(tr("Payment request error"),
+ tr("Insecure requests to custom payment scripts unsupported"),
+ CClientUIInterface::MSG_ERROR);
return false;
}
}
@@ -566,11 +574,11 @@ void PaymentServer::netRequestFinished(QNetworkReply* reply)
reply->deleteLater();
if (reply->error() != QNetworkReply::NoError)
{
- QString message = QObject::tr("Error communicating with %1: %2")
+ QString msg = QObject::tr("Error communicating with %1: %2")
.arg(reply->request().url().toString())
.arg(reply->errorString());
- qDebug() << "PaymentServer::netRequestFinished : " << message;
- emit reportError(tr("Network request error"), message, CClientUIInterface::MODAL);
+ qDebug() << "PaymentServer::netRequestFinished : " << msg;
+ emit message(tr("Network request error"), msg, CClientUIInterface::MSG_ERROR);
return;
}
@@ -595,10 +603,10 @@ void PaymentServer::netRequestFinished(QNetworkReply* reply)
payments::PaymentACK paymentACK;
if (!paymentACK.ParseFromArray(data.data(), data.size()))
{
- QString message = QObject::tr("Bad response from server %1")
+ QString msg = QObject::tr("Bad response from server %1")
.arg(reply->request().url().toString());
- qDebug() << "PaymentServer::netRequestFinished : " << message;
- emit reportError(tr("Network request error"), message, CClientUIInterface::MODAL);
+ qDebug() << "PaymentServer::netRequestFinished : " << msg;
+ emit message(tr("Network request error"), msg, CClientUIInterface::MSG_ERROR);
}
else {
emit receivedPaymentACK(QString::fromStdString(paymentACK.memo()));
@@ -615,7 +623,7 @@ void PaymentServer::reportSslErrors(QNetworkReply* reply, const QList<QSslError>
qDebug() << "PaymentServer::reportSslErrors : " << err;
errString += err.errorString() + "\n";
}
- emit reportError(tr("Network request error"), errString, CClientUIInterface::MODAL);
+ emit message(tr("Network request error"), errString, CClientUIInterface::MSG_ERROR);
}
void PaymentServer::setOptionsModel(OptionsModel *optionsModel)
diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h
index f9d827204b..042c41ef64 100644
--- a/src/qt/paymentserver.h
+++ b/src/qt/paymentserver.h
@@ -90,8 +90,8 @@ signals:
// Fired when a valid PaymentACK is received
void receivedPaymentACK(QString);
- // Fired when an error should be reported to the user
- void reportError(QString, QString, unsigned int);
+ // Fired when a message should be reported to the user
+ void message(const QString &title, const QString &message, unsigned int style);
public slots:
// Signal this when the main window's UI is ready
diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp
index 59724c94f4..188b8860a9 100644
--- a/src/qt/sendcoinsentry.cpp
+++ b/src/qt/sendcoinsentry.cpp
@@ -60,12 +60,7 @@ void SendCoinsEntry::on_addressBookButton_clicked()
void SendCoinsEntry::on_payTo_textChanged(const QString &address)
{
- if(!model)
- return;
- // Fill in label from address book, if address has an associated label
- QString associatedLabel = model->getAddressTableModel()->labelForAddress(address);
- if(!associatedLabel.isEmpty())
- ui->addAsLabel->setText(associatedLabel);
+ updateLabel(address);
}
void SendCoinsEntry::setModel(WalletModel *model)
@@ -174,6 +169,7 @@ void SendCoinsEntry::setValue(const SendCoinsRecipient &value)
ui->payTo_s->setText(recipient.authenticatedMerchant);
ui->memoTextLabel_s->setText(QString::fromStdString(details.memo()));
ui->payAmount_s->setValue(recipient.amount);
+ ui->payAmount_s->setReadOnly(true);
setCurrentWidget(ui->SendCoinsSecure);
}
}
@@ -203,3 +199,19 @@ void SendCoinsEntry::updateDisplayUnit()
ui->payAmount_s->setDisplayUnit(model->getOptionsModel()->getDisplayUnit());
}
}
+
+bool SendCoinsEntry::updateLabel(const QString &address)
+{
+ if(!model)
+ return false;
+
+ // Fill in label from address book, if address has an associated label
+ QString associatedLabel = model->getAddressTableModel()->labelForAddress(address);
+ if(!associatedLabel.isEmpty())
+ {
+ ui->addAsLabel->setText(associatedLabel);
+ return true;
+ }
+
+ return false;
+}
diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h
index 49e622daf1..66d9752909 100644
--- a/src/qt/sendcoinsentry.h
+++ b/src/qt/sendcoinsentry.h
@@ -58,6 +58,8 @@ private:
SendCoinsRecipient recipient;
Ui::SendCoinsEntry *ui;
WalletModel *model;
+
+ bool updateLabel(const QString &address);
};
#endif // SENDCOINSENTRY_H
diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp
index 8d6a1b387e..f754bd5e71 100644
--- a/src/qt/walletframe.cpp
+++ b/src/qt/walletframe.cpp
@@ -5,20 +5,21 @@
* The Bitcoin Developers 2011-2013
*/
#include "walletframe.h"
+#include "walletview.h"
#include "bitcoingui.h"
-#include "walletstack.h"
#include <QHBoxLayout>
#include <QMessageBox>
+#include <QStackedWidget>
WalletFrame::WalletFrame(BitcoinGUI *_gui) :
- QFrame(_gui)
+ QFrame(_gui),
+ gui(_gui)
{
// Leave HBox hook for adding a list view later
QHBoxLayout *walletFrameLayout = new QHBoxLayout(this);
setContentsMargins(0,0,0,0);
- walletStack = new WalletStack(this);
- walletStack->setBitcoinGUI(_gui);
+ walletStack = new QStackedWidget(this);
walletFrameLayout->setContentsMargins(0,0,0,0);
walletFrameLayout->addWidget(walletStack);
}
@@ -29,95 +30,157 @@ WalletFrame::~WalletFrame()
void WalletFrame::setClientModel(ClientModel *clientModel)
{
- if (clientModel)
- walletStack->setClientModel(clientModel);
+ this->clientModel = clientModel;
}
bool WalletFrame::addWallet(const QString& name, WalletModel *walletModel)
{
- return walletStack->addWallet(name, walletModel);
+ if (!gui || !clientModel || !walletModel || mapWalletViews.count(name) > 0)
+ return false;
+
+ WalletView *walletView = new WalletView(this);
+ walletView->setBitcoinGUI(gui);
+ walletView->setClientModel(clientModel);
+ walletView->setWalletModel(walletModel);
+ walletView->showOutOfSyncWarning(bOutOfSync);
+
+ /* TODO we should goto the currently selected page once dynamically adding wallets is supported */
+ walletView->gotoOverviewPage();
+ walletStack->addWidget(walletView);
+ mapWalletViews[name] = walletView;
+
+ // Ensure a walletView is able to show the main window
+ connect(walletView, SIGNAL(showNormalIfMinimized()), gui, SLOT(showNormalIfMinimized()));
+
+ return true;
}
bool WalletFrame::setCurrentWallet(const QString& name)
{
- // TODO: Check if valid name
- return walletStack->setCurrentWallet(name);
+ if (mapWalletViews.count(name) == 0)
+ return false;
+
+ WalletView *walletView = mapWalletViews.value(name);
+ walletStack->setCurrentWidget(walletView);
+ walletView->setEncryptionStatus();
+ return true;
+}
+
+bool WalletFrame::removeWallet(const QString &name)
+{
+ if (mapWalletViews.count(name) == 0)
+ return false;
+
+ WalletView *walletView = mapWalletViews.take(name);
+ walletStack->removeWidget(walletView);
+ return true;
}
void WalletFrame::removeAllWallets()
{
- walletStack->removeAllWallets();
+ QMap<QString, WalletView*>::const_iterator i;
+ for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
+ walletStack->removeWidget(i.value());
+ mapWalletViews.clear();
}
bool WalletFrame::handlePaymentRequest(const SendCoinsRecipient &recipient)
{
- return walletStack->handlePaymentRequest(recipient);
+ WalletView *walletView = (WalletView*)walletStack->currentWidget();
+ if (!walletView)
+ return false;
+
+ return walletView->handlePaymentRequest(recipient);
}
void WalletFrame::showOutOfSyncWarning(bool fShow)
{
- if (!walletStack)
- return;
-
- walletStack->showOutOfSyncWarning(fShow);
+ bOutOfSync = fShow;
+ QMap<QString, WalletView*>::const_iterator i;
+ for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
+ i.value()->showOutOfSyncWarning(fShow);
}
void WalletFrame::gotoOverviewPage()
{
- walletStack->gotoOverviewPage();
+ QMap<QString, WalletView*>::const_iterator i;
+ for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
+ i.value()->gotoOverviewPage();
}
void WalletFrame::gotoHistoryPage()
{
- walletStack->gotoHistoryPage();
+ QMap<QString, WalletView*>::const_iterator i;
+ for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
+ i.value()->gotoHistoryPage();
}
void WalletFrame::gotoAddressBookPage()
{
- walletStack->gotoAddressBookPage();
+ QMap<QString, WalletView*>::const_iterator i;
+ for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
+ i.value()->gotoAddressBookPage();
}
void WalletFrame::gotoReceiveCoinsPage()
{
- walletStack->gotoReceiveCoinsPage();
+ QMap<QString, WalletView*>::const_iterator i;
+ for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
+ i.value()->gotoReceiveCoinsPage();
}
void WalletFrame::gotoSendCoinsPage(QString addr)
{
- walletStack->gotoSendCoinsPage(addr);
+ QMap<QString, WalletView*>::const_iterator i;
+ for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
+ i.value()->gotoSendCoinsPage(addr);
}
void WalletFrame::gotoSignMessageTab(QString addr)
{
- walletStack->gotoSignMessageTab(addr);
+ WalletView *walletView = (WalletView*)walletStack->currentWidget();
+ if (walletView)
+ walletView->gotoSignMessageTab(addr);
}
void WalletFrame::gotoVerifyMessageTab(QString addr)
{
- walletStack->gotoSignMessageTab(addr);
+ WalletView *walletView = (WalletView*)walletStack->currentWidget();
+ if (walletView)
+ walletView->gotoVerifyMessageTab(addr);
}
void WalletFrame::encryptWallet(bool status)
{
- walletStack->encryptWallet(status);
+ WalletView *walletView = (WalletView*)walletStack->currentWidget();
+ if (walletView)
+ walletView->encryptWallet(status);
}
void WalletFrame::backupWallet()
{
- walletStack->backupWallet();
+ WalletView *walletView = (WalletView*)walletStack->currentWidget();
+ if (walletView)
+ walletView->backupWallet();
}
void WalletFrame::changePassphrase()
{
- walletStack->changePassphrase();
+ WalletView *walletView = (WalletView*)walletStack->currentWidget();
+ if (walletView)
+ walletView->changePassphrase();
}
void WalletFrame::unlockWallet()
{
- walletStack->unlockWallet();
+ WalletView *walletView = (WalletView*)walletStack->currentWidget();
+ if (walletView)
+ walletView->unlockWallet();
}
void WalletFrame::setEncryptionStatus()
{
- walletStack->setEncryptionStatus();
+ WalletView *walletView = (WalletView*)walletStack->currentWidget();
+ if (walletView)
+ walletView->setEncryptionStatus();
}
diff --git a/src/qt/walletframe.h b/src/qt/walletframe.h
index eaae053ccd..5011987963 100644
--- a/src/qt/walletframe.h
+++ b/src/qt/walletframe.h
@@ -8,12 +8,17 @@
#define WALLETFRAME_H
#include <QFrame>
+#include <QMap>
class BitcoinGUI;
class ClientModel;
class SendCoinsRecipient;
class WalletModel;
-class WalletStack;
+class WalletView;
+
+QT_BEGIN_NAMESPACE
+class QStackedWidget;
+QT_END_NAMESPACE
class WalletFrame : public QFrame
{
@@ -27,7 +32,7 @@ public:
bool addWallet(const QString& name, WalletModel *walletModel);
bool setCurrentWallet(const QString& name);
-
+ bool removeWallet(const QString &name);
void removeAllWallets();
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
@@ -35,7 +40,12 @@ public:
void showOutOfSyncWarning(bool fShow);
private:
- WalletStack *walletStack;
+ QStackedWidget *walletStack;
+ BitcoinGUI *gui;
+ ClientModel *clientModel;
+ QMap<QString, WalletView*> mapWalletViews;
+
+ bool bOutOfSync;
public slots:
/** Switch to overview (home) page */
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 099fbe8dc3..417bac9928 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -258,22 +258,26 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
// and emit coinsSent signal for each recipient
foreach(const SendCoinsRecipient &rcp, transaction.getRecipients())
{
- std::string strAddress = rcp.address.toStdString();
- CTxDestination dest = CBitcoinAddress(strAddress).Get();
- std::string strLabel = rcp.label.toStdString();
+ // Don't touch the address book when we have a secure payment-request
+ if (rcp.authenticatedMerchant.isEmpty())
{
- LOCK(wallet->cs_wallet);
-
- std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(dest);
-
- // Check if we have a new address or an updated label
- if (mi == wallet->mapAddressBook.end())
- {
- wallet->SetAddressBook(dest, strLabel, "send");
- }
- else if (mi->second.name != strLabel)
+ std::string strAddress = rcp.address.toStdString();
+ CTxDestination dest = CBitcoinAddress(strAddress).Get();
+ std::string strLabel = rcp.label.toStdString();
{
- wallet->SetAddressBook(dest, strLabel, ""); // "" means don't change purpose
+ LOCK(wallet->cs_wallet);
+
+ std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(dest);
+
+ // Check if we have a new address or an updated label
+ if (mi == wallet->mapAddressBook.end())
+ {
+ wallet->SetAddressBook(dest, strLabel, "send");
+ }
+ else if (mi->second.name != strLabel)
+ {
+ wallet->SetAddressBook(dest, strLabel, ""); // "" means don't change purpose
+ }
}
}
emit coinsSent(wallet, rcp, transaction_array);
diff --git a/src/qt/walletstack.cpp b/src/qt/walletstack.cpp
deleted file mode 100644
index 4ef87aed52..0000000000
--- a/src/qt/walletstack.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Qt4 bitcoin GUI.
- *
- * W.J. van der Laan 2011-2012
- * The Bitcoin Developers 2011-2013
- */
-#include "walletstack.h"
-#include "walletview.h"
-#include "bitcoingui.h"
-
-#include <QMap>
-#include <QMessageBox>
-
-WalletStack::WalletStack(QWidget *parent) :
- QStackedWidget(parent),
- gui(0),
- clientModel(0),
- bOutOfSync(true)
-{
- setContentsMargins(0,0,0,0);
-}
-
-WalletStack::~WalletStack()
-{
-}
-
-bool WalletStack::addWallet(const QString& name, WalletModel *walletModel)
-{
- if (!gui || !clientModel || !walletModel || mapWalletViews.count(name) > 0)
- return false;
-
- WalletView *walletView = new WalletView(this, gui);
- walletView->setBitcoinGUI(gui);
- walletView->setClientModel(clientModel);
- walletView->setWalletModel(walletModel);
- walletView->showOutOfSyncWarning(bOutOfSync);
- addWidget(walletView);
- mapWalletViews[name] = walletView;
-
- // Ensure a walletView is able to show the main window
- connect(walletView, SIGNAL(showNormalIfMinimized()), gui, SLOT(showNormalIfMinimized()));
-
- return true;
-}
-
-bool WalletStack::removeWallet(const QString& name)
-{
- if (mapWalletViews.count(name) == 0)
- return false;
-
- WalletView *walletView = mapWalletViews.take(name);
- removeWidget(walletView);
- return true;
-}
-
-void WalletStack::removeAllWallets()
-{
- QMap<QString, WalletView*>::const_iterator i;
- for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
- removeWidget(i.value());
- mapWalletViews.clear();
-}
-
-bool WalletStack::handlePaymentRequest(const SendCoinsRecipient &recipient)
-{
- WalletView *walletView = (WalletView*)currentWidget();
- if (!walletView)
- return false;
-
- return walletView->handlePaymentRequest(recipient);
-}
-
-void WalletStack::showOutOfSyncWarning(bool fShow)
-{
- bOutOfSync = fShow;
- QMap<QString, WalletView*>::const_iterator i;
- for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
- i.value()->showOutOfSyncWarning(fShow);
-}
-
-void WalletStack::gotoOverviewPage()
-{
- QMap<QString, WalletView*>::const_iterator i;
- for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
- i.value()->gotoOverviewPage();
-}
-
-void WalletStack::gotoHistoryPage()
-{
- QMap<QString, WalletView*>::const_iterator i;
- for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
- i.value()->gotoHistoryPage();
-}
-
-void WalletStack::gotoAddressBookPage()
-{
- QMap<QString, WalletView*>::const_iterator i;
- for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
- i.value()->gotoAddressBookPage();
-}
-
-void WalletStack::gotoReceiveCoinsPage()
-{
- QMap<QString, WalletView*>::const_iterator i;
- for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
- i.value()->gotoReceiveCoinsPage();
-}
-
-void WalletStack::gotoSendCoinsPage(QString addr)
-{
- QMap<QString, WalletView*>::const_iterator i;
- for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
- i.value()->gotoSendCoinsPage(addr);
-}
-
-void WalletStack::gotoSignMessageTab(QString addr)
-{
- WalletView *walletView = (WalletView*)currentWidget();
- if (walletView)
- walletView->gotoSignMessageTab(addr);
-}
-
-void WalletStack::gotoVerifyMessageTab(QString addr)
-{
- WalletView *walletView = (WalletView*)currentWidget();
- if (walletView)
- walletView->gotoVerifyMessageTab(addr);
-}
-
-void WalletStack::encryptWallet(bool status)
-{
- WalletView *walletView = (WalletView*)currentWidget();
- if (walletView)
- walletView->encryptWallet(status);
-}
-
-void WalletStack::backupWallet()
-{
- WalletView *walletView = (WalletView*)currentWidget();
- if (walletView)
- walletView->backupWallet();
-}
-
-void WalletStack::changePassphrase()
-{
- WalletView *walletView = (WalletView*)currentWidget();
- if (walletView)
- walletView->changePassphrase();
-}
-
-void WalletStack::unlockWallet()
-{
- WalletView *walletView = (WalletView*)currentWidget();
- if (walletView)
- walletView->unlockWallet();
-}
-
-void WalletStack::setEncryptionStatus()
-{
- WalletView *walletView = (WalletView*)currentWidget();
- if (walletView)
- walletView->setEncryptionStatus();
-}
-
-bool WalletStack::setCurrentWallet(const QString& name)
-{
- if (mapWalletViews.count(name) == 0)
- return false;
-
- WalletView *walletView = mapWalletViews.value(name);
- setCurrentWidget(walletView);
- walletView->setEncryptionStatus();
- return true;
-}
diff --git a/src/qt/walletstack.h b/src/qt/walletstack.h
deleted file mode 100644
index 74b9f09081..0000000000
--- a/src/qt/walletstack.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Qt4 bitcoin GUI.
- *
- * W.J. van der Laan 2011-2012
- * The Bitcoin Developers 2011-2013
- */
-#ifndef WALLETSTACK_H
-#define WALLETSTACK_H
-
-#include <QStackedWidget>
-#include <QMap>
-#include <boost/shared_ptr.hpp>
-
-class BitcoinGUI;
-class TransactionTableModel;
-class ClientModel;
-class WalletModel;
-class WalletView;
-class TransactionView;
-class OverviewPage;
-class AddressBookPage;
-class SendCoinsDialog;
-class SendCoinsRecipient;
-class SignVerifyMessageDialog;
-class Notificator;
-class RPCConsole;
-
-class CWalletManager;
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-class QModelIndex;
-QT_END_NAMESPACE
-
-/*
- WalletStack class. This class is a container for WalletView instances. It takes the place of centralWidget.
- It was added to support multiple wallet functionality. It communicates with both the client and the
- wallet models to give the user an up-to-date view of the current core state. It manages all the wallet views
- it contains and updates them accordingly.
- */
-class WalletStack : public QStackedWidget
-{
- Q_OBJECT
-
-public:
- explicit WalletStack(QWidget *parent = 0);
- ~WalletStack();
-
- void setBitcoinGUI(BitcoinGUI *gui) { this->gui = gui; }
-
- void setClientModel(ClientModel *clientModel) { this->clientModel = clientModel; }
-
- bool addWallet(const QString& name, WalletModel *walletModel);
- bool removeWallet(const QString& name);
-
- void removeAllWallets();
-
- bool handlePaymentRequest(const SendCoinsRecipient &recipient);
-
- void showOutOfSyncWarning(bool fShow);
-
-private:
- BitcoinGUI *gui;
- ClientModel *clientModel;
- QMap<QString, WalletView*> mapWalletViews;
-
- bool bOutOfSync;
-
-public slots:
- bool setCurrentWallet(const QString& name);
-
- /** Switch to overview (home) page */
- void gotoOverviewPage();
- /** Switch to history (transactions) page */
- void gotoHistoryPage();
- /** Switch to address book page */
- void gotoAddressBookPage();
- /** Switch to receive coins page */
- void gotoReceiveCoinsPage();
- /** Switch to send coins page */
- void gotoSendCoinsPage(QString addr = "");
-
- /** Show Sign/Verify Message dialog and switch to sign message tab */
- void gotoSignMessageTab(QString addr = "");
- /** Show Sign/Verify Message dialog and switch to verify message tab */
- void gotoVerifyMessageTab(QString addr = "");
-
- /** Encrypt the wallet */
- void encryptWallet(bool status);
- /** Backup the wallet */
- void backupWallet();
- /** Change encrypted wallet passphrase */
- void changePassphrase();
- /** Ask for passphrase to unlock wallet temporarily */
- void unlockWallet();
-
- /** Set the encryption status as shown in the UI.
- @param[in] status current encryption status
- @see WalletModel::EncryptionStatus
- */
- void setEncryptionStatus();
-};
-
-#endif // WALLETSTACK_H
diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp
index efb74efaa0..d7cef971ed 100644
--- a/src/qt/walletview.cpp
+++ b/src/qt/walletview.cpp
@@ -29,9 +29,9 @@
#include <QFileDialog>
#include <QPushButton>
-WalletView::WalletView(QWidget *parent, BitcoinGUI *_gui):
+WalletView::WalletView(QWidget *parent):
QStackedWidget(parent),
- gui(_gui),
+ gui(0),
clientModel(0),
walletModel(0)
{
@@ -54,12 +54,8 @@ WalletView::WalletView(QWidget *parent, BitcoinGUI *_gui):
transactionsPage->setLayout(vbox);
addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);
-
receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab);
-
- sendCoinsPage = new SendCoinsDialog(gui);
-
- signVerifyMessageDialog = new SignVerifyMessageDialog(gui);
+ sendCoinsPage = new SendCoinsDialog();
addWidget(overviewPage);
addWidget(transactionsPage);
@@ -68,7 +64,6 @@ WalletView::WalletView(QWidget *parent, BitcoinGUI *_gui):
addWidget(sendCoinsPage);
// Clicking on a transaction on the overview page simply sends you to transaction history page
- connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex)));
// Double-clicking on a transaction on the transaction history page shows details
@@ -82,8 +77,6 @@ WalletView::WalletView(QWidget *parent, BitcoinGUI *_gui):
connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));
// Clicking on "Export" allows to export the transaction list
connect(exportButton, SIGNAL(clicked()), transactionView, SLOT(exportClicked()));
-
- gotoOverviewPage();
}
WalletView::~WalletView()
@@ -93,6 +86,10 @@ WalletView::~WalletView()
void WalletView::setBitcoinGUI(BitcoinGUI *gui)
{
this->gui = gui;
+ if(gui)
+ {
+ connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), gui, SLOT(gotoHistoryPage()));
+ }
}
void WalletView::setClientModel(ClientModel *clientModel)
@@ -109,7 +106,7 @@ void WalletView::setClientModel(ClientModel *clientModel)
void WalletView::setWalletModel(WalletModel *walletModel)
{
this->walletModel = walletModel;
- if (walletModel)
+ if (walletModel && gui)
{
// Receive and report messages from wallet thread
connect(walletModel, SIGNAL(message(QString,QString,unsigned int)), gui, SLOT(message(QString,QString,unsigned int)));
@@ -120,7 +117,6 @@ void WalletView::setWalletModel(WalletModel *walletModel)
addressBookPage->setModel(walletModel->getAddressTableModel());
receiveCoinsPage->setModel(walletModel->getAddressTableModel());
sendCoinsPage->setModel(walletModel);
- signVerifyMessageDialog->setModel(walletModel);
setEncryptionStatus();
connect(walletModel, SIGNAL(encryptionStatusChanged(int)), gui, SLOT(setEncryptionStatus(int)));
@@ -152,31 +148,26 @@ void WalletView::incomingTransaction(const QModelIndex& parent, int start, int /
void WalletView::gotoOverviewPage()
{
- gui->getOverviewAction()->setChecked(true);
setCurrentWidget(overviewPage);
}
void WalletView::gotoHistoryPage()
{
- gui->getHistoryAction()->setChecked(true);
setCurrentWidget(transactionsPage);
}
void WalletView::gotoAddressBookPage()
{
- gui->getAddressBookAction()->setChecked(true);
setCurrentWidget(addressBookPage);
}
void WalletView::gotoReceiveCoinsPage()
{
- gui->getReceiveCoinsAction()->setChecked(true);
setCurrentWidget(receiveCoinsPage);
}
void WalletView::gotoSendCoinsPage(QString addr)
{
- gui->getSendCoinsAction()->setChecked(true);
setCurrentWidget(sendCoinsPage);
if (!addr.isEmpty())
@@ -185,7 +176,10 @@ void WalletView::gotoSendCoinsPage(QString addr)
void WalletView::gotoSignMessageTab(QString addr)
{
- // call show() in showTab_SM()
+ // calls show() in showTab_SM()
+ SignVerifyMessageDialog *signVerifyMessageDialog = new SignVerifyMessageDialog(this);
+ signVerifyMessageDialog->setAttribute(Qt::WA_DeleteOnClose);
+ signVerifyMessageDialog->setModel(walletModel);
signVerifyMessageDialog->showTab_SM(true);
if (!addr.isEmpty())
@@ -194,7 +188,10 @@ void WalletView::gotoSignMessageTab(QString addr)
void WalletView::gotoVerifyMessageTab(QString addr)
{
- // call show() in showTab_VM()
+ // calls show() in showTab_VM()
+ SignVerifyMessageDialog *signVerifyMessageDialog = new SignVerifyMessageDialog(this);
+ signVerifyMessageDialog->setAttribute(Qt::WA_DeleteOnClose);
+ signVerifyMessageDialog->setModel(walletModel);
signVerifyMessageDialog->showTab_VM(true);
if (!addr.isEmpty())
diff --git a/src/qt/walletview.h b/src/qt/walletview.h
index ce4e051098..e3ff253d3c 100644
--- a/src/qt/walletview.h
+++ b/src/qt/walletview.h
@@ -36,7 +36,7 @@ class WalletView : public QStackedWidget
Q_OBJECT
public:
- explicit WalletView(QWidget *parent, BitcoinGUI *_gui);
+ explicit WalletView(QWidget *parent);
~WalletView();
void setBitcoinGUI(BitcoinGUI *gui);
@@ -64,7 +64,6 @@ private:
AddressBookPage *addressBookPage;
AddressBookPage *receiveCoinsPage;
SendCoinsDialog *sendCoinsPage;
- SignVerifyMessageDialog *signVerifyMessageDialog;
TransactionView *transactionView;
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index 957241d6a0..6ea805a7f1 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp
index 61cd07d507..3589b45900 100644
--- a/src/rpcdump.cpp
+++ b/src/rpcdump.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2009-2012 Bitcoin Developers
+// Copyright (c) 2009-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.
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index f123c3a9e0..77dc13815d 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp
index f78f034e32..7685dec57b 100644
--- a/src/rpcnet.cpp
+++ b/src/rpcnet.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2009-2012 Bitcoin Developers
+// Copyright (c) 2009-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.
diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp
index 5384b65906..d5bd39cb4d 100644
--- a/src/rpcrawtransaction.cpp
+++ b/src/rpcrawtransaction.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index 433cc8b735..a72c254e76 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
@@ -1169,7 +1169,9 @@ Value listsinceblock(const Array& params, bool fHelp)
uint256 blockId = 0;
blockId.SetHex(params[0].get_str());
- pindex = CBlockLocator(blockId).GetBlockIndex();
+ std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(blockId);
+ if (it != mapBlockIndex.end())
+ pindex = it->second;
}
if (params.size() > 1)
diff --git a/src/script.cpp b/src/script.cpp
index 0fe2953548..4e4e95a678 100644
--- a/src/script.cpp
+++ b/src/script.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#include "script.h"
@@ -971,62 +971,118 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
+namespace {
+/** Wrapper that serializes like CTransaction, but with the modifications
+ * required for the signature hash done in-place
+ */
+class CTransactionSignatureSerializer {
+private:
+ const CTransaction &txTo; // reference to the spending transaction (the one being serialized)
+ const CScript &scriptCode; // output script being consumed
+ const unsigned int nIn; // input index of txTo being signed
+ const bool fAnyoneCanPay; // whether the hashtype has the SIGHASH_ANYONECANPAY flag set
+ const bool fHashSingle; // whether the hashtype is SIGHASH_SINGLE
+ const bool fHashNone; // whether the hashtype is SIGHASH_NONE
-
-uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType)
-{
- if (nIn >= txTo.vin.size())
- {
- LogPrintf("ERROR: SignatureHash() : nIn=%d out of range\n", nIn);
- return 1;
+public:
+ CTransactionSignatureSerializer(const CTransaction &txToIn, const CScript &scriptCodeIn, unsigned int nInIn, int nHashTypeIn) :
+ txTo(txToIn), scriptCode(scriptCodeIn), nIn(nInIn),
+ fAnyoneCanPay(!!(nHashTypeIn & SIGHASH_ANYONECANPAY)),
+ fHashSingle((nHashTypeIn & 0x1f) == SIGHASH_SINGLE),
+ fHashNone((nHashTypeIn & 0x1f) == SIGHASH_NONE) {}
+
+ /** Serialize the passed scriptCode, skipping OP_CODESEPARATORs */
+ template<typename S>
+ void SerializeScriptCode(S &s, int nType, int nVersion) const {
+ CScript::const_iterator it = scriptCode.begin();
+ CScript::const_iterator itBegin = it;
+ opcodetype opcode;
+ unsigned int nCodeSeparators = 0;
+ while (scriptCode.GetOp(it, opcode)) {
+ if (opcode == OP_CODESEPARATOR)
+ nCodeSeparators++;
+ }
+ ::WriteCompactSize(s, scriptCode.size() - nCodeSeparators);
+ it = itBegin;
+ while (scriptCode.GetOp(it, opcode)) {
+ if (opcode == OP_CODESEPARATOR) {
+ s.write((char*)&itBegin[0], it-itBegin-1);
+ itBegin = it;
+ }
+ }
+ s.write((char*)&itBegin[0], it-itBegin);
}
- CTransaction txTmp(txTo);
- // In case concatenating two scripts ends up with two codeseparators,
- // or an extra one at the end, this prevents all those possible incompatibilities.
- scriptCode.FindAndDelete(CScript(OP_CODESEPARATOR));
+ /** Serialize an input of txTo */
+ template<typename S>
+ void SerializeInput(S &s, unsigned int nInput, int nType, int nVersion) const {
+ // In case of SIGHASH_ANYONECANPAY, only the input being signed is serialized
+ if (fAnyoneCanPay)
+ nInput = nIn;
+ // Serialize the prevout
+ ::Serialize(s, txTo.vin[nInput].prevout, nType, nVersion);
+ // Serialize the script
+ if (nInput != nIn)
+ // Blank out other inputs' signatures
+ ::Serialize(s, CScript(), nType, nVersion);
+ else
+ SerializeScriptCode(s, nType, nVersion);
+ // Serialize the nSequence
+ if (nInput != nIn && (fHashSingle || fHashNone))
+ // let the others update at will
+ ::Serialize(s, (int)0, nType, nVersion);
+ else
+ ::Serialize(s, txTo.vin[nInput].nSequence, nType, nVersion);
+ }
- // Blank out other inputs' signatures
- for (unsigned int i = 0; i < txTmp.vin.size(); i++)
- txTmp.vin[i].scriptSig = CScript();
- txTmp.vin[nIn].scriptSig = scriptCode;
+ /** Serialize an output of txTo */
+ template<typename S>
+ void SerializeOutput(S &s, unsigned int nOutput, int nType, int nVersion) const {
+ if (fHashSingle && nOutput != nIn)
+ // Do not lock-in the txout payee at other indices as txin
+ ::Serialize(s, CTxOut(), nType, nVersion);
+ else
+ ::Serialize(s, txTo.vout[nOutput], nType, nVersion);
+ }
- // Blank out some of the outputs
- if ((nHashType & 0x1f) == SIGHASH_NONE)
- {
- // Wildcard payee
- txTmp.vout.clear();
+ /** Serialize txTo */
+ template<typename S>
+ void Serialize(S &s, int nType, int nVersion) const {
+ // Serialize nVersion
+ ::Serialize(s, txTo.nVersion, nType, nVersion);
+ // Serialize vin
+ unsigned int nInputs = fAnyoneCanPay ? 1 : txTo.vin.size();
+ ::WriteCompactSize(s, nInputs);
+ for (unsigned int nInput = 0; nInput < nInputs; nInput++)
+ SerializeInput(s, nInput, nType, nVersion);
+ // Serialize vout
+ unsigned int nOutputs = fHashNone ? 0 : (fHashSingle ? nIn+1 : txTo.vout.size());
+ ::WriteCompactSize(s, nOutputs);
+ for (unsigned int nOutput = 0; nOutput < nOutputs; nOutput++)
+ SerializeOutput(s, nOutput, nType, nVersion);
+ // Serialie nLockTime
+ ::Serialize(s, txTo.nLockTime, nType, nVersion);
+ }
+};
+}
- // Let the others update at will
- for (unsigned int i = 0; i < txTmp.vin.size(); i++)
- if (i != nIn)
- txTmp.vin[i].nSequence = 0;
+uint256 SignatureHash(const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType)
+{
+ if (nIn >= txTo.vin.size()) {
+ LogPrintf("ERROR: SignatureHash() : nIn=%d out of range\n", nIn);
+ return 1;
}
- else if ((nHashType & 0x1f) == SIGHASH_SINGLE)
- {
- // Only lock-in the txout payee at same index as txin
- unsigned int nOut = nIn;
- if (nOut >= txTmp.vout.size())
- {
- LogPrintf("ERROR: SignatureHash() : nOut=%d out of range\n", nOut);
+
+ // Check for invalid use of SIGHASH_SINGLE
+ if ((nHashType & 0x1f) == SIGHASH_SINGLE) {
+ if (nIn >= txTo.vout.size()) {
+ LogPrintf("ERROR: SignatureHash() : nOut=%d out of range\n", nIn);
return 1;
}
- txTmp.vout.resize(nOut+1);
- for (unsigned int i = 0; i < nOut; i++)
- txTmp.vout[i].SetNull();
-
- // Let the others update at will
- for (unsigned int i = 0; i < txTmp.vin.size(); i++)
- if (i != nIn)
- txTmp.vin[i].nSequence = 0;
}
- // Blank out other inputs completely, not recommended for open transactions
- if (nHashType & SIGHASH_ANYONECANPAY)
- {
- txTmp.vin[0] = txTmp.vin[nIn];
- txTmp.vin.resize(1);
- }
+ // Wrapper to serialize only the necessary parts of the transaction being signed
+ CTransactionSignatureSerializer txTmp(txTo, scriptCode, nIn, nHashType);
// Serialize and hash
CHashWriter ss(SER_GETHASH, 0);
diff --git a/src/script.h b/src/script.h
index 842b8512eb..d339f7880e 100644
--- a/src/script.h
+++ b/src/script.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef H_BITCOIN_SCRIPT
diff --git a/src/serialize.h b/src/serialize.h
index e3d9939bcc..4d9aec3426 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_SERIALIZE_H
@@ -216,18 +216,24 @@ uint64 ReadCompactSize(Stream& is)
unsigned short xSize;
READDATA(is, xSize);
nSizeRet = xSize;
+ if (nSizeRet < 253)
+ throw std::ios_base::failure("non-canonical ReadCompactSize()");
}
else if (chSize == 254)
{
unsigned int xSize;
READDATA(is, xSize);
nSizeRet = xSize;
+ if (nSizeRet < 0x10000u)
+ throw std::ios_base::failure("non-canonical ReadCompactSize()");
}
else
{
uint64 xSize;
READDATA(is, xSize);
nSizeRet = xSize;
+ if (nSizeRet < 0x100000000LLu)
+ throw std::ios_base::failure("non-canonical ReadCompactSize()");
}
if (nSizeRet > (uint64)MAX_SIZE)
throw std::ios_base::failure("ReadCompactSize() : size too large");
diff --git a/src/sync.cpp b/src/sync.cpp
index 29a455f9b2..d6444141dc 100644
--- a/src/sync.cpp
+++ b/src/sync.cpp
@@ -78,7 +78,7 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
if (lockstack.get() == NULL)
lockstack.reset(new LockStack);
- if (fDebug) LogPrintf("Locking: %s\n", locklocation.ToString().c_str());
+ LogPrint("lock", "Locking: %s\n", locklocation.ToString().c_str());
dd_mutex.lock();
(*lockstack).push_back(std::make_pair(c, locklocation));
@@ -108,7 +108,7 @@ static void pop_lock()
if (fDebug)
{
const CLockLocation& locklocation = (*lockstack).rbegin()->second;
- LogPrintf("Unlocked: %s\n", locklocation.ToString().c_str());
+ LogPrint("lock", "Unlocked: %s\n", locklocation.ToString().c_str());
}
dd_mutex.lock();
(*lockstack).pop_back();
diff --git a/src/sync.h b/src/sync.h
index 64de7cc57c..10e0470a20 100644
--- a/src/sync.h
+++ b/src/sync.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_SYNC_H
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
index a859eb1de8..c3495095d9 100644
--- a/src/test/Makefile.am
+++ b/src/test/Makefile.am
@@ -34,7 +34,7 @@ test_bitcoin_SOURCES = accounting_tests.cpp alert_tests.cpp \
netbase_tests.cpp pmt_tests.cpp rpc_tests.cpp script_P2SH_tests.cpp \
script_tests.cpp serialize_tests.cpp sigopcount_tests.cpp test_bitcoin.cpp \
transaction_tests.cpp uint160_tests.cpp uint256_tests.cpp util_tests.cpp \
- wallet_tests.cpp $(JSON_TEST_FILES) $(RAW_TEST_FILES)
+ wallet_tests.cpp sighash_tests.cpp $(JSON_TEST_FILES) $(RAW_TEST_FILES)
nodist_test_bitcoin_SOURCES = $(BUILT_SOURCES)
diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp
index 9ef932b5b4..7f6f141c62 100644
--- a/src/test/multisig_tests.cpp
+++ b/src/test/multisig_tests.cpp
@@ -19,7 +19,7 @@ using namespace boost::assign;
typedef vector<unsigned char> valtype;
-extern uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
+extern uint256 SignatureHash(const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
BOOST_AUTO_TEST_SUITE(multisig_tests)
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index dfa5529b87..32be914414 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -21,7 +21,7 @@ using namespace std;
using namespace json_spirit;
using namespace boost::algorithm;
-extern uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
+extern uint256 SignatureHash(const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
static const unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC;
diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp
index 19ffdcab66..50139df09e 100644
--- a/src/test/serialize_tests.cpp
+++ b/src/test/serialize_tests.cpp
@@ -39,7 +39,67 @@ BOOST_AUTO_TEST_CASE(varints)
ss >> VARINT(j);
BOOST_CHECK_MESSAGE(i == j, "decoded:" << j << " expected:" << i);
}
+}
+
+BOOST_AUTO_TEST_CASE(compactsize)
+{
+ CDataStream ss(SER_DISK, 0);
+ vector<char>::size_type i, j;
+
+ for (i = 1; i <= MAX_SIZE; i *= 2)
+ {
+ WriteCompactSize(ss, i-1);
+ WriteCompactSize(ss, i);
+ }
+ for (i = 1; i <= MAX_SIZE; i *= 2)
+ {
+ j = ReadCompactSize(ss);
+ BOOST_CHECK_MESSAGE((i-1) == j, "decoded:" << j << " expected:" << (i-1));
+ j = ReadCompactSize(ss);
+ BOOST_CHECK_MESSAGE(i == j, "decoded:" << j << " expected:" << i);
+ }
+}
+
+static bool isCanonicalException(const std::ios_base::failure& ex)
+{
+ return std::string("non-canonical ReadCompactSize()") == ex.what();
+}
+
+BOOST_AUTO_TEST_CASE(noncanonical)
+{
+ // Write some non-canonical CompactSize encodings, and
+ // make sure an exception is thrown when read back.
+ CDataStream ss(SER_DISK, 0);
+ vector<char>::size_type n;
+
+ // zero encoded with three bytes:
+ ss.write("\xfd\x00\x00", 3);
+ BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalException);
+
+ // 0xfc encoded with three bytes:
+ ss.write("\xfd\xfc\x00", 3);
+ BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalException);
+
+ // 0xfd encoded with three bytes is OK:
+ ss.write("\xfd\xfd\x00", 3);
+ n = ReadCompactSize(ss);
+ BOOST_CHECK(n == 0xfd);
+
+ // zero encoded with five bytes:
+ ss.write("\xfe\x00\x00\x00\x00", 5);
+ BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalException);
+
+ // 0xffff encoded with five bytes:
+ ss.write("\xfe\xff\xff\x00\x00", 5);
+ BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalException);
+
+ // zero encoded with nine bytes:
+ ss.write("\xff\x00\x00\x00\x00\x00\x00\x00\x00", 9);
+ BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalException);
+ // 0x01ffffff encoded with nine bytes:
+ ss.write("\xff\xff\xff\xff\x01\x00\x00\x00\x00", 9);
+ BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalException);
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp
new file mode 100644
index 0000000000..f098d46186
--- /dev/null
+++ b/src/test/sighash_tests.cpp
@@ -0,0 +1,120 @@
+#include <boost/test/unit_test.hpp>
+
+#include "main.h"
+#include "util.h"
+
+extern uint256 SignatureHash(const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
+
+// Old script.cpp SignatureHash function
+uint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType)
+{
+ if (nIn >= txTo.vin.size())
+ {
+ printf("ERROR: SignatureHash() : nIn=%d out of range\n", nIn);
+ return 1;
+ }
+ CTransaction txTmp(txTo);
+
+ // In case concatenating two scripts ends up with two codeseparators,
+ // or an extra one at the end, this prevents all those possible incompatibilities.
+ scriptCode.FindAndDelete(CScript(OP_CODESEPARATOR));
+
+ // Blank out other inputs' signatures
+ for (unsigned int i = 0; i < txTmp.vin.size(); i++)
+ txTmp.vin[i].scriptSig = CScript();
+ txTmp.vin[nIn].scriptSig = scriptCode;
+
+ // Blank out some of the outputs
+ if ((nHashType & 0x1f) == SIGHASH_NONE)
+ {
+ // Wildcard payee
+ txTmp.vout.clear();
+
+ // Let the others update at will
+ for (unsigned int i = 0; i < txTmp.vin.size(); i++)
+ if (i != nIn)
+ txTmp.vin[i].nSequence = 0;
+ }
+ else if ((nHashType & 0x1f) == SIGHASH_SINGLE)
+ {
+ // Only lock-in the txout payee at same index as txin
+ unsigned int nOut = nIn;
+ if (nOut >= txTmp.vout.size())
+ {
+ printf("ERROR: SignatureHash() : nOut=%d out of range\n", nOut);
+ return 1;
+ }
+ txTmp.vout.resize(nOut+1);
+ for (unsigned int i = 0; i < nOut; i++)
+ txTmp.vout[i].SetNull();
+
+ // Let the others update at will
+ for (unsigned int i = 0; i < txTmp.vin.size(); i++)
+ if (i != nIn)
+ txTmp.vin[i].nSequence = 0;
+ }
+
+ // Blank out other inputs completely, not recommended for open transactions
+ if (nHashType & SIGHASH_ANYONECANPAY)
+ {
+ txTmp.vin[0] = txTmp.vin[nIn];
+ txTmp.vin.resize(1);
+ }
+
+ // Serialize and hash
+ CHashWriter ss(SER_GETHASH, 0);
+ ss << txTmp << nHashType;
+ return ss.GetHash();
+}
+
+void static RandomScript(CScript &script) {
+ static const opcodetype oplist[] = {OP_FALSE, OP_1, OP_2, OP_3, OP_CHECKSIG, OP_IF, OP_VERIF, OP_RETURN, OP_CODESEPARATOR};
+ script = CScript();
+ int ops = (insecure_rand() % 10);
+ for (int i=0; i<ops; i++)
+ script << oplist[insecure_rand() % (sizeof(oplist)/sizeof(oplist[0]))];
+}
+
+void static RandomTransaction(CTransaction &tx, bool fSingle) {
+ tx.nVersion = insecure_rand();
+ tx.vin.clear();
+ tx.vout.clear();
+ tx.nLockTime = (insecure_rand() % 2) ? insecure_rand() : 0;
+ int ins = (insecure_rand() % 4) + 1;
+ int outs = fSingle ? ins : (insecure_rand() % 4) + 1;
+ for (int in = 0; in < ins; in++) {
+ tx.vin.push_back(CTxIn());
+ CTxIn &txin = tx.vin.back();
+ txin.prevout.hash = GetRandHash();
+ txin.prevout.n = insecure_rand() % 4;
+ RandomScript(txin.scriptSig);
+ txin.nSequence = (insecure_rand() % 2) ? insecure_rand() : (unsigned int)-1;
+ }
+ for (int out = 0; out < outs; out++) {
+ tx.vout.push_back(CTxOut());
+ CTxOut &txout = tx.vout.back();
+ txout.nValue = insecure_rand() % 100000000;
+ RandomScript(txout.scriptPubKey);
+ }
+}
+
+BOOST_AUTO_TEST_SUITE(sighash_tests)
+
+BOOST_AUTO_TEST_CASE(sighash_test)
+{
+ seed_insecure_rand(false);
+
+ for (int i=0; i<50000; i++) {
+ int nHashType = insecure_rand();
+ CTransaction txTo;
+ RandomTransaction(txTo, (nHashType & 0x1f) == SIGHASH_SINGLE);
+ CScript scriptCode;
+ RandomScript(scriptCode);
+ int nIn = insecure_rand() % txTo.vin.size();
+ BOOST_CHECK(SignatureHash(scriptCode, txTo, nIn, nHashType) ==
+ SignatureHashOld(scriptCode, txTo, nIn, nHashType));
+ }
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
diff --git a/src/txdb.cpp b/src/txdb.cpp
index 24ee8ec3e8..5e7b78296c 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
diff --git a/src/txdb.h b/src/txdb.h
index f59fc5da86..e3560a9c5c 100644
--- a/src/txdb.h
+++ b/src/txdb.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_TXDB_LEVELDB_H
diff --git a/src/uint256.h b/src/uint256.h
index 45ab8abb5e..79404f1b16 100644
--- a/src/uint256.h
+++ b/src/uint256.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_UINT256_H
diff --git a/src/util.cpp b/src/util.cpp
index cfaf5bdf8c..71994587cf 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
@@ -95,8 +95,6 @@ void locking_callback(int mode, int i, const char* file, int line)
}
}
-LockedPageManager LockedPageManager::instance;
-
// Init
class CInit
{
diff --git a/src/util.h b/src/util.h
index c3fb01dbf0..258910e2fb 100644
--- a/src/util.h
+++ b/src/util.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_UTIL_H
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 0f0ce7e631..5eb2808920 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
@@ -1231,9 +1231,10 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend,
}
int64 nChange = nValueIn - nValue - nFeeRet;
- // if sub-cent change is required, the fee must be raised to at least nMinTxFee
- // or until nChange becomes zero
- // NOTE: this depends on the exact behaviour of GetMinFee
+ // The following if statement should be removed once enough miners
+ // have upgraded to the 0.9 GetMinFee() rules. Until then, this avoids
+ // creating free transactions that have change outputs less than
+ // CENT bitcoins.
if (nFeeRet < CTransaction::nMinTxFee && nChange > 0 && nChange < CENT)
{
int64 nMoveToFee = min(nChange, CTransaction::nMinTxFee - nFeeRet);
@@ -1299,7 +1300,15 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend,
strFailReason = _("Transaction too large");
return false;
}
- dPriority /= nBytes;
+ unsigned int nTxSizeMod = nBytes;
+ // See miner.c's dPriority logic for the matching network-node side code.
+ BOOST_FOREACH(const CTxIn& txin, (*(CTransaction*)&wtxNew).vin)
+ {
+ unsigned int offset = 41U + min(110U, (unsigned int)txin.scriptSig.size());
+ if (nTxSizeMod > offset)
+ nTxSizeMod -= offset;
+ }
+ dPriority /= nTxSizeMod;
// Check that enough fee is included
int64 nPayFee = nTransactionFee * (1 + (int64)nBytes / 1000);
diff --git a/src/wallet.h b/src/wallet.h
index 51bc9f67c4..f87e9b08c4 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_WALLET_H
diff --git a/src/walletdb.cpp b/src/walletdb.cpp
index 635fda1b42..831ef8b00d 100644
--- a/src/walletdb.cpp
+++ b/src/walletdb.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
@@ -306,6 +306,8 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
}
CKey key;
CPrivKey pkey;
+ uint256 hash = 0;
+
if (strType == "key")
{
wss.nKeys++;
@@ -315,14 +317,40 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
ssValue >> wkey;
pkey = wkey.vchPrivKey;
}
- if (!key.SetPrivKey(pkey, vchPubKey.IsCompressed()))
+
+ // Old wallets store keys as "key" [pubkey] => [privkey]
+ // ... which was slow for wallets with lots of keys, because the public key is re-derived from the private key
+ // using EC operations as a checksum.
+ // Newer wallets store keys as "key"[pubkey] => [privkey][hash(pubkey,privkey)], which is much faster while
+ // remaining backwards-compatible.
+ try
{
- strErr = "Error reading wallet database: CPrivKey corrupt";
- return false;
+ ssValue >> hash;
+ }
+ catch(...){}
+
+ bool fSkipCheck = false;
+
+ if (hash != 0)
+ {
+ // hash pubkey/privkey to accelerate wallet load
+ std::vector<unsigned char> vchKey;
+ vchKey.reserve(vchPubKey.size() + pkey.size());
+ vchKey.insert(vchKey.end(), vchPubKey.begin(), vchPubKey.end());
+ vchKey.insert(vchKey.end(), pkey.begin(), pkey.end());
+
+ if (Hash(vchKey.begin(), vchKey.end()) != hash)
+ {
+ strErr = "Error reading wallet database: CPubKey/CPrivKey corrupt";
+ return false;
+ }
+
+ fSkipCheck = true;
}
- if (key.GetPubKey() != vchPubKey)
+
+ if (!key.Load(pkey, vchPubKey, fSkipCheck))
{
- strErr = "Error reading wallet database: CPrivKey pubkey inconsistency";
+ strErr = "Error reading wallet database: CPrivKey corrupt";
return false;
}
if (!pwallet->LoadKey(key, vchPubKey))
diff --git a/src/walletdb.h b/src/walletdb.h
index 09ebebe5ac..b6d0d45449 100644
--- a/src/walletdb.h
+++ b/src/walletdb.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2012 The Bitcoin developers
+// Copyright (c) 2009-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.
#ifndef BITCOIN_WALLETDB_H
@@ -93,8 +93,14 @@ public:
if (!Write(std::make_pair(std::string("keymeta"), vchPubKey),
keyMeta))
return false;
-
- return Write(std::make_pair(std::string("key"), vchPubKey), vchPrivKey, false);
+
+ // hash pubkey/privkey to accelerate wallet load
+ std::vector<unsigned char> vchKey;
+ vchKey.reserve(vchPubKey.size() + vchPrivKey.size());
+ vchKey.insert(vchKey.end(), vchPubKey.begin(), vchPubKey.end());
+ vchKey.insert(vchKey.end(), vchPrivKey.begin(), vchPrivKey.end());
+
+ return Write(std::make_pair(std::string("key"), vchPubKey), std::make_pair(vchPrivKey, Hash(vchKey.begin(), vchKey.end())), false);
}
bool WriteCryptedKey(const CPubKey& vchPubKey,