Compare commits

...

423 Commits
24.x ... v0.6.3

Author SHA1 Message Date
Gavin Andresen
6e0c5e3778 Revert "Update gitian descriptors to point at stable git repo"
This reverts commit 1179f6373d.
2012-06-19 16:44:55 -04:00
Gavin Andresen
23e7583a8c Merge branch '0.6.x' of git://gitorious.org/+bitcoin-stable-developers/bitcoin/bitcoind-stable into 0.6.3 2012-06-19 16:34:10 -04:00
Gavin Andresen
b90b8159db print large orphan warning BEFORE deleting pvMsg 2012-06-19 16:30:37 -04:00
Gavin Andresen
bd05d057eb Checkpoint at block 185333 (and remove a couple of intermediate checkpoints) 2012-06-19 16:28:09 -04:00
Pieter Wuille
c58ff3781d Use a 64-bit nonce in ping
Former code sent '0' as nonce, which was serialized as 32-bit.
2012-06-19 15:38:58 -04:00
Jeff Garzik
57ca021e7e Prevent crashes due to missing or corrupted blk????.dat records
In LoadExternalBlockFile(), errors are already caught... silently.
Add a warning message, even though we do not abort the program due to
load error.
2012-06-19 15:38:45 -04:00
Jeff Garzik
4bd6299efd Prevent crashes due to missing or corrupted database records
Any problems seen during deserialization will throw an uncaught
exception, crashing the entire bitcoin process.  Properly return an
error instead, so that we may at least log the error and gracefully
shutdown other portions of the app.
2012-06-19 15:36:43 -04:00
Gavin Andresen
fcbeaff8d0 Move signature cache from CKey::Verify to CheckSig in script.cpp
More than doubles the speed of verifying already-cached signatures
that use compressed pubkeys:
Before: ~200 microseconds
After:  ~80 microseconds
(no caching at all: ~3,300 microseconds per signature)

Also encapsulates the signature cache code in a class
and fixes a signed/unsigned comparison warning.
2012-06-19 15:36:34 -04:00
Jeff Garzik
414e0407df Define BOOST_SPIRIT_THREADSAFE in all makefiles
rather than at each include site.

Fixes #1371
2012-06-19 15:27:54 -04:00
Jeff Garzik
7c1773cf37 Default to DB_TXN_WRITE_NOSYNC for all transactional operations
* This is safer than DB_TXN_NOSYNC, and does not appear to impact
  performance.
* Applying this to the dbenv is necessary to avoid many fdatasync(2)
  calls on db 5.x
* We carefully and thoroughly flush databases upon shutdown and
  other important events already.
2012-06-19 15:23:42 -04:00
Gavin Andresen
28a498d5a6 Refactor: GetRandHash() method for util 2012-06-19 15:22:58 -04:00
Gavin Andresen
2d90330d8c Cache signature verifications
Create a maximum-10MB signature verification result cache.
This should almost double the number of transactions that
can be processed on a given CPU, because before this change
ECDSA signatures were verified when transactions were added
to the memory pool and then again when they appeared in
a block.
2012-06-19 15:22:57 -04:00
Gavin Andresen
4d87a33eae Further DoS prevention: Verify signatures last
Loop over all inputs doing inexpensive validity checks first,
and then loop over them a second time doing expensive signature
checks. This helps prevent possible CPU exhaustion attacks
where an attacker tries to make a victim waste time checking
signatures for invalid transactions.
2012-06-19 14:52:50 -04:00
Gavin Andresen
63ee422ab3 Remove invalid dependent orphans from memory
Remove orphan transactions from memory once
all of their parent transactions are received
and they're still not valid.
Thanks to Sergio Demian Lerner for suggesting this fix.
2012-06-19 14:52:41 -04:00
Gavin Andresen
469f6da8bc Optimize orphan transaction handling
Changes suggested by Sergio Demian Lerner to
help prevent potential DoS attacks.
2012-06-19 14:52:29 -04:00
Jeff Garzik
87593b9837 Make orphan logging more verbose, displaying mapOrphanTransactions.size()
Old log message:
	storing orphan tx df2244f6bc

New log message:
	storing orphan tx df2244f6bc (mapsz 51)

Also, trim a few trailing whitespace in main.cpp.
2012-06-19 14:49:38 -04:00
Gavin Andresen
4aa8021a96 Refactor: move code from key.h to key.cpp 2012-06-19 14:45:40 -04:00
Gavin Andresen
db4036a829 Bump version numbers to 0.6.3 2012-06-19 14:44:38 -04:00
Luke Dashjr
5e322a72f9 Merge branch '0.6.0.x' into 0.6.x
Conflicts:
	.gitignore
	src/bitcoinrpc.cpp
	src/main.cpp
	src/qt/bitcoingui.cpp
	src/ui_interface.h
	src/util.cpp
2012-06-14 18:21:07 +00:00
Luke Dashjr
6ec9d30905 Merge branch '0.5.x' into 0.6.0.x
Conflicts:
	src/main.h
	src/net.cpp
	src/serialize.h
2012-06-14 18:13:46 +00:00
Luke Dashjr
3703150d56 Merge branch '0.4.x' into 0.5.x
Conflicts:
	doc/release-process.txt
	src/serialize.h
2012-06-14 18:07:11 +00:00
Pieter Wuille
8f0c0c16d3 Use a 64-bit nonce in ping
Former code sent '0' as nonce, which was serialized as 32-bit.
2012-06-14 18:00:49 +00:00
Wladimir J. van der Laan
1bc2f0a37b Fix build of testcases after commit 0f10b21719 2012-06-14 17:59:31 +00:00
Philip Kaufmann
276cfd8530 Bugfix: Fix various places where Bitcoin-Qt was being shutdown improperly
(Partial/merge of upstream 9247134eab, 1a3f0da922, and 3e34352222)
2012-06-14 17:53:59 +00:00
Philip Kaufmann
0b1fda6f65 Don't call exit() in Shutdown() for Bitcoin-Qt (fixes a tray-icon issue)
(partial of 9247134eab)
2012-06-14 17:32:45 +00:00
Matt Corallo
ca39829ecb Update wiki changelog at doc/release-process.txt 2012-06-14 17:21:05 +00:00
Philip Kaufmann
a973e225e7 change initial Balance on overviewpage from "123.456 BTC" to "0 BTC" to not confuse users, which could see it before we init with the real wallet balance 2012-06-14 17:19:48 +00:00
Philip Kaufmann
5482b5d23b removed ability to translate "0 BTC" and "123.456 BTC" as this is only used as preview in the Qt Designer anyway
(partial of 4295311da3)
2012-06-14 17:18:44 +00:00
Matt Corallo
1903033bad Fix broken config files 2012-06-14 17:13:29 +00:00
Wladimir J. van der Laan
b825e816e4 Do not select first address automatically in the address book
This contributed to an accidental send (#1384), and has no clear advantage, better to disable it.
2012-06-14 17:11:26 +00:00
Pieter Wuille
01ed45cbbc Update comment about secure_allocator<> 2012-06-14 17:03:27 +00:00
Luke Dashjr
9849f50b68 Bump VERSION so we can differentiate between fixed 0.4.7rc2 and not-fixed 0.4.7rc1 2012-06-14 15:59:18 +00:00
Luke Dashjr
9a48f56fb0 Bugfix: Move IsStandard scriptSig size check out of IsPushOnly, since BIP16 verification uses the latter too
This caused clients to reject block #177618 since it has a P2SH transaction with over 200 bytes in scriptSig.

(Upstream commit: e679ec969c)
2012-06-12 23:50:38 +00:00
Luke Dashjr
722ff53718 Bugfix: Allow tray icon to linger until Bitcoin-Qt shuts down completely. Fixes #908
Upstream commit: 7cfbe1fee4
2012-06-06 20:00:22 +00:00
Philip Kaufmann
af413c0a0f fix an incorrect if-clause in net.cpp 2012-06-06 19:37:53 +00:00
Michael Hendricks
a0ea95d3ce Serialize access to debug.log stream
Acquire an exclusive, advisory lock before sending output to debug.log
and release it when we're done. This should avoid output from multiple
threads being interspersed in the log file.

We can't use CRITICAL_SECTION machinery for this because the debug log
is written during startup and shutdown when that machinery is not
available.

(Thanks to Gavin for pointing out the CRITICAL_SECTION problems based
on his earlier work in this area)
2012-06-06 19:29:28 +00:00
Matt Corallo
fdd907c9f1 Correct blockchain size in contrib/debian.
* Updates package description to note that blockchain now takes
  2+ GB instead of 150+ MB.

(PARTIAL of 8f6111bb9c)
2012-06-06 19:24:31 +00:00
Chris Moore
7c4de78a5c "USE_UPNP=-" is needed to remove UPnP support. 2012-06-06 19:21:15 +00:00
Jeff Garzik
82a227b263 .gitignore: add test_bitcoin 2012-05-26 02:25:16 +00:00
Pieter Wuille
17badef789 Do not signal outbound semaphore if uninitialized 2012-05-25 21:32:06 +00:00
Luke Dashjr
a49927a46d Merge branch '0.6.0.x' into 0.6.x
Conflicts:
	bitcoin-qt.pro
	doc/README
	doc/README_windows.txt
	share/setup.nsi
	src/bitcoinrpc.h
	src/db.h
	src/headers.h
	src/init.cpp
	src/main.cpp
	src/main.h
	src/noui.h
	src/qt/bitcoin.cpp
	src/qt/locale/bitcoin_en.ts
	src/qt/walletmodel.cpp
	src/script.cpp
	src/ui_interface.h
	src/util.cpp
2012-05-22 23:07:46 +00:00
Luke Dashjr
d67b0434f2 Merge branch '0.5.x' into 0.6.0.x
Conflicts:
	src/main.cpp
2012-05-22 22:57:10 +00:00
Luke Dashjr
3b36da6d27 Merge branch '0.4.x' into 0.5.x
Conflicts:
	src/ui.cpp
	src/ui.h
	src/uibase.cpp
	src/xpm/about.xpm
2012-05-22 22:55:49 +00:00
Jeff Garzik
a2de1ea2d5 Prevent crashes due to missing or corrupted blk????.dat records 2012-05-22 22:50:02 +00:00
Jeff Garzik
b6862f7b74 Prevent crashes due to missing or corrupted database records
Any problems seen during deserialization will throw an uncaught
exception, crashing the entire bitcoin process.  Properly return an
error instead, so that we may at least log the error and gracefully
shutdown other portions of the app.
2012-05-22 22:47:51 +00:00
Wladimir J. van der Laan
d7534272c6 Remove duplicate behavior on MacOSX
Dock icon on macosx already has show/hide functionality. This results in erratic behavior.
2012-05-22 22:43:53 +00:00
R E Broadley
8a39b0d613 Correct debug.log output to show correct function the debug is coming from. 2012-05-22 22:42:13 +00:00
Wladimir J. van der Laan
087fc28f7d Filter out whitespace and zero-width non-breaking spaces in validator
- Fixes issues with copy/pasting from web or html emails (#1325)
2012-05-22 22:33:41 +00:00
Fordy
58ac600b2c Update License in File Headers
I originally created a pull to replace the "COPYING" in crypter.cpp and
crypter.h, but it turned out that COPYING was actually the correct
file.
2012-05-20 20:15:41 +00:00
Fordy
b2de28c740 Update License in File Headers
I originally created a pull to replace the "COPYING" in crypter.cpp and
crypter.h, but it turned out that COPYING was actually the correct
file.
2012-05-20 20:10:24 +00:00
Fordy
d11488abd0 Update License in File Headers
I originally created a pull to replace the "COPYING" in crypter.cpp and
crypter.h, but it turned out that COPYING was actually the correct
file.
2012-05-20 20:06:11 +00:00
Fordy
e10622d129 Update License in File Headers
I originally created a pull to replace the "COPYING" in crypter.cpp and
crypter.h, but it turned out that COPYING was actually the correct
file.
2012-05-20 20:00:26 +00:00
Philip Kaufmann
334668cde4 remove 2 ugly spaces from a message string
(PARTIAL of 966ae00)
2012-05-20 19:54:14 +00:00
R E Broadley
c45c2c380d Add build directory to .gitignore, so that it's not tracked. 2012-05-18 00:08:34 +00:00
R E Broadley
77b0f86a43 Add /bin/sh to bitcoin-qt.pro - as some filesystems don't have the execute flag. 2012-05-18 00:07:45 +00:00
Christian von Roques
fba681519a Fix typo. libarcode => libqrcode 2012-05-18 00:04:59 +00:00
Jeff Garzik
3a05f1d2ce Always check return values of TxnBegin() and TxnCommit() 2012-05-18 00:04:18 +00:00
Jeff Garzik
738592a002 Always check return values of TxnBegin() and TxnCommit()
PARTIAL, since d68dcf7 isn't backported (yet)
2012-05-18 00:03:32 +00:00
Pieter Wuille
c455aec699 Hopefully final fix for the stuck blockchain issue
Immediately issue a "getblocks", instead of a "getdata" (which will
trigger the relevant "inv" to be sent anyway), and only do so when
the previous set of invs led us into a known and attached part of
the block tree.
2012-05-17 23:45:49 +00:00
Philip Kaufmann
10593f3be1 remove string "TextLabel" from warningLabel, as this is unneeded and as such is a silly translation less to do :) 2012-05-15 08:08:32 +00:00
Wladimir J. van der Laan
dc15d56b2d Properly escape " in strings when exporting CSV 2012-05-15 08:03:38 +00:00
Fordy
0d174e130b Correct Date 2012-05-15 08:02:57 +00:00
Fordy
182738e177 Correct Date 2012-05-15 08:02:30 +00:00
Pieter Wuille
7532c476fe Fix version numbers of archive builds 2012-05-15 08:00:04 +00:00
Gavin Andresen
d306fd833c Fix osx build 2012-05-15 07:49:27 +00:00
Matt Corallo
7700b94d33 Fix DEBUG_LOCKCONTENTION 2012-05-15 07:40:01 +00:00
Philip Kaufmann
7515f00aa3 remove 2 ugly spaces from a string used in translations 2012-05-15 07:37:59 +00:00
Philip Kaufmann
9e52f51223 remove 2 obsolete functions from init.h that moved to util.h 2012-05-15 07:34:22 +00:00
Luke Dashjr
93b5eff274 Bitcoin-Qt: Remove redundant tooltip on optional transaction fee. Fixes #1218 2012-05-15 07:32:00 +00:00
Luke Dashjr
99101685f6 Merge remote branch 'origin/0.6.2' into 0.6.x
Conflicts:
	src/addrman.cpp
2012-05-15 07:23:32 +00:00
Gavin Andresen
40fd689eb1 Bump version to 0.6.2.2 for osx-special build 2012-05-11 10:09:45 -04:00
Gavin Andresen
aaff04791d Merge branch 'semaphores-v0.6.2' of https://github.com/sipa/bitcoin into 0.6.2 2012-05-10 16:39:49 -04:00
Pieter Wuille
f0f1b3775e Use polling instead of boost's broken semaphore on OSX 2012-05-10 22:34:49 +02:00
Pieter Wuille
ca0816152d Use semaphores instead of condition variables 2012-05-10 22:34:43 +02:00
Gavin Andresen
91b13a0dff Revert "Fix 100% cpu usage on osx bug"
This reverts commit 8f9123a157.
2012-05-10 16:14:15 -04:00
Gavin Andresen
8f9123a157 Fix 100% cpu usage on osx bug 2012-05-09 18:58:38 -04:00
Luke Dashjr
8fa3259664 Bump version to 0.6.0.8 2012-05-08 20:11:44 +00:00
Luke Dashjr
cd0527453b Merge branch '0.5.x' into 0.6.0.x
Conflicts:
	bitcoin-qt.pro
	doc/README
	doc/README_windows.txt
	share/setup.nsi
	src/serialize.h
2012-05-08 20:10:20 +00:00
Luke Dashjr
35a07f8ec4 Bump version to 0.5.6 2012-05-08 20:09:43 +00:00
Luke Dashjr
fac3476993 Merge branch '0.4.x' into 0.5.x
Conflicts:
	contrib/Bitcoin.app/Contents/Info.plist
	doc/README
	doc/README_windows.txt
	share/setup.nsi
	src/serialize.h
2012-05-08 20:08:19 +00:00
Luke Dashjr
18b4eccddb Bump version to 0.4.7 2012-05-08 19:53:29 +00:00
Gavin Andresen
8ff1873096 Bump versions for 0.6.2 2012-05-08 12:58:39 -04:00
Luke Dashjr
b481373001 Update/fix translations 2012-05-07 05:34:18 +00:00
Luke Dashjr
1fa846bbb6 Merge branch '0.5.x' into 0.6.0.x
Conflicts:
	src/main.cpp
	src/qt/locale/bitcoin_da.ts
	src/qt/locale/bitcoin_de.ts
	src/qt/locale/bitcoin_en.ts
	src/qt/locale/bitcoin_es.ts
	src/qt/locale/bitcoin_es_CL.ts
	src/qt/locale/bitcoin_hu.ts
	src/qt/locale/bitcoin_it.ts
	src/qt/locale/bitcoin_nb.ts
	src/qt/locale/bitcoin_nl.ts
	src/qt/locale/bitcoin_pt_BR.ts
	src/qt/locale/bitcoin_ru.ts
	src/qt/locale/bitcoin_uk.ts
	src/qt/locale/bitcoin_zh_CN.ts
	src/qt/locale/bitcoin_zh_TW.ts
2012-05-07 04:10:54 +00:00
Luke Dashjr
b803009c84 Update/fix translations 2012-05-07 04:10:35 +00:00
Pieter Wuille
60953d05c8 Prevent stuck download: correct solution
Pull request #948 introduced a fix for nodes stuck on a long side branch
of the main chain. The fix was non-functional however, as the additional
getdata request was created in a first step of processing, but dropped
in a second step as it was considered redundant. This commits fixes it
by sending the request directly.
2012-05-07 04:00:49 +00:00
Luke Dashjr
6bcefc1338 Merge commit '293f264' into 0.6.0.x 2012-05-07 04:00:26 +00:00
Luke Dashjr
afff998ef0 Merge branch '0.4.x' into 0.5.x 2012-05-07 02:46:14 +00:00
Pieter Wuille
2403bb79bc Prevent stuck download: correct solution
Pull request #948 introduced a fix for nodes stuck on a long side branch
of the main chain. The fix was non-functional however, as the additional
getdata request was created in a first step of processing, but dropped
in a second step as it was considered redundant. This commits fixes it
by sending the request directly.
2012-05-07 02:45:08 +00:00
Pieter Wuille
eb3f661add Prevent stuck block download in large reorganisations
In cases of very large reorganisations (hundreds of blocks), a situation
may appear where an 'inv' is sent as response to a 'getblocks', but the
last block mentioned in the inv is already known to the receiver node.
However, the supplying node uses a request for this last block as a
trigger to send the rest of the inv blocks. If it never comes, the block
chain download is stuck.

This commit makes the receiver node always request the last inv'ed block,
even if it is already known, to prevent this problem.
2012-05-07 02:44:45 +00:00
Pieter Wuille
5e27f737fa Bugfix: store source address in addrman 2012-05-06 19:59:42 -04:00
Pieter Wuille
05ff9680ba Fix addrman crashes
A function returned the element to remove from a bucket, instead of its
position in that bucket. This function was only called when a tried
bucket overflowed, which only happens after many outgoing connections
have been made.

Closes: #1065, #1156
2012-05-06 19:58:22 -04:00
Pieter Wuille
dfdaee9310 Add extra asserts to addrman 2012-05-06 19:58:06 -04:00
Philip Kaufmann
5cbe24202a fix #952 by checking if we have a new address or an updated label 2012-05-06 22:52:12 +00:00
Philip Kaufmann
293f2644ff fix #952 by checking if we have a new address or an updated label 2012-05-06 22:48:05 +00:00
Wladimir J. van der Laan
486f7c8f65 Hide UI immediately after leaving the main loop.
Prevents it from seeming to hang during shutdown if shutdown is triggered while the window is open.
2012-05-06 14:56:13 +00:00
Wladimir J. van der Laan
e38d492822 Hide UI immediately after leaving the main loop.
Prevents it from seeming to hang during shutdown if shutdown is triggered while the window is open.
2012-05-06 14:55:59 +00:00
Luke Dashjr
9b661e57bf Merge branch '0.6.0.x' into 0.6.x
Conflicts:
	src/bitcoinrpc.cpp
	src/db.cpp
2012-05-06 05:37:21 +00:00
Luke Dashjr
457ff3a437 Merge branch '0.5.x' into 0.6.0.x 2012-05-06 05:35:58 +00:00
Luke Dashjr
5da2dce524 Merge branch '0.4.x' into 0.5.x 2012-05-06 05:35:50 +00:00
Pieter Wuille
700e5a4d86 Bugfix: store source address in addrman 2012-05-06 05:33:38 +00:00
Pieter Wuille
adecb2ea00 Fix addrman crashes
A function returned the element to remove from a bucket, instead of its
position in that bucket. This function was only called when a tried
bucket overflowed, which only happens after many outgoing connections
have been made.

Closes: #1065, #1156
2012-05-06 05:32:44 +00:00
Peter Todd
e2b9bf9e6e Fixed non-sensical error message
Previously trying to create a multisig address that required less than
one signature would output something like the following:

"wrong number of keys(got 1, need at least 0)"
2012-05-06 05:30:43 +00:00
Peter Todd
b94e6eb5a5 Fixed non-sensical error message
Previously trying to create a multisig address that required less than
one signature would output something like the following:

"wrong number of keys(got 1, need at least 0)"
2012-05-06 05:30:37 +00:00
Luke Dashjr
d41f22cb76 Bugfix: %-12I64d is not valid and causes the parameter to be skipped, use %12"PRI64d" instead 2012-05-06 05:27:38 +00:00
Luke Dashjr
607739befb Bugfix: %-12I64d is not valid and causes the parameter to be skipped, use %12"PRI64d" instead
Conflicts:

	src/walletdb.cpp
2012-05-06 05:27:08 +00:00
Philip Kaufmann
479c99022e remove HTML code around "Wallet" (displayed on overview page) and use Qt tags for font settings 2012-05-05 16:15:38 +00:00
Luke Dashjr
65077e1177 Merge branch '0.6.0.x' into 0.6.x
Conflicts:
	bitcoin-qt.pro
	contrib/gitian-descriptors/gitian-win32.yml
	doc/README
	doc/README_windows.txt
	share/qt/make_windows_icon.sh
	share/setup.nsi
	src/bitcoinrpc.cpp
	src/main.cpp
	src/main.h
	src/makefile.linux-mingw
	src/net.cpp
	src/net.h
	src/netbase.h
	src/noui.h
	src/qt/addressbookpage.cpp
	src/qt/bitcoin.cpp
	src/qt/bitcoingui.cpp
	src/qt/bitcoingui.h
	src/qt/bitcoinstrings.cpp
	src/qt/guiutil.cpp
	src/qt/guiutil.h
	src/qt/optionsmodel.cpp
	src/qt/qrcodedialog.cpp
	src/qt/qtipcserver.cpp
	src/script.cpp
	src/serialize.h
	src/ui_interface.h
	src/uint256.h
2012-05-05 16:13:56 +00:00
Luke Dashjr
ee932c6e35 Merge branch '0.5.x' into 0.6.0.x
Conflicts:
	src/main.cpp
2012-05-04 19:55:54 +00:00
Luke Dashjr
c328c684c2 Bugfix: Remove redundant duplicate transaction check 2012-05-04 19:54:24 +00:00
Luke Dashjr
57cd445e95 Merge branch '0.6.0.x' of gitorious.org:+bitcoin-stable-developers/bitcoin/bitcoind-stable into 0.6.0.x 2012-05-04 18:58:37 +00:00
Luke Dashjr
a1a5a89063 Merge branch '0.5.x' into 0.6.0.x
Conflicts:
	src/main.cpp
	src/serialize.h
2012-05-04 18:57:03 +00:00
Luke Dashjr
b2e5f797b5 Merge branch '0.4.x' into 0.5.x 2012-05-04 18:55:15 +00:00
Gavin Andresen
6a89317f62 Check earlier for blocks with duplicate transactions. Fixes #1167 2012-05-04 18:55:05 +00:00
Gavin Andresen
ad5a4c7c47 Check earlier for blocks with duplicate transactions. Fixes #1167 2012-05-04 18:52:16 +00:00
Philip Kaufmann
cae1a68267 remove obsolete BackupWallet() entry in wallet.h 2012-05-04 17:41:13 +00:00
Philip Kaufmann
6789e99e4f add bitcoin-qt.rc to OTHER_FILES (shown in Qt Creator) 2012-05-02 19:39:46 -04:00
Philip Kaufmann
4898482915 fix compiler warning "suggest parentheses around assignment used as truth
value [-Wparentheses]" in util.cpp
2012-05-01 23:11:56 -04:00
Philip Kaufmann
8edec3f9d6 fix DEPENDPATH in the project file, as json has no include sub-dir and src was in twice 2012-05-01 23:11:07 -04:00
Philip Kaufmann
e6578e7fa7 remove unused typedef in serialize.h 2012-05-01 23:09:22 -04:00
Philip Kaufmann
1fb6e2d9bf change button tooltip on sign message page for copy to clipboard as it was missleading 2012-04-30 10:45:58 -04:00
Luke Dashjr
6c055e506d Merge branch '0.5.x' into 0.6.0.x 2012-04-27 16:28:00 -04:00
Gavin Andresen
813dc92cdc fix compiler error in bitcoinrpc RE: boost::system
(Partial of 2232717cba)
2012-04-27 15:00:57 -04:00
Gavin Andresen
3a70f3a4ec Bump win32.deps version number for new openssl 2012-04-27 14:01:49 -04:00
Luke Dashjr
655b1b0cc2 Merge branch '0.5.x' into 0.6.0.x
Conflicts:
	contrib/gitian-descriptors/gitian-win32.yml
2012-04-27 13:57:43 -04:00
Gavin Andresen
dd02f3ca6e Windows build: compile against openssl 1.0.1b 2012-04-27 13:57:17 -04:00
Luke Dashjr
824e8dde8b Merge branch '0.4.x' into 0.5.x
Conflicts:
	doc/build-msw.txt
	src/makefile.linux-mingw
	src/makefile.mingw
2012-04-27 13:52:02 -04:00
Gavin Andresen
b7a2b6e1aa Windows build: compile against openssl 1.0.1b 2012-04-27 13:51:12 -04:00
Gavin Andresen
5ad4028050 Windows build: compile against openssl 1.0.1b 2012-04-27 11:19:20 -04:00
Luke Dashjr
8ba4282c3f Merge branch '0.5.x' into 0.6.0.x
Conflicts:
	bitcoin-qt.pro
	doc/README
	doc/README_windows.txt
	share/setup.nsi
	src/serialize.h
2012-04-27 10:57:15 -04:00
Luke Dashjr
e5f43fe309 Bump version to 0.5.5 2012-04-27 10:55:06 -04:00
Luke Dashjr
ccfcdc2e3d Merge branch '0.4.x' into 0.5.x
Conflicts:
	contrib/Bitcoin.app/Contents/Info.plist
	doc/README
	doc/README_windows.txt
	share/setup.nsi
	src/protocol.h
	src/serialize.h
2012-04-27 10:53:14 -04:00
Luke Dashjr
c18b82d5db Bump version to 0.4.6 2012-04-27 10:50:24 -04:00
freewil
3eb5fdbf5f listsinceblock: rpc param blockid -> blockhash
This is more consistent with the rest of the labeling seen
by the user when accessing the rpc commands.
2012-04-27 10:47:31 -04:00
freewil
aff6456e8a remove strange debug message from listsinceblock 2012-04-27 10:46:36 -04:00
Timothy Redaelli
ea22a380de We should include netinet/in.h to use sockaddr_in (POSIX.1-2001) 2012-04-27 10:45:58 -04:00
Timothy Redaelli
dfac636fd7 We should include netinet/in.h to use sockaddr_in (POSIX.1-2001) 2012-04-27 10:42:37 -04:00
Timothy Redaelli
282e3ffe6e We should include netinet/in.h to use sockaddr_in (POSIX.1-2001) 2012-04-27 10:41:52 -04:00
Jeff Garzik
c21121752d CBlock::WriteToDisk() properly checks ftell(3) for error return
Rather than storing ftell(3)'s return value -- a long -- in an
unsigned int, we store and check a properly typed temp.  Then, assured a
non-negative value, we store in nBlockPosRet.
2012-04-24 01:00:15 -04:00
Jeff Garzik
07d1a50aee Test ScriptSigArgsExpected() for error, before accumulating return value 2012-04-24 00:51:54 -04:00
Luke Dashjr
66116c3847 Merge branch '0.5.x' into 0.6.0.x
Conflicts:
	src/main.h
	src/net.cpp
	src/util.cpp
2012-04-22 10:07:24 -04:00
Luke Dashjr
a93ab87787 Merge branch '0.4.x' into 0.5.x
Conflicts:
	src/main.cpp
2012-04-22 10:05:43 -04:00
Timothy Redaelli
d0fe14ffec Add missing includes. (Fix bulding under GCC 4.7)
(Note: GCC 4.7 build NOT tested with backports -Luke)
2012-04-22 09:41:51 -04:00
Dwayne C. Litzenberger
c43a9ea77d Fix bugs on 'unsigned char' platforms.
In ISO C++, the signedness of 'char' is undefined.  On some platforms (e.g.
ARM), 'char' is an unsigned type, but some of the code relies on 'char' being
signed (as it is on x86).  This is indicated by compiler warnings like this:

 bignum.h: In constructor 'CBigNum::CBigNum(char)':
 bignum.h:81:59: warning: comparison is always true due to limited range of data type [-Wtype-limits]

 util.cpp: In function 'bool IsHex(const string&)':
 util.cpp:427:28: warning: comparison is always false due to limited range of data type [-Wtype-limits]

In particular, IsHex erroneously returned true regardless of the input
characters, as long as the length of the string was a positive multiple of 2.

Note: For testing, it's possible using GCC to force char to be unsigned by
adding the -funsigned-char parameter to xCXXFLAGS.
2012-04-22 09:38:37 -04:00
Dwayne C. Litzenberger
e5b980d72f Fix bugs on 'unsigned char' platforms.
In ISO C++, the signedness of 'char' is undefined.  On some platforms (e.g.
ARM), 'char' is an unsigned type, but some of the code relies on 'char' being
signed (as it is on x86).  This is indicated by compiler warnings like this:

 bignum.h: In constructor 'CBigNum::CBigNum(char)':
 bignum.h:81:59: warning: comparison is always true due to limited range of data type [-Wtype-limits]

 util.cpp: In function 'bool IsHex(const string&)':
 util.cpp:427:28: warning: comparison is always false due to limited range of data type [-Wtype-limits]

In particular, IsHex erroneously returned true regardless of the input
characters, as long as the length of the string was a positive multiple of 2.

Note: For testing, it's possible using GCC to force char to be unsigned by
adding the -funsigned-char parameter to xCXXFLAGS.
2012-04-22 09:38:27 -04:00
Dwayne C. Litzenberger
8104274701 Fix phexdigits[255] is undefined. 2012-04-22 09:26:30 -04:00
Dwayne C. Litzenberger
bd043f19c8 Fix phexdigits[255] is undefined. 2012-04-22 09:26:11 -04:00
Pieter Wuille
e401e5eb79 Add missing breaks in optionmodel's switch case 2012-04-17 20:30:31 -04:00
Pieter Wuille
dc588faf59 Fix potential deadlock
Conflict:
* cs_main in ProcessMessages() (before calling ProcessMessages)
* cs_vSend in CNode::BeginMessage
versus:
* cs_vSend in ThreadMessageHandler2 (before calling SendMessages)
* cs_main in SendMessages

Even though cs_vSend is a try_lock, if it succeeds simultaneously with
the locking of cs_main in ProcessMessages(), it could cause a deadlock.
2012-04-17 15:11:48 -04:00
Jeff Garzik
7f34351910 Fix misc. minor sign-comparison warnings 2012-04-17 15:08:18 -04:00
Jeff Garzik
1b7e5cbcad CNode's nHeaderStart may be negative, so change its type (PARTIAL) 2012-04-17 15:03:05 -04:00
Jeff Garzik
2abd083ea4 Fix sign-compare warnings: netbase's Lookup* max-solutions may be unsigned 2012-04-17 15:00:15 -04:00
Jeff Garzik
0c3aa881e2 Fix loop index var types, fixing many minor sign comparison warnings
foo.size() typically returns an unsigned integral type; make loop variables
match those types' signedness.
2012-04-17 14:59:32 -04:00
Jeff Garzik
774e9b6dbb Fix loop index var types, fixing many minor sign comparison warnings
foo.size() typically returns an unsigned integral type; make loop variables
match those types' signedness.
2012-04-17 14:57:42 -04:00
Jeff Garzik
ef2f3ddaf7 The string class returns string::npos, when find() fails.
Noticed when sign-comparison warnings were enabled.
2012-04-17 14:50:26 -04:00
Wladimir J. van der Laan
d506c160eb Add forgotten initializer 2012-04-17 14:49:36 -04:00
Jeff Garzik
1175d8f6a1 AlreadyHave(): only hold lock during mapTransactions access 2012-04-17 14:40:58 -04:00
Jeff Garzik
12570da46f Locking fix for AlreadyHave()
Access to mapTransactions[] must be guarded by cs_mapTransactions lock.
2012-04-17 13:20:29 -04:00
Wladimir J. van der Laan
e2ce6438a9 Set label when selecting an address that already has a label. Fixes #1080. 2012-04-16 09:18:06 -04:00
Luke Dashjr
3374c3ef09 Merge branch '0.5.x' into 0.6.0.x
Conflicts:
	src/qt/bitcoin.cpp
	src/qt/bitcoingui.cpp
	src/qt/guiutil.cpp
	src/qt/guiutil.h
	src/qt/sendcoinsdialog.cpp
	src/qt/sendcoinsdialog.h
	src/util.cpp
2012-04-15 21:15:48 -04:00
Luke Dashjr
e73b792b1a Merge branch '0.5.0.x' into 0.5.x 2012-04-15 21:06:10 -04:00
Luke Dashjr
79fc752b61 Merge branch '0.4.x' into 0.5.0.x
Conflicts:
	src/keystore.h
2012-04-15 21:05:54 -04:00
Wladimir J. van der Laan
1bdfa94a01 fix warnings: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses] 2012-04-15 19:43:45 -04:00
Wladimir J. van der Laan
8460185dec fix warnings: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses] 2012-04-15 19:43:41 -04:00
Wladimir J. van der Laan
9c236a945c fix warnings: '&&' within '||' [-Wlogical-op-parentheses] 2012-04-15 19:42:40 -04:00
Wladimir J. van der Laan
678a319888 fix warnings: delete called on 'XX' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor] 2012-04-15 19:42:19 -04:00
Wladimir J. van der Laan
0aa0bb1ead fix warnings: unused variable 'XX' [-Wunused-variable] 2012-04-15 19:40:58 -04:00
Wladimir J. van der Laan
fdcafa3535 fix warnings: unused variable 'XX' [-Wunused-variable] 2012-04-15 19:37:34 -04:00
Wladimir J. van der Laan
5f4fee559e fix warnings: enumeration values 'XX' not handled in switch [-Wswitch-enum] 2012-04-15 19:28:48 -04:00
Wladimir J. van der Laan
c4381587a6 fix warnings: 'XX' defined as a struct here but previously declared as a class [-Wmismatched-tags] 2012-04-15 19:28:34 -04:00
Wladimir J. van der Laan
85e975f379 fix warnings: array subscript is of type 'char' [-Wchar-subscripts] 2012-04-15 19:28:09 -04:00
Wladimir J. van der Laan
f650d62fc6 fix warnings: array subscript is of type 'char' [-Wchar-subscripts] 2012-04-15 19:28:00 -04:00
Wladimir J. van der Laan
401db6d96b work around issue in boost::program_options that prevents from compiling in clang 2012-04-15 19:23:01 -04:00
Chris Moore
7c3db2129e CBitcoinSecret::SetString() now calls IsValid() to make sure it was passed something with the correct version. 2012-04-15 13:31:50 -04:00
Wladimir J. van der Laan
cb1035a008 Show a message box when runaway exception happens
This is more clear to users than when the program simply disappears (usually during initialization). It still logs the message to the console and debug log as well.
2012-04-15 13:25:35 -04:00
Luke Dashjr
79940a6793 Merge commit 'e962c7f' into 0.5.0.x 2012-04-15 13:23:43 -04:00
Luke Dashjr
e962c7f532 Bugfix: nTotalBlocks wasn't in 0.5.0, so need to replace it with equivalent function call in backport 2012-04-15 13:23:34 -04:00
Luke Dashjr
b7566fe29c Bump version to 0.6.0.7
Skipping 0.6.0.1 through 0.6.0.6 since the internal version for 0.6.0[.0] was in fact 0.6.0.6
2012-04-15 13:08:21 -04:00
Luke Dashjr
b557c17a37 Bugfix: Check that QRcode_encodeString didn't return NULL (error)
Without this, any error will segfault Bitcoin-Qt
2012-04-15 12:59:11 -04:00
Luke Dashjr
02a38ac22b Add symlink to scripts/qt/make_windows_icon.sh from old file name, just in case 2012-04-14 15:38:26 -04:00
Wladimir J. van der Laan
f2862f1a49 Rename make_windows_icon.py to .sh as it is a shell script (fixes #1099) 2012-04-14 15:38:05 -04:00
Wladimir J. van der Laan
a558054709 Do not show green tick unless all known blocks are downloaded (fixes #921) 2012-04-14 15:33:24 -04:00
Wladimir J. van der Laan
1f91797535 Add missing tooltip and key shortcut in settings dialog (#1088 without line break part) 2012-04-14 15:33:03 -04:00
Gavin Andresen
e88b6b341d Bug fix listtransactions from/count handling. 2012-04-14 15:29:43 -04:00
Luke Dashjr
278074eb23 Display an error, rather than crashing, if encoding a QR Code failed.
(master workaround in b1a99c3a1f + 7261945eb5)
2012-04-14 15:28:07 -04:00
Philip Kaufmann
760d9480ed removed (no label) string if we have NO label
(partial of 9e0dba8c17)
2012-04-14 15:11:28 -04:00
Wladimir J. van der Laan
1f56046fd5 Show error message instead of exception crash when unable to bind RPC port
Fixes issue #875
2012-04-11 15:54:30 -04:00
cardpuncher
06de079091 Added comment lines in French & Turkish which basically mean "Bitcoin, virtual P2P cryptocurrency". 2012-04-11 15:20:59 -04:00
Luke Dashjr
9bf1140b90 Merge branch '0.5.0.x' into 0.5.x 2012-04-06 17:45:20 -04:00
Luke Dashjr
527b512cf7 Bugfix: Windows lacks sleep(), so need to use Sleep() from util.h 2012-04-06 17:44:48 -04:00
Luke Dashjr
892fcaf291 Merge branch '0.5.0.x' into 0.5.x
Conflicts:
	src/qt/notificator.h
2012-04-06 16:34:34 -04:00
p2k
bf1f995c4c Proper support for Growl 1.3 notifications 2012-04-06 16:31:09 -04:00
Luke Dashjr
ce33356094 Bugfix: Replace "URL" with "URI" where we aren't actually working with URLs 2012-04-06 14:46:30 -04:00
Luke Dashjr
d652709aba Bugfix: Replace "URL" with "URI" where we aren't actually working with URLs 2012-04-06 14:30:10 -04:00
graingert
8ae76e0f5d Change sign message bitcoin address tooltip to "The address to sign the message with" Closes #1050 2012-04-05 22:24:44 -04:00
Luke Dashjr
a93bb51604 Merge branch 'strlcpy_attribute' into 0.5.0.x 2012-04-05 19:43:06 -04:00
Luke Dashjr
3e0e10add3 Merge branch '0.5.x' into 0.6.0.x
Conflicts:
	src/keystore.cpp
2012-04-05 18:22:47 -04:00
Luke Dashjr
0d10cb7a1f Merge branch '0.5.0.x' into 0.5.x 2012-04-05 18:21:01 -04:00
Luke Dashjr
0af2f2d856 Merge branch '0.4.x' into 0.5.0.x 2012-04-05 18:20:18 -04:00
Pieter Wuille
c7057326ea Verify status of encrypt/decrypt calls to detect failed padding 2012-04-05 18:03:48 -04:00
Wladimir J. van der Laan
53e596512c Increase time ago of last block for "up to date" status from 30 to 90 minutes
It was too hyperactive.
gmaxwell: I mean that right now when the block gap goes over an hour it starts showing synchronizing. Increasing that to 90 minutes or so would make it only happen about 6.4 times per year
2012-04-04 16:00:04 -04:00
Matt Corallo
d02833c76a Add laanwj to gitian download scripts. 2012-04-04 15:58:15 -04:00
Matt Corallo
bf754cfd01 Add laanwj to gitian download scripts. 2012-04-04 15:58:02 -04:00
Luke Dashjr
fe1725a141 Merge branch '0.5.x' into 0.6.0.x
Conflicts:
	src/bitcoinrpc.cpp
2012-04-04 15:43:29 -04:00
Luke Dashjr
658cf0b1be Merge branch '0.5.0.x' into 0.5.x
Conflicts:
	src/qt/bitcoingui.h
2012-04-04 15:41:07 -04:00
Luke Dashjr
a37092fcf4 Merge branch '0.4.x' into 0.5.0.x 2012-04-04 15:36:25 -04:00
Wladimir J. van der Laan
91d7e847e0 Use a messagebox to display the error when -server is provided without providing a rpc password
(plus part of 7cfbe1fee4)
2012-04-04 13:57:32 -04:00
Luke Dashjr
1376cd9d7f Merge branch '0.5.x' into 0.6.0.x
Conflicts:
	bitcoin-qt.pro
	contrib/debian/changelog
	doc/README
	doc/README_windows.txt
	doc/translation_process.md
	share/setup.nsi
	src/bitcoinrpc.cpp
	src/db.cpp
	src/init.cpp
	src/irc.cpp
	src/main.cpp
	src/main.h
	src/makefile.osx
	src/makefile.unix
	src/net.cpp
	src/net.h
	src/qt/bitcoin.cpp
	src/qt/bitcoingui.cpp
	src/qt/bitcoinstrings.cpp
	src/qt/guiutil.cpp
	src/qt/guiutil.h
	src/qt/locale/bitcoin_da.ts
	src/qt/locale/bitcoin_de.ts
	src/qt/locale/bitcoin_en.ts
	src/qt/locale/bitcoin_es.ts
	src/qt/locale/bitcoin_es_CL.ts
	src/qt/locale/bitcoin_hu.ts
	src/qt/locale/bitcoin_it.ts
	src/qt/locale/bitcoin_nb.ts
	src/qt/locale/bitcoin_nl.ts
	src/qt/locale/bitcoin_pt_BR.ts
	src/qt/locale/bitcoin_ru.ts
	src/qt/locale/bitcoin_uk.ts
	src/qt/locale/bitcoin_zh_CN.ts
	src/qt/locale/bitcoin_zh_TW.ts
	src/qt/sendcoinsdialog.h
	src/qt/transactionrecord.cpp
	src/script.cpp
	src/script.h
	src/serialize.h
	src/util.cpp
	src/util.h
2012-04-04 10:32:09 -04:00
Luke Dashjr
ef9ab3c2a0 Merge branch '0.5.0.x' into 0.5.x 2012-04-04 10:30:35 -04:00
Luke Dashjr
724c65c1f8 Add Luke-Jr's PGP key to gitian-downloader 2012-04-04 10:23:08 -04:00
Luke Dashjr
8fae3dae11 Add Luke-Jr's PGP key to gitian-downloader 2012-04-04 10:23:02 -04:00
Philip Kaufmann
6806677841 removed an ugly line break in a transaction tooltip for case TransactionStatus::Mature 2012-04-04 10:21:14 -04:00
Pieter Wuille
3f47eb4a9a Updated my GPG key 2012-04-04 10:17:26 -04:00
Pieter Wuille
2f98e8c1a4 Updated my GPG key 2012-04-04 10:17:18 -04:00
Luke Dashjr
1fafcee66d Merge branch '0.4.x' into 0.5.0.x
Conflicts:
	src/main.cpp
	src/makefile.unix
2012-04-04 10:10:16 -04:00
Luke Dashjr
d53fbb4a53 Fix script tests for P2SH
Upstream: 922e8e2929
2012-04-04 10:00:32 -04:00
Vegard Nossum
d15180297f Fix testing setup
There were some problems with the existing testing setup:

 - Makefile rules for test-file compilation used CFLAGS instead of
   CXXFLAGS in makefile.unix
2012-04-04 10:00:20 -04:00
Pieter Wuille
60f89779a3 Do not invoke anti-DoS system for invalid BIP16 transactions
Doing so would allow an attack on old nodes, which would relay a
standard transaction spending a BIP16 output in an invalid way,
until reaching a new node, which will disconnect their peer.

Reported by makomk on IRC.
2012-04-04 09:50:48 -04:00
Luke Dashjr
dce656f9e0 Merge branch '0.5.0.x' into 0.5.x 2012-04-02 09:37:09 -04:00
Luke Dashjr
2eba535348 Merge branch 'vfycompsig_0.5.0' into 0.5.0.x 2012-03-27 20:10:46 -04:00
Luke Dashjr
ddd0d9ae54 Minimal support for compressed-key signature recovery (for verifymessage)
Upstream commits:
	11529c6e4f
	d4d9c734c3
2012-03-27 20:03:31 -04:00
Luke Dashjr
9a133240d3 Merge branch '0.5.0.x' into 0.5.x 2012-03-26 20:07:28 -04:00
Luke Dashjr
6085033f31 Merge branch '0.4.x' into 0.5.0.x 2012-03-26 20:06:55 -04:00
Gavin Andresen
9504e415cb Remove wxWidgets .exe and locales during setup 2012-03-26 17:40:02 -04:00
Pieter Wuille
fea0a27ddc Check minversion before loading the rest of the wallet
When a 0.6 wallet with compressed pubkeys is created, it writes a
minversion record to prevent older clients from reading it. If the 0.5
loading it sees a key record before seeing the minversion record however,
it will fail with DB_CORRUPT instead of DB_TOO_NEW.
2012-03-22 16:25:36 -04:00
Wladimir J. van der Laan
1941765ae2 Fix warning about deprecated unescaped backslash 2012-03-22 16:19:48 -04:00
Alistair Buxton
04dc79f1cc When disconnecting a node, clear the received buffer so that we do
not process any already received messages.

The primary reason to do this is if a node spams hundreds of messages
and we ban them, we don't want to continue processing the rest of it.
2012-03-22 16:19:26 -04:00
Pieter Wuille
b6751ed1b2 More debug output for failed reorganizations 2012-03-22 16:18:37 -04:00
Pieter Wuille
8ed1f7c153 Report number of (dis)connected blocks in reorganization
Also report old and new best, and fork point.
2012-03-22 16:18:36 -04:00
Luke Dashjr
68d889db34 Fix grammatical errors in translation process documentation (partial of 2fac102) 2012-03-22 16:15:30 -04:00
Gavin Andresen
e364ad962f Use last checkpoint instead of hard-coded 140,700. Fixes #913. 2012-03-22 16:08:21 -04:00
Luke Dashjr
166004aca5 Merge branch '0.5.3.x' into 0.5.x
Conflicts:
	bitcoin-qt.pro
	doc/README
	doc/README_windows.txt
	share/setup.nsi
	src/serialize.h
2012-03-22 14:15:12 -04:00
Luke Dashjr
fcc547346a Move QMAKE_LIBS_QT_ENTRY adjustment to bitcoin side of build
It could just as well be on either part of the gitian build, but to safely put it on the Qt side would require bumping the filename, and every gitian user rebuilding it.
v0.5.3.1 put it on the Bitcoin side, and this is easier to work with and keep safe, so I'm moving it.

Use `qmake MINGW_THREAD_BUGFIX=0` to disable
2012-03-22 14:14:32 -04:00
Luke Dashjr
d1eafe56c8 Merge branch '0.5.0.x' into 0.5.x 2012-03-21 13:50:35 -04:00
Luke Dashjr
2ac8af4534 Merge branch '0.4.x' into 0.5.0.x
Conflicts:
	src/main.cpp
2012-03-21 13:49:00 -04:00
Luke Dashjr
cdc6b8d6a6 Merge branch 'bip16_0.4.x' into 0.4.x 2012-03-21 13:30:56 -04:00
Luke Dashjr
815a3605c1 Merge branch '0.5.0.x' into 0.5.x
Conflicts:
	bitcoin-qt.pro
	doc/README
	doc/README_windows.txt
	share/setup.nsi
	src/serialize.h
2012-03-21 13:22:24 -04:00
Luke Dashjr
17a5fd9248 Merge branch '0.4.x' into 0.5.0.x 2012-03-21 13:19:25 -04:00
Luke Dashjr
2f2ac3fece Minimal support for validating BIP16 pay-to-script-hash transactions
Note this does NOT include accepting them in blocks (making them standard)
2012-03-20 15:34:43 -04:00
Pieter Wuille
0e6c6e3fd1 Workaround for BN_bn2mpi reading/writing out of bounds
When OpenSSL's BN_bn2mpi is passed a buffer of size 4, valgrind
reports reading/writing one byte past it. I am unable to find
evidence of this behaviour in BN_bn2mpi's source code, so it may
be a spurious warning. However, this change is harmless, as only
the bignum with value 0 results in an mpi serialization of size 4.
2012-03-19 19:08:19 -04:00
Wladimir J. van der Laan
b4c7b6a384 Yet another attempt at implementing "minimize to tray" that works on all OSes 2012-03-19 17:44:18 -04:00
Wladimir J. van der Laan
e20417c333 Hide window from taskbar when "minimize to tray" active by making window into Tool window 2012-03-19 17:44:16 -04:00
Joel Kaartinen
0ae535cdb2 Make the sendcoins dialog use the configured unit type, even on the first attempt. 2012-03-19 12:53:08 -04:00
Luke Dashjr
1194f00350 Print more diagnostic info for the various DB_CORRUPT conditions 2012-03-19 12:52:22 -04:00
Luke Dashjr
00d832756c Print wallet load errors (to debug.log) 2012-03-19 12:51:24 -04:00
Luke Dashjr
0a1c5c9b10 Bump version to 0.5.0.6 2012-03-19 12:15:03 -04:00
Luke Dashjr
b3ba40c6bf Move QMAKE_LIBS_QT_ENTRY adjustment to bitcoin side of build
It could just as well be on either part of the gitian build, but to safely put it on the Qt side would require bumping the filename, and every gitian user rebuilding it.
v0.5.3.1 put it on the Bitcoin side, and this is easier to work with and keep safe, so I'm moving it.
2012-03-19 12:11:49 -04:00
Luke Dashjr
1a4ac2b4d0 Move QMAKE_LIBS_QT_ENTRY adjustment to bitcoin side of build
It could just as well be on either part of the gitian build, but to safely put it on the Qt side would require bumping the filename, and every gitian user rebuilding it.
v0.5.3.1 put it on the Bitcoin side, and this is easier to work with and keep safe, so I'm moving it.
2012-03-17 20:26:08 -04:00
Matt Corallo
1422e5bf51 Bump version to 0.5.3.1 2012-03-16 23:33:10 -04:00
Luke Dashjr
8b3a795ea6 Bugfix: Missing includes 2012-03-16 20:37:25 -04:00
Luke Dashjr
1db5f43dc4 Bugfix: Missing includes 2012-03-16 20:31:12 -04:00
Luke Dashjr
c1c86b147b Merge branch '0.5.0.x' into 0.5.3.x 2012-03-16 17:28:36 -04:00
Luke Dashjr
eca170286e Merge branch '0.5.0.x' into 0.5.x
Conflicts:
	bitcoin-qt.pro
	doc/README
	doc/README_windows.txt
	share/setup.nsi
	src/serialize.h
2012-03-16 16:45:32 -04:00
Luke Dashjr
78b9d2de40 Merge branch '0.4.x' into 0.5.0.x
Conflicts:
	contrib/Bitcoin.app/Contents/Info.plist
	doc/README
	doc/README_windows.txt
	share/setup.nsi
	src/serialize.h
2012-03-16 16:44:00 -04:00
Gavin Andresen
27960a36de Fix issue #848 : broken mining on testnet 2012-03-16 16:40:38 -04:00
Gavin Andresen
91aadbdacf Fix issue #848 : broken mining on testnet 2012-03-16 16:39:52 -04:00
Wladimir J. van der Laan
458b6e6436 fix default suffixes in save dialog in GNOME, make it more clear that PNG is used (solves #833) 2012-03-16 16:36:27 -04:00
Luke Dashjr
7f23df06d7 Bump version to 0.5.4 2012-03-16 16:12:16 -04:00
Luke Dashjr
f322aa4d60 Bump version to 0.5.0.5 2012-03-16 16:11:11 -04:00
Luke Dashjr
ffef16404d Bump version to 0.4.5 2012-03-16 16:04:26 -04:00
Matt Corallo
76a3bfa17c Fix Win32 RPC Crashes. 2012-03-16 15:49:30 -04:00
Gavin Andresen
4986c35d74 Code cleanup: use ECDSA_size() instead of fixed 10,000 byte sig buffer, and explicity init static var 2012-03-13 19:08:42 -04:00
Luke Dashjr
d05c03ab4e Merge branch '0.5.0.x' into 0.5.x 2012-03-11 22:21:06 -04:00
Luke Dashjr
b4f8c8f5f9 Merge branch '0.4.x' into 0.5.0.x 2012-03-11 22:20:31 -04:00
Gregory Maxwell
11c34e0f6c Resolves issue #922 - "wallet passphrase timeout of several years doesn't work"
2^31 milliseconds is only about 25 days. Also clamps Sleep() to 10 years,
because it currently sleeps for 0 seconds when the sleep time would cross
2^31 seconds since the epoch. Hopefully boost will be fixed by 2028.
2012-03-11 21:53:47 -04:00
nomnombtc
b3b4b008e3 fix typo src/net.cpp 2012-03-06 10:28:49 -05:00
Luke Dashjr
9cf600e6da Merge branch '0.5.0.x' into 0.5.x 2012-03-03 13:59:31 -05:00
Luke Dashjr
7013cc3d97 Merge branch '0.4.x' into 0.5.0.x 2012-03-03 13:59:19 -05:00
Luke Dashjr
88aa771536 Bugfix: Fix possible buffer overflow (#901)
Upstream commit: 21ae37d (partial)
2012-03-03 13:51:10 -05:00
Luke Dashjr
4fc8c042a2 Bugfix: Check return value of SHGetSpecialFolderPath in MyGetSpecialFolderPath
Upstream commit: 21ae37d (partial)
2012-03-03 13:45:44 -05:00
Luke Dashjr
e9865a41d6 Merge remote branch 'sipa/nooverwritetx_v0.4.0' into 0.4.x 2012-03-03 12:59:09 -05:00
Pieter Wuille
d7962747c4 Do not allow overwriting unspent transactions (BIP 30)
Introduce the following network rule:
 * a block is not valid if it contains a transaction whose hash
   already exists in the block chain, unless all that transaction's
   outputs were already spent before said block.

Warning: this is effectively a network rule change, with potential
risk for forking the block chain. Leaving this unfixed carries the
same risk however, for attackers that can cause a reorganisation
in part of the network.

Thanks to Russell O'Connor and Ben Reeves.
2012-03-03 18:51:18 +01:00
Gavin Andresen
3108aed0f2 DoS fix for mapOrphanTransactions 2012-03-02 13:04:39 -05:00
Wladimir J. van der Laan
ef48e9b7df In UI, handle cases in which the last received block was generated in the future (secs<0)
Fixes #874.
2012-02-27 13:07:26 -05:00
Chris Moore
0b11082d36 Don't show splash screen when -min is specified on the command line. 2012-02-27 13:07:10 -05:00
Gavin Andresen
feb3c15335 Checkpoint block 168,000 2012-02-27 13:00:23 -05:00
Pieter Wuille
1be5779124 ProcessBlock is sometimes called with pfrom==NULL 2012-02-27 12:58:53 -05:00
Pieter Wuille
ab2be34059 Fix #616: remove base_uint::operator&=(uint64 b) 2012-02-27 12:55:15 -05:00
Pieter Wuille
54fee2d0ce Fix #626: RecvLine wrong error message 2012-02-27 12:54:06 -05:00
Wladimir J. van der Laan
001a64c71c On windows, show message box with help, as there is no stderr (fixes #702)
(partial)
2012-02-27 12:48:28 -05:00
Wladimir J. van der Laan
b085138f89 Only fill in label from address book, if no label is filled in yet, fixes #840 2012-02-27 12:45:25 -05:00
Pieter Wuille
471e0bdc7c Fix #650: CKey::SetSecret BIGNUM leak 2012-02-27 12:42:48 -05:00
Pieter Wuille
caad1add4f Free pwalletdbEncryption after encryping wallet
Fixes a memory leak.
2012-02-27 12:36:56 -05:00
Wladimir J. van der Laan
33e0c3a866 Restructure IPC URL handling (fixes #851) 2012-02-27 12:28:39 -05:00
Wladimir J. van der Laan
82705af1eb Change #ifdef GUI to #ifdef QT_GUI, GUI is not defined anymore... 2012-02-17 12:05:09 -05:00
Pieter Wuille
69ce70866d Extra wallet locking fixes
* Fix sign error in calculation of seconds to sleep
* Do not mix GetTime() (seconds) and Sleep() (milliseconds)
* Do not sleep forever if walletlock() is called
* Do locking within critical section
2012-02-17 10:52:28 -05:00
Luke Dashjr
6fb186f4bb Merge branch '0.5.0.x' into 0.5.x 2012-02-17 09:40:00 -05:00
Luke Dashjr
fdb365df0e Merge branch '0.4.x' into 0.5.0.x 2012-02-17 09:39:54 -05:00
Pieter Wuille
8960f2fc33 Fix wallet locking locking 2012-02-17 09:38:20 -05:00
Pieter Wuille
43163a5a4d Macros for manual critical sections 2012-02-17 09:38:13 -05:00
Luke Dashjr
fb811c31fd Merge branch '0.5.0.x' into 0.5.x
Conflicts:
	src/qt/bitcoingui.cpp
2012-02-17 09:16:19 -05:00
Luke Dashjr
0365f19dec Merge branch '0.4.x' into 0.5.0.x 2012-02-17 09:15:21 -05:00
Wladimir J. van der Laan
25be0597ca don't allow -daemon in bitcoin-qt (changes only #defines) 2012-02-17 09:14:38 -05:00
Matt Corallo
6928794f56 Properly include $*_LIB_PATH in makefile.unix 2012-02-17 09:04:53 -05:00
Pieter Wuille
d52397b3c0 Several shutdown-related fixes
* do not let vnThreadsRunning[1] go negative
* do not perform locking operations while vnThreadsRunning[1] is decreased
* check vnThreadsRunning[1] at exit
2012-02-17 09:02:21 -05:00
Pieter Wuille
622f1438de Bugfix: do not create CAddress for invalid accepts 2012-02-17 09:00:48 -05:00
Janne Pulkkinen
41cde5bbdc Fix Minimize to the tray instead of the taskbar 2012-02-17 08:50:34 -05:00
Wladimir J. van der Laan
6ebb141bf9 Prevent window from being shown momentarily when using -min
- In a previous patch, show() was added to all the page switcher functions. As the contructor calls showOverviewPage(), this means the window is shown in the constructor.
- This change prevents this by connecting show() to the signal instead.
2012-02-17 08:49:46 -05:00
Wladimir J. van der Laan
4c38fbae95 Enable accessible widgets Qt module on win32, so that people with screen readers such as NVDA can make sense of it. 2012-02-14 17:13:28 -05:00
Luke Dashjr
9ab932b769 Merge branch '0.5.0.x' into 0.5.x 2012-02-11 21:26:22 -05:00
Luke Dashjr
8ad6996cc3 Merge branch '0.4.x' into 0.5.0.x 2012-02-11 21:26:11 -05:00
Matt Corallo
888ac4e7a3 Get ext. IP from UPnP, make sure addrMe IsRoutable() in version.
This fixes a potential bug where some NATs may replace the node's
interal IP with its external IP in version messages, causing
incorrect checksums when version messages begin being checksummed
on February 14, 2012.
2012-02-11 21:25:35 -05:00
Pieter Wuille
76e707a44e Fix #822 2012-02-11 20:50:43 -05:00
Luke Dashjr
84d228ed83 Bugfix: Capitalize kB correctly (upstream: 9d4b05c) 2012-02-07 22:50:31 -05:00
Luke Dashjr
a21e4da901 Merge branch '0.5.0.x' into 0.5.x
Conflicts:
	src/qt/locale/bitcoin_ru.ts
	src/qt/locale/bitcoin_zh_TW.ts
2012-02-07 22:49:03 -05:00
Luke Dashjr
b5d9c7d9fb Merge branch '0.4.x' into 0.5.0.x
Conflicts:
	src/bitcoinrpc.cpp
2012-02-07 22:46:07 -05:00
Luke Dashjr
4bbd72cca1 Update copyrights to 2012 for files modified this year 2012-02-07 22:43:39 -05:00
Gregory Maxwell
da6a3919a9 Have bitcoind recommend a secure RPC password. Increase invalid password delay.
Help users avoid insecure configurations a bit by recommending a
secure RPC password and increasing the incorrect password delay.

This may open up a RPC DOS for users with exposed RPC ports and
short passwords. Since users shouldn't have exposed RPC ports OR
short passwords, the DOS risk is preferable to the compromise
risk.

Also logs the client IP address for incorrect attempts.
2012-02-07 22:39:09 -05:00
Wladimir J. van der Laan
e7c3e6e4b4 Restructure credit transaction decomposition (solves issue #689)
When a transaction has multiple outputs that go to the wallet, list these
as multiple transactions in the UI. This is also applied to generated
(coinbase) transactions. Also makes the code shorter and easier
to understand.
2012-02-07 22:36:03 -05:00
Luke Dashjr
ccd69c7d22 Bugfix: Capitalize kB correctly (upstream: 9d4b05c) 2012-02-07 22:35:57 -05:00
Luke Dashjr
4664aae3fe Update copyrights to 2012 for files modified this year 2012-02-07 22:30:50 -05:00
Gregory Maxwell
cac23a5a0b Have bitcoind recommend a secure RPC password. Increase invalid password delay.
Help users avoid insecure configurations a bit by recommending a
secure RPC password and increasing the incorrect password delay.

This may open up a RPC DOS for users with exposed RPC ports and
short passwords. Since users shouldn't have exposed RPC ports OR
short passwords, the DOS risk is preferable to the compromise
risk.

Also logs the client IP address for incorrect attempts.
2012-02-07 22:21:13 -05:00
Luke Dashjr
06e0f79ae5 Merge branch '0.5.0.x' into 0.5.x 2012-02-02 20:17:56 -05:00
Luke Dashjr
882e00e215 Merge branch '0.4.x' into 0.5.0.x
Conflicts:
	src/main.cpp
2012-02-02 20:17:41 -05:00
Gavin Andresen
c11e2b8679 Only store transactions with missing inputs in the orphan pool.
All previous versions of bitcoin could store some types of
invalid transactions in the orphan-transaction list.
2012-02-02 20:03:33 -05:00
Pieter Wuille
d841fc969a Full checking of all loaded keys 2012-02-02 20:03:26 -05:00
Wladimir J. van der Laan
c13d50d861 Revert to global progress indication (see #753) 2012-02-02 17:50:13 -05:00
Pieter Wuille
c1c6de6ad4 Check consistency of private keys
Reported by onlineproof on IRC: Bitcoin does not verify whether private
keys and public keys correspond, when loading a wallet.
2012-02-02 17:49:39 -05:00
Wladimir J. van der Laan
7120874983 Remove loose amp; from Portugese translation (issue #701) 2012-02-02 17:48:15 -05:00
Gavin Andresen
1b6d8f3fca Allow -upnp to override setting in wallet (and simplify logic a bit) 2012-02-02 17:45:04 -05:00
Matt Corallo
e5b031f5d2 Fix UPnP by reannouncing every 20 minutes. 2012-02-02 17:44:42 -05:00
Gavin Andresen
edb563e8a5 Testnet difficulty calculation changes, to take effect Feb 15 2012
Allow mining of min-difficulty blocks if 20 minutes have gone by without mining a regular-difficulty block.
Normal rules apply every 2016 blocks, though, so there may be a very-slow-to-confirm block at the difficulty-adjustment blocks.
2012-02-02 17:44:04 -05:00
Matt Corallo
bccbc5f4c3 Automatically refocus on new SendCoinsEntrys and scroll to them. 2012-02-02 17:37:55 -05:00
Gavin Andresen
22388eac08 Support makefile.osx building test_bitcoin with dynamic boost 2012-02-02 17:34:29 -05:00
Luke Dashjr
1677743fca Rename src/obj/test to src/obj-test to workaround bug in older GNU Make 2012-02-02 17:29:50 -05:00
Luke Dashjr
d1e56838dc Bugfix: Support building test_bitcoin with shared-object boost test framework
Conflicts:

	src/makefile.unix
2012-02-02 17:27:44 -05:00
Luke Dashjr
a0db9a79e5 Merge branch '0.5.0.x' into 0.5.x 2012-01-23 22:45:47 -05:00
Luke Dashjr
8f378e98c5 Merge branch '0.4.x' into 0.5.0.x
Conflicts:
	doc/release-process.txt
2012-01-23 22:45:36 -05:00
Luke Dashjr
3d3f9cd120 Various updates to the release process 2012-01-23 22:44:02 -05:00
Luke Dashjr
5df1a22c2e Various updates to the release process 2012-01-23 22:43:47 -05:00
Daniel Folkinshteyn
54ed0a0432 Update seednodes, pick long-uptime nodes with version >= 0.4.0 2012-01-23 22:39:21 -05:00
Lars Rasmusson
b0870346f2 Replace tabs with four spaces to comply with coding standard in doc/coding.txt 2012-01-23 22:38:30 -05:00
Lars Rasmusson
1181bf86d1 Replace tabs with four spaces to comply with coding standard in doc/coding.txt 2012-01-23 22:37:48 -05:00
Luke Dashjr
382e613ef5 Merge branch '0.5.0.x' into 0.5.x 2012-01-16 22:30:10 -05:00
Luke Dashjr
c144672045 Code tidyups, fixing various warnings.
Partial cherry pick of:

Compile with extra warnings turned on. And more makefile/code tidying up.

This turns on most gcc warnings, and removes some unused variables and other code that triggers warnings.
Exceptions are:
 -Wno-sign-compare : triggered by lots of comparisons of signed integer to foo.size(), which is unsigned.
 -Wno-char-subscripts : triggered by the convert-to-hex functions (I may fix this in a future commit).

Conflicts:

	src/makefile.osx
	src/makefile.unix
	src/netbase.cpp
2012-01-16 22:29:54 -05:00
Luke Dashjr
a5b875f47b Merge branch '0.5.0.x' into 0.5.x 2012-01-16 22:28:14 -05:00
Luke Dashjr
70550ed81b Merge branch '0.4.x' into 0.5.0.x 2012-01-16 22:27:59 -05:00
Janne Pulkkinen
5df96269d3 *Clear all has a tooltip now *About dialog updated 2012-01-16 22:26:54 -05:00
Luke Dashjr
948072c39f Code tidyups, fixing various warnings.
Partial cherry pick of:

Compile with extra warnings turned on. And more makefile/code tidying up.

This turns on most gcc warnings, and removes some unused variables and other code that triggers warnings.
Exceptions are:
 -Wno-sign-compare : triggered by lots of comparisons of signed integer to foo.size(), which is unsigned.
 -Wno-char-subscripts : triggered by the convert-to-hex functions (I may fix this in a future commit).

Conflicts:

	src/makefile.osx
	src/makefile.unix
	src/netbase.cpp
	src/rpc.cpp
2012-01-16 22:18:51 -05:00
Pieter Wuille
880c478635 Remove unused definition 2012-01-10 19:46:04 -05:00
Luke Dashjr
98811f6ad4 Bump version to 0.5.3 2012-01-10 15:58:29 -05:00
Luke Dashjr
83201b12ae Merge branch '0.5.0.x' into 0.5.x
Conflicts:
	bitcoin-qt.pro
	contrib/debian/changelog
	doc/README
	doc/README_windows.txt
	share/setup.nsi
	src/serialize.h
2012-01-10 15:55:40 -05:00
Luke Dashjr
507848b63d Bump version to 0.5.0.4 2012-01-10 15:54:38 -05:00
Luke Dashjr
cc19ba76e4 Merge branch '0.4.x' into 0.5.0.x
Conflicts:
	contrib/Bitcoin.app/Contents/Info.plist
	doc/README
	doc/README_windows.txt
	share/setup.nsi
	src/serialize.h
2012-01-10 15:54:25 -05:00
Luke Dashjr
6e1e62a04c Bump version to 0.4.4 2012-01-10 15:50:37 -05:00
Luke Dashjr
9b53650a45 Merge branch '0.5.0.x' into 0.5.x
Conflicts:
	contrib/debian/changelog
2012-01-09 12:15:32 -05:00
Wladimir J. van der Laan
2d8bc0e6da Add "About Qt" menu option to show built-in Qt About dialog
- Most Qt programs do this, and it can be useful to find out what version of Qt was built against.
2012-01-09 12:13:58 -05:00
Wladimir J. van der Laan
21aa161453 make transaction description read-only (UI fix) 2012-01-09 12:10:52 -05:00
Matt Corallo
09308a3882 Remove mentions on anonymity in debian folder.
These should never have been there, bitcoin isnt anonymous without
a ton of work that virtually no users will ever be willing and
capable of doing.
2012-01-09 12:10:16 -05:00
Luke Dashjr
7de7913abd Merge branch '0.5.0.x' into 0.5.x 2012-01-05 18:19:29 -05:00
Luke Dashjr
780a182317 Merge branch '0.4.x' into 0.5.0.x 2012-01-05 18:17:58 -05:00
Matt Corallo
99e9601e80 Fix horrific performance found by gmaxwell. 2012-01-05 12:11:28 -05:00
Wladimir J. van der Laan
45099b19da Fix transaction type in UI: not all tx'es with "from"/"to" field are necessarily IP tx'es
- Also, prepare for OP_EVAL by calling all transactions without bitcoin address "SendToOther"/"RecvFromOther",
 (IP tx'es are so rare they can be put together with funky EV_EVAL scripts)
2012-01-04 01:09:09 -05:00
Luke Dashjr
a2e9767225 Merge branch '0.5.0.x' into 0.5.x 2012-01-03 12:23:09 -05:00
Wladimir J. van der Laan
20e3f2aefc Fix typo (#734) 2012-01-03 12:23:07 -05:00
Luke Dashjr
fb88f1cc97 Fix typo (#734)
Conflicts:

	src/qt/locale/bitcoin_hu.ts
	src/qt/locale/bitcoin_it.ts
	src/qt/locale/bitcoin_pt_BR.ts
	src/qt/locale/bitcoin_uk.ts
	src/qt/locale/bitcoin_zh_CN.ts
2012-01-03 12:21:04 -05:00
Luke Dashjr
eb2a10afd6 Merge branch '0.4.x' into 0.5.0.x
Conflicts:
	src/util.cpp
2012-01-03 12:19:48 -05:00
Gavin Andresen
cc6bd19660 I broke -testnet with my TOR option-parsing fixes. 2012-01-03 12:17:54 -05:00
Gavin Andresen
84393f15b6 Fix issue #659, and cleanup wallet/command-line argument handling a bit
Conflicts:
	src/init.cpp
	src/util.cpp
2012-01-03 11:48:44 -05:00
Pieter Wuille
b52b6f2e38 Fix some address-handling deadlocks
Made three critical blocks for cs_mapAddresses smaller, and moved
writing to the database out of them. This should also improve the
concurrency of the code.
2012-01-02 20:05:58 -05:00
Luke Dashjr
a91a40febd Merge branch '0.5.0.x' into 0.5.x 2011-12-25 09:56:55 -05:00
Luke Dashjr
3b8051864b Be more conservative: check all transactions in blocks after last checkpoint. 2011-12-25 09:26:12 -05:00
Luke Dashjr
961cf14ab3 Merge branch '0.5.0.x' into 0.5.x 2011-12-23 10:09:13 -05:00
Matt Corallo
8632383161 Fix #722. 2011-12-23 10:09:02 -05:00
Luke Dashjr
ab4b52a239 Merge branch '0.4.x' into 0.5.0.x 2011-12-23 10:08:53 -05:00
Dylan Noblesmith
96f1723bb1 Implement an mlock()'d string class for storing passphrases
SecureString is identical to std::string except with secure_allocator
substituting for std::allocator. This makes casting between them
impossible, so converting between the two at API boundaries requires
calling ::c_str() for now.
2011-12-20 18:42:30 -05:00
Luke Dashjr
027d149352 Bugfix: fForRelay should be false when deciding required fee to include in blocks
During the rushed transition from 0.01 BTC to 0.0005 BTC fees, we took the
approach of dropping the relay and block-inclusion fee to 0.0005 BTC
immediately, and only delayed adjusting the sending fee for the next release.
Afterward, the relay fee was lowered to 0.0001 BTC to avoid having the same
problem in the future. However, the block inclusion code was left setting
fForRelay to true! This fixes that, so the lower 0.0001 BTC allowance is (as
intended) only permitted for real relaying.
2011-12-20 17:05:04 -05:00
Luke Dashjr
96c700f5e4 Merge branch '0.5.0.x' into 0.5.x 2011-12-19 16:05:32 -05:00
Luke Dashjr
f503a1486a Merge branch '0.4.x' into 0.5.0.x 2011-12-19 16:05:15 -05:00
Luke Dashjr
987f26aa1a Add my DNS seed domain 2011-12-19 14:38:26 -05:00
Matt Corallo
6be2c9b5b4 Add sipa's new dnsseed. 2011-12-19 14:38:22 -05:00
Luke Dashjr
7aa253d3ec Bump version to 0.5.2 2011-12-16 17:58:40 -05:00
Matt Corallo
9ea0699278 Update debian changelog to 0.5.1. 2011-12-16 17:55:44 -05:00
Luke Dashjr
f1a6d74775 Merge branch '0.5.0.x' into 0.5.x 2011-12-16 17:54:53 -05:00
Luke Dashjr
5fe2dbd7b6 Update debian changelog to 0.5.0.3. 2011-12-16 17:47:50 -05:00
Luke Dashjr
ace5ce05be Bump version to 0.5.0.3 2011-12-15 19:34:37 -05:00
Luke Dashjr
98c0b8b85e Bump version to 0.5.0.2 2011-12-15 19:32:15 -05:00
Luke Dashjr
1f53204045 Bump version to 0.4.3 2011-12-15 19:25:29 -05:00
Matt Corallo
181b863d22 Fix status bar not displaying Alerts. 2011-12-13 16:17:58 -05:00
Wladimir J. van der Laan
142e5056cd Enable wordwrap for long message in passphrase dialog
- Remove explicit resizing from constructor to prevent potential hang
2011-12-13 12:46:58 -05:00
Matt Corallo
9a7f4948c6 Re-enable RPCSSL in gitian builds. 2011-12-12 14:39:49 -05:00
Luke Dashjr
12c69167e3 Merge branch '0.4.x' into 0.5.x 2011-12-12 14:34:47 -05:00
Luke Dashjr
b379bc5eef Merge branch 'restore_old_miniupnp_compat' into 0.4.x 2011-12-12 14:33:47 -05:00
Matt Corallo
16e7c05de7 Move -lgdi32 after -lcrypto (fixes #681). 2011-12-05 11:08:48 -05:00
Matt Corallo
4c519a47a9 Move DNS Seed lookup to a new thread. 2011-12-02 12:56:26 -05:00
Matt Corallo
ba56a88ca5 Move DNS Seed lookup to a new thread. 2011-12-02 12:55:14 -05:00
Luke Dashjr
fe5cc3b7f8 Merge branch '0.4.x' into 0.5.x
(no actual changes)
2011-12-01 23:22:12 -05:00
Gavin Andresen
5d901f1ba0 Orphan block fill-up-memory attack prevention 2011-12-01 23:20:32 -05:00
Gavin Andresen
0e6425da4a Moved checkpoints out of main, to prep for using them to help prevent DoS attacks 2011-12-01 23:12:47 -05:00
Gavin Andresen
f8c3eb9568 Orphan block fill-up-memory attack prevention 2011-12-01 15:48:27 -05:00
Gavin Andresen
d27be1f557 Moved checkpoints out of main, to prep for using them to help prevent DoS attacks 2011-12-01 15:48:20 -05:00
Wladimir J. van der Laan
3741185a51 Make home and addressbook icon more consistent with other toolbar icons (make it blue and flip light source direction) 2011-12-01 03:56:33 -05:00
Gavin Andresen
cba18514c0 Add missing command-line arguments to --help/-? output 2011-12-01 03:55:59 -05:00
Gavin Andresen
a7d735dcc2 Add missing command-line arguments to --help/-? output 2011-12-01 03:55:26 -05:00
Wladimir J. van der Laan
094c35cffc allow for filtering addresses and labels by searching for the typed string anywhere, not just at the beginning (#641) 2011-11-25 09:05:58 -05:00
Luke Dashjr
b683118cd0 Merge branch '0.4.x' into 0.5.x
The only practical change here is updating the gitian URIs to the stable repository.
Otherwise, it just enables merging bugfixes from 0.4.x into 0.5.x properly.

Conflicts:
	contrib/Bitcoin.app/Contents/Info.plist
	doc/README
	doc/README_windows.txt
	doc/release-process.txt
	share/setup.nsi
	src/bitcoinrpc.cpp
	src/headers.h
	src/makefile.unix
	src/serialize.h
	src/ui.cpp
2011-11-24 19:26:52 -05:00
Nils Schneider
1c4be55a99 update translation: de 2011-11-24 19:20:49 -05:00
Alex B
7597fcd92f Small fixes in both spanish translations 2011-11-24 19:20:14 -05:00
Gavin Andresen
adb9f7ddde Don't forget to bump release numbers in READMEs next time 2011-11-21 15:36:15 -05:00
Gavin Andresen
99fe0af2fe Bump version numbers to 0.5.1 2011-11-21 15:36:10 -05:00
Gavin Andresen
45593c271a Don't forget to bump release numbers in READMEs next time 2011-11-21 15:34:20 -05:00
Luke Dashjr
d885aba347 Bump version to 0.4.2 2011-11-21 13:59:38 -05:00
Pieter Wuille
36b1eb7631 close old db when rewriting 2011-11-20 13:53:07 -05:00
Gavin Andresen
76ef6d89b9 Never remove database files on shutdown, it caused unreadable wallets on some testers' machines. 2011-11-20 13:52:59 -05:00
Gavin Andresen
c4a3bf9e55 Only remove database log files on shutdown after wallet encryption/rewrite 2011-11-17 14:29:18 -05:00
Gavin Andresen
90de05e88e Create new keypool for newly encrypted wallets. 2011-11-17 14:29:12 -05:00
Jeff Garzik
2bf36b4e7d Remove vladimir's DNS seed, at his request. 2011-11-15 17:39:38 -05:00
Gavin Andresen
831d24a19d Tweak handling of boost filesystem versions
(partial cherry pick)
2011-11-15 17:00:38 -05:00
Gavin Andresen
1aafd7464f Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite. 2011-11-15 16:59:52 -05:00
Luke Dashjr
586ea168c2 add message about restarting bitcoin after encrypting wallet succesfully 2011-11-15 11:48:41 -05:00
Luke Dashjr
1179f6373d Update gitian descriptors to point at stable git repo 2011-11-15 10:33:26 -05:00
Gavin Andresen
0143c024af Fix boost filesystem incompatibility problem 2011-11-15 10:12:45 -05:00
Gavin Andresen
2744ea8c1f Obsolete keypool and make sure database removes log files on shutdown. 2011-11-15 10:11:53 -05:00
Pieter Wuille
00eae584a2 Resilvering 2011-11-15 10:03:31 -05:00
Matt Corallo
ef4280e08b Add returns to avoid annoying compile-time warnings. 2011-11-02 11:04:13 -04:00
Matt Corallo
ed176ba584 Only define __STDC_LIMIT_MACROS if not already defined. 2011-11-02 11:02:13 -04:00
cjdelisle
38a976d5bb Added a workaround for an Ubuntu bug which causes -fstack-protector-all to be disregarded. 2011-11-02 10:59:48 -04:00
Gavin Andresen
b526cbaa71 bitcoind does not need to link with gthread-2.0 2011-10-10 16:18:58 -04:00
Luke Dashjr
aec5c5fe26 Bump version to 0.4.1 2011-10-10 14:22:31 -04:00
Victor Leschuk
600dc62559 Fix for 64bit build 2011-10-07 11:04:04 -04:00
Luke Dashjr
030d7acf7d Merge commit '65ba3e2f5024e1e38e119a0c25d5fc30c896cd65' into 0.4.x 2011-10-05 11:06:55 -04:00
Wladimir J. van der Laan
20cff2ade4 remove possibility of 63 bit overflow in ParseMoney 2011-10-01 19:04:24 -04:00
Luke Dashjr
7944d81567 Merge commit '3f94dfa' into stable 2011-09-26 15:37:57 -04:00
70 changed files with 919 additions and 497 deletions

2
.gitignore vendored
View File

@@ -1,6 +1,7 @@
src/*.exe
src/bitcoin
src/bitcoind
src/test_bitcoin
src/build.h
.*.swp
*.*~*
@@ -20,3 +21,4 @@ qrc_*.cpp
*.pro.user
#mac specific
.DS_Store
build

View File

@@ -1,8 +1,8 @@
TEMPLATE = app
TARGET =
VERSION = 0.6.1
VERSION = 0.6.3.0
INCLUDEPATH += src src/json src/qt
DEFINES += QT_GUI BOOST_THREAD_USE_LIB
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
CONFIG += no_include_pwd
# for boost 1.37, add -mt to the boost libraries
@@ -83,7 +83,7 @@ contains(BITCOIN_NEED_QT_PLUGINS, 1) {
# regenerate src/build.h
!windows || contains(USE_BUILD_INFO, 1) {
genbuild.depends = FORCE
genbuild.commands = cd $$PWD; share/genbuild.sh $$OUT_PWD/build/build.h
genbuild.commands = cd $$PWD; /bin/sh share/genbuild.sh $$OUT_PWD/build/build.h
genbuild.target = genbuildhook
PRE_TARGETDEPS += genbuildhook
QMAKE_EXTRA_TARGETS += genbuild

View File

@@ -35,7 +35,7 @@ Description: peer-to-peer network based digital currency - daemon
By default connects to an IRC network to discover other peers.
.
Full transaction history is stored locally at each client. This
requires 150+ MB of space, slowly growing.
requires 2+ GB of space, slowly growing.
.
This package provides bitcoind, a combined daemon and CLI tool to
interact with the daemon.
@@ -53,6 +53,6 @@ Description: peer-to-peer network based digital currency - QT GUI
By default connects to an IRC network to discover other peers.
.
Full transaction history is stored locally at each client. This
requires 150+ MB of space, slowly growing.
requires 2+ GB of space, slowly growing.
.
This package provides bitcoin-qt, a GUI for Bitcoin based on QT.

View File

@@ -31,7 +31,7 @@ signers:
weight: 40
name: "Gavin Andresen"
key: gavinandresen
71A3B16735405025D447E8F274810B012346C9A6
71A3B16735405025D447E8F274810B012346C9A6:
weight: 40
name: "Wladimir J. van der Laan"
key: laanwj

View File

@@ -31,7 +31,7 @@ signers:
weight: 40
name: "Gavin Andresen"
key: gavinandresen
71A3B16735405025D447E8F274810B012346C9A6
71A3B16735405025D447E8F274810B012346C9A6:
weight: 40
name: "Wladimir J. van der Laan"
key: laanwj

View File

@@ -1,4 +1,4 @@
Bitcoin 0.6.1 BETA
Bitcoin 0.6.3 BETA
Copyright (c) 2009-2012 Bitcoin Developers
Distributed under the MIT/X11 software license, see the accompanying

View File

@@ -1,4 +1,4 @@
Bitcoin 0.6.1 BETA
Bitcoin 0.6.3 BETA
Copyright (c) 2009-2012 Bitcoin Developers
Distributed under the MIT/X11 software license, see the accompanying

View File

@@ -33,14 +33,14 @@ Dependencies
miniupnpc may be used for UPnP port mapping. It can be downloaded from
http://miniupnp.tuxfamily.org/files/. UPnP support is compiled in and
turned off by default. Set USE_UPNP to a different value to control this:
USE_UPNP= No UPnP support - miniupnp not required
USE_UPNP=- No UPnP support - miniupnp not required
USE_UPNP=0 (the default) UPnP support turned off by default at runtime
USE_UPNP=1 UPnP support turned on by default at runtime
libqrencode may be used for QRCode image generation. It can be downloaded
from http://fukuchi.org/works/qrencode/index.html.en, or installed via
your package manager. Set USE_QRCODE to control this:
USE_QRCODE=0 (the default) No QRCode support - libarcode not required
USE_QRCODE=0 (the default) No QRCode support - libqrcode not required
USE_QRCODE=1 QRCode support enabled
Licenses of statically linked libraries:

View File

@@ -98,6 +98,8 @@
* update wiki download links
* update wiki changelog: https://en.bitcoin.it/wiki/Changelog
* Commit your signature to gitian.sigs:
pushd gitian.sigs
git add ${VERSION}/${SIGNER}

View File

@@ -5,7 +5,7 @@ SetCompressor /SOLID lzma
# General Symbol Definitions
!define REGKEY "SOFTWARE\$(^Name)"
!define VERSION 0.6.1
!define VERSION 0.6.3
!define COMPANY "Bitcoin project"
!define URL http://www.bitcoin.org/
@@ -45,13 +45,13 @@ Var StartMenuGroup
!insertmacro MUI_LANGUAGE English
# Installer attributes
OutFile bitcoin-0.6.1-win32-setup.exe
OutFile bitcoin-0.6.3-win32-setup.exe
InstallDir $PROGRAMFILES\Bitcoin
CRCCheck on
XPStyle on
BrandingText " "
ShowInstDetails show
VIProductVersion 0.6.1.3
VIProductVersion 0.6.3.0
VIAddVersionKey ProductName Bitcoin
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey CompanyName "${COMPANY}"

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2012 Pieter Wuille
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "addrman.h"
@@ -107,9 +107,15 @@ void CAddrMan::SwapRandom(int nRndPos1, int nRndPos2)
if (nRndPos1 == nRndPos2)
return;
assert(nRndPos1 >= 0 && nRndPos2 >= 0);
assert(nRndPos1 < vRandom.size() && nRndPos2 < vRandom.size());
int nId1 = vRandom[nRndPos1];
int nId2 = vRandom[nRndPos2];
assert(mapInfo.count(nId1) == 1);
assert(mapInfo.count(nId2) == 1);
mapInfo[nId1].nRandomPos = nRndPos2;
mapInfo[nId2].nRandomPos = nRndPos1;
@@ -124,26 +130,32 @@ int CAddrMan::SelectTried(int nKBucket)
// random shuffle the first few elements (using the entire list)
// find the least recently tried among them
int64 nOldest = -1;
int nOldestPos = -1;
for (unsigned int i = 0; i < ADDRMAN_TRIED_ENTRIES_INSPECT_ON_EVICT && i < vTried.size(); i++)
{
int nPos = GetRandInt(vTried.size() - i) + i;
int nTemp = vTried[nPos];
vTried[nPos] = vTried[i];
vTried[i] = nTemp;
if (nOldest == -1 || mapInfo[nTemp].nLastSuccess < mapInfo[nOldest].nLastSuccess)
assert(nOldest == -1 || mapInfo.count(nTemp) == 1);
if (nOldest == -1 || mapInfo[nTemp].nLastSuccess < mapInfo[nOldest].nLastSuccess) {
nOldest = nTemp;
nOldestPos = nPos;
}
}
return nOldest;
return nOldestPos;
}
int CAddrMan::ShrinkNew(int nUBucket)
{
assert(nUBucket >= 0 && nUBucket < vvNew.size());
std::set<int> &vNew = vvNew[nUBucket];
// first look for deletable items
for (std::set<int>::iterator it = vNew.begin(); it != vNew.end(); it++)
{
assert(mapInfo.count(*it));
CAddrInfo &info = mapInfo[*it];
if (info.IsTerrible())
{
@@ -168,11 +180,13 @@ int CAddrMan::ShrinkNew(int nUBucket)
{
if (nI == n[0] || nI == n[1] || nI == n[2] || nI == n[3])
{
assert(nOldest == -1 || mapInfo.count(*it) == 1);
if (nOldest == -1 || mapInfo[*it].nTime < mapInfo[nOldest].nTime)
nOldest = *it;
}
nI++;
}
assert(mapInfo.count(nOldest) == 1);
CAddrInfo &info = mapInfo[nOldest];
if (--info.nRefCount == 0)
{
@@ -189,6 +203,8 @@ int CAddrMan::ShrinkNew(int nUBucket)
void CAddrMan::MakeTried(CAddrInfo& info, int nId, int nOrigin)
{
assert(vvNew[nOrigin].count(nId) == 1);
// remove the entry from all new buckets
for (std::vector<std::set<int> >::iterator it = vvNew.begin(); it != vvNew.end(); it++)
{
@@ -197,6 +213,8 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId, int nOrigin)
}
nNew--;
assert(info.nRefCount == 0);
// what tried bucket to move the entry to
int nKBucket = info.GetTriedBucket(nKey);
std::vector<int> &vTried = vvTried[nKBucket];
@@ -214,6 +232,7 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId, int nOrigin)
int nPos = SelectTried(nKBucket);
// find which new bucket it belongs to
assert(mapInfo.count(vTried[nPos]) == 1);
int nUBucket = mapInfo[vTried[nPos]].GetNewBucket(nKey);
std::set<int> &vNew = vvNew[nUBucket];
@@ -385,6 +404,7 @@ CAddress CAddrMan::Select_(int nUnkBias)
std::vector<int> &vTried = vvTried[nKBucket];
if (vTried.size() == 0) continue;
int nPos = GetRandInt(vTried.size());
assert(mapInfo.count(vTried[nPos]) == 1);
CAddrInfo &info = mapInfo[vTried[nPos]];
if (GetRandInt(1<<30) < fChanceFactor*info.GetChance()*(1<<30))
return info;
@@ -402,6 +422,7 @@ CAddress CAddrMan::Select_(int nUnkBias)
std::set<int>::iterator it = vNew.begin();
while (nPos--)
it++;
assert(mapInfo.count(*it) == 1);
CAddrInfo &info = mapInfo[*it];
if (GetRandInt(1<<30) < fChanceFactor*info.GetChance()*(1<<30))
return info;
@@ -481,6 +502,7 @@ void CAddrMan::GetAddr_(std::vector<CAddress> &vAddr)
{
int nRndPos = GetRandInt(vRandom.size() - n) + n;
SwapRandom(n, nRndPos);
assert(mapInfo.count(vRandom[n]) == 1);
vAddr.push_back(mapInfo[vRandom[n]]);
}
}

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2012 Pieter Wuille
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef _BITCOIN_ADDRMAN
#define _BITCOIN_ADDRMAN 1
@@ -62,7 +62,7 @@ public:
nRandomPos = -1;
}
CAddrInfo(const CAddress &addrIn, const CNetAddr &addrSource) : CAddress(addrIn)
CAddrInfo(const CAddress &addrIn, const CNetAddr &addrSource) : CAddress(addrIn), source(addrSource)
{
Init();
}

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_ALLOCATORS_H
#define BITCOIN_ALLOCATORS_H
@@ -117,7 +117,6 @@ struct zero_after_free_allocator : public std::allocator<T>
};
// This is exactly like std::string, but with a custom allocator.
// (secure_allocator<> is defined in serialize.h)
typedef std::basic_string<char, std::char_traits<char>, secure_allocator<char> > SecureString;
#endif

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin Developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
//

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_BIGNUM_H
#define BITCOIN_BIGNUM_H

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "main.h"
#include "wallet.h"
@@ -225,7 +225,7 @@ Value stop(const Array& params, bool fHelp)
"stop\n"
"Stop bitcoin server.");
// Shutdown will take long enough that the response should get back
QueueShutdown();
StartShutdown();
return "bitcoin server stopping";
}
@@ -839,7 +839,8 @@ Value movecmd(const Array& params, bool fHelp)
strComment = params[4].get_str();
CWalletDB walletdb(pwalletMain->strWalletFile);
walletdb.TxnBegin();
if (!walletdb.TxnBegin())
throw JSONRPCError(-20, "database error");
int64 nNow = GetAdjustedTime();
@@ -861,7 +862,8 @@ Value movecmd(const Array& params, bool fHelp)
credit.strComment = strComment;
walletdb.WriteAccountingEntry(credit);
walletdb.TxnCommit();
if (!walletdb.TxnCommit())
throw JSONRPCError(-20, "database error");
return true;
}
@@ -999,10 +1001,12 @@ Value addmultisigaddress(const Array& params, bool fHelp)
strAccount = AccountFromValue(params[2]);
// Gather public keys
if ((nRequired < 1) || ((int)keys.size() < nRequired))
if (nRequired < 1)
throw runtime_error("a multisignature address must require at least one key to redeem");
if ((int)keys.size() < nRequired)
throw runtime_error(
strprintf("wrong number of keys"
"(got %d, need at least %d)", keys.size(), nRequired));
strprintf("not enough keys supplied "
"(got %d keys, but need at least %d to redeem)", keys.size(), nRequired));
std::vector<CKey> pubkeys;
pubkeys.resize(keys.size());
for (unsigned int i = 0; i < keys.size(); i++)
@@ -1703,7 +1707,7 @@ Value encryptwallet(const Array& params, bool fHelp)
// BDB seems to have a bad habit of writing old data into
// slack space in .dat files; that is bad if the old data is
// unencrypted private keys. So:
QueueShutdown();
StartShutdown();
return "wallet encrypted; bitcoin server stopping, restart to run with encrypted wallet";
}
@@ -2376,7 +2380,7 @@ void ThreadRPCServer2(void* parg)
GetConfigFile().string().c_str(),
EncodeBase58(&rand_pwd[0],&rand_pwd[0]+32).c_str()),
_("Error"), wxOK | wxMODAL);
QueueShutdown();
StartShutdown();
return;
}
@@ -2397,7 +2401,7 @@ void ThreadRPCServer2(void* parg)
{
ThreadSafeMessageBox(strprintf(_("An error occured while setting up the RPC port %i for listening: %s"), endpoint.port(), e.what()),
_("Error"), wxOK | wxMODAL);
QueueShutdown();
StartShutdown();
return;
}

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef _BITCOINRPC_H_
#define _BITCOINRPC_H_ 1

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <boost/assign/list_of.hpp> // for 'map_list_of()'
#include <boost/foreach.hpp>
@@ -25,14 +25,11 @@ namespace Checkpoints
boost::assign::map_list_of
( 11111, uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"))
( 33333, uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6"))
( 68555, uint256("0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a"))
( 70567, uint256("0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a"))
( 74000, uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20"))
(105000, uint256("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97"))
(118000, uint256("0x000000000000774a7f8a7a12dc906ddb9e17e75d684f15e00f8767f9e8f36553"))
(134444, uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe"))
(140700, uint256("0x000000000000033b512028abb90e1626d8b346fd0ed598ac0a3c371138dce2bd"))
(168000, uint256("0x000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763"))
(185333, uint256("0x00000000000002334c71b8706940c20348af897a9cfc0f1a6dab0d14d4ceb815"))
;
bool CheckBlock(int nHeight, const uint256& hash)

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_CHECKPOINT_H
#define BITCOIN_CHECKPOINT_H

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef _BITCOIN_COMPAT_H
#define _BITCOIN_COMPAT_H 1

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "db.h"
#include "util.h"
@@ -96,6 +96,7 @@ CDB::CDB(const char *pszFile, const char* pszMode) : pdb(NULL)
dbenv.set_lk_max_locks(10000);
dbenv.set_lk_max_objects(10000);
dbenv.set_errfile(fopen(pathErrorFile.string().c_str(), "a")); /// debug
dbenv.set_flags(DB_TXN_WRITE_NOSYNC, 1);
dbenv.set_flags(DB_AUTO_COMMIT, 1);
dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1);
ret = dbenv.open(pathDataDir.string().c_str(),
@@ -410,9 +411,15 @@ bool CTxDB::ReadOwnerTxes(uint160 hash160, int nMinHeight, vector<CTransaction>&
string strType;
uint160 hashItem;
CDiskTxPos pos;
ssKey >> strType >> hashItem >> pos;
int nItemHeight;
ssValue >> nItemHeight;
try {
ssKey >> strType >> hashItem >> pos;
ssValue >> nItemHeight;
}
catch (std::exception &e) {
return error("%s() : deserialize error", __PRETTY_FUNCTION__);
}
// Read transaction
if (strType != "owner" || hashItem != hash160)
@@ -532,6 +539,8 @@ bool CTxDB::LoadBlockIndex()
return false;
// Unserialize
try {
string strType;
ssKey >> strType;
if (strType == "blockindex" && !fRequestShutdown)
@@ -563,6 +572,10 @@ bool CTxDB::LoadBlockIndex()
{
break; // if shutdown requested or finished loading block index
}
} // try
catch (std::exception &e) {
return error("%s() : deserialize error", __PRETTY_FUNCTION__);
}
}
pcursor->close();

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_DB_H
#define BITCOIN_DB_H
@@ -72,8 +72,13 @@ protected:
return false;
// Unserialize value
CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK, CLIENT_VERSION);
ssValue >> value;
try {
CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK, CLIENT_VERSION);
ssValue >> value;
}
catch (std::exception &e) {
return false;
}
// Clear and free memory
memset(datValue.get_data(), 0, datValue.get_size());
@@ -216,7 +221,7 @@ public:
if (!pdb)
return false;
DbTxn* ptxn = NULL;
int ret = dbenv.txn_begin(GetTxn(), &ptxn, DB_TXN_NOSYNC);
int ret = dbenv.txn_begin(GetTxn(), &ptxn, DB_TXN_WRITE_NOSYNC);
if (!ptxn || ret != 0)
return false;
vTxn.push_back(ptxn);

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "db.h"
#include "walletdb.h"
#include "bitcoinrpc.h"
@@ -36,6 +36,17 @@ void ExitTimeout(void* parg)
#endif
}
void StartShutdown()
{
#ifdef QT_GUI
// ensure we leave the Qt main loop for a clean GUI exit (Shutdown() is called in bitcoin.cpp afterwards)
QueueShutdown();
#else
// Without UI, Shutdown() can simply be started in a new thread
CreateThread(Shutdown, NULL);
#endif
}
void Shutdown(void* parg)
{
static CCriticalSection cs_Shutdown;
@@ -64,7 +75,10 @@ void Shutdown(void* parg)
Sleep(50);
printf("Bitcoin exiting\n\n");
fExit = true;
#ifndef QT_GUI
// ensure non UI client get's exited here, but let Bitcoin-Qt reach return 0; in bitcoin.cpp
exit(0);
#endif
}
else
{

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_INIT_H
#define BITCOIN_INIT_H
@@ -9,11 +9,9 @@
extern CWallet* pwalletMain;
void StartShutdown();
void Shutdown(void* parg);
bool AppInit(int argc, char* argv[]);
bool AppInit2(int argc, char* argv[]);
bool GetStartOnSystemStartup();
bool SetStartOnSystemStartup(bool fAutoStart);
#endif

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "irc.h"
#include "net.h"

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_IRC_H
#define BITCOIN_IRC_H

View File

@@ -1,9 +1,14 @@
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <map>
#include <openssl/ec.h>
#include <openssl/ecdsa.h>
#include <openssl/obj_mac.h>
#include "key.h"
#include "util.h"
// Generate a private key from just the secret parameter
int EC_KEY_regenerate_key(EC_KEY *eckey, BIGNUM *priv_key)
@@ -115,3 +120,264 @@ err:
if (Q != NULL) EC_POINT_free(Q);
return ret;
}
void CKey::SetCompressedPubKey()
{
EC_KEY_set_conv_form(pkey, POINT_CONVERSION_COMPRESSED);
fCompressedPubKey = true;
}
void CKey::Reset()
{
fCompressedPubKey = false;
pkey = EC_KEY_new_by_curve_name(NID_secp256k1);
if (pkey == NULL)
throw key_error("CKey::CKey() : EC_KEY_new_by_curve_name failed");
fSet = false;
}
CKey::CKey()
{
Reset();
}
CKey::CKey(const CKey& b)
{
pkey = EC_KEY_dup(b.pkey);
if (pkey == NULL)
throw key_error("CKey::CKey(const CKey&) : EC_KEY_dup failed");
fSet = b.fSet;
}
CKey& CKey::operator=(const CKey& b)
{
if (!EC_KEY_copy(pkey, b.pkey))
throw key_error("CKey::operator=(const CKey&) : EC_KEY_copy failed");
fSet = b.fSet;
return (*this);
}
CKey::~CKey()
{
EC_KEY_free(pkey);
}
bool CKey::IsNull() const
{
return !fSet;
}
bool CKey::IsCompressed() const
{
return fCompressedPubKey;
}
void CKey::MakeNewKey(bool fCompressed)
{
if (!EC_KEY_generate_key(pkey))
throw key_error("CKey::MakeNewKey() : EC_KEY_generate_key failed");
if (fCompressed)
SetCompressedPubKey();
fSet = true;
}
bool CKey::SetPrivKey(const CPrivKey& vchPrivKey)
{
const unsigned char* pbegin = &vchPrivKey[0];
if (!d2i_ECPrivateKey(&pkey, &pbegin, vchPrivKey.size()))
return false;
fSet = true;
return true;
}
bool CKey::SetSecret(const CSecret& vchSecret, bool fCompressed)
{
EC_KEY_free(pkey);
pkey = EC_KEY_new_by_curve_name(NID_secp256k1);
if (pkey == NULL)
throw key_error("CKey::SetSecret() : EC_KEY_new_by_curve_name failed");
if (vchSecret.size() != 32)
throw key_error("CKey::SetSecret() : secret must be 32 bytes");
BIGNUM *bn = BN_bin2bn(&vchSecret[0],32,BN_new());
if (bn == NULL)
throw key_error("CKey::SetSecret() : BN_bin2bn failed");
if (!EC_KEY_regenerate_key(pkey,bn))
{
BN_clear_free(bn);
throw key_error("CKey::SetSecret() : EC_KEY_regenerate_key failed");
}
BN_clear_free(bn);
fSet = true;
if (fCompressed || fCompressedPubKey)
SetCompressedPubKey();
return true;
}
CSecret CKey::GetSecret(bool &fCompressed) const
{
CSecret vchRet;
vchRet.resize(32);
const BIGNUM *bn = EC_KEY_get0_private_key(pkey);
int nBytes = BN_num_bytes(bn);
if (bn == NULL)
throw key_error("CKey::GetSecret() : EC_KEY_get0_private_key failed");
int n=BN_bn2bin(bn,&vchRet[32 - nBytes]);
if (n != nBytes)
throw key_error("CKey::GetSecret(): BN_bn2bin failed");
fCompressed = fCompressedPubKey;
return vchRet;
}
CPrivKey CKey::GetPrivKey() const
{
int nSize = i2d_ECPrivateKey(pkey, NULL);
if (!nSize)
throw key_error("CKey::GetPrivKey() : i2d_ECPrivateKey failed");
CPrivKey vchPrivKey(nSize, 0);
unsigned char* pbegin = &vchPrivKey[0];
if (i2d_ECPrivateKey(pkey, &pbegin) != nSize)
throw key_error("CKey::GetPrivKey() : i2d_ECPrivateKey returned unexpected size");
return vchPrivKey;
}
bool CKey::SetPubKey(const std::vector<unsigned char>& vchPubKey)
{
const unsigned char* pbegin = &vchPubKey[0];
if (!o2i_ECPublicKey(&pkey, &pbegin, vchPubKey.size()))
return false;
fSet = true;
if (vchPubKey.size() == 33)
SetCompressedPubKey();
return true;
}
std::vector<unsigned char> CKey::GetPubKey() const
{
int nSize = i2o_ECPublicKey(pkey, NULL);
if (!nSize)
throw key_error("CKey::GetPubKey() : i2o_ECPublicKey failed");
std::vector<unsigned char> vchPubKey(nSize, 0);
unsigned char* pbegin = &vchPubKey[0];
if (i2o_ECPublicKey(pkey, &pbegin) != nSize)
throw key_error("CKey::GetPubKey() : i2o_ECPublicKey returned unexpected size");
return vchPubKey;
}
bool CKey::Sign(uint256 hash, std::vector<unsigned char>& vchSig)
{
unsigned int nSize = ECDSA_size(pkey);
vchSig.resize(nSize); // Make sure it is big enough
if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], &nSize, pkey))
{
vchSig.clear();
return false;
}
vchSig.resize(nSize); // Shrink to fit actual size
return true;
}
// create a compact signature (65 bytes), which allows reconstructing the used public key
// The format is one header byte, followed by two times 32 bytes for the serialized r and s values.
// The header byte: 0x1B = first key with even y, 0x1C = first key with odd y,
// 0x1D = second key with even y, 0x1E = second key with odd y
bool CKey::SignCompact(uint256 hash, std::vector<unsigned char>& vchSig)
{
bool fOk = false;
ECDSA_SIG *sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey);
if (sig==NULL)
return false;
vchSig.clear();
vchSig.resize(65,0);
int nBitsR = BN_num_bits(sig->r);
int nBitsS = BN_num_bits(sig->s);
if (nBitsR <= 256 && nBitsS <= 256)
{
int nRecId = -1;
for (int i=0; i<4; i++)
{
CKey keyRec;
keyRec.fSet = true;
if (fCompressedPubKey)
keyRec.SetCompressedPubKey();
if (ECDSA_SIG_recover_key_GFp(keyRec.pkey, sig, (unsigned char*)&hash, sizeof(hash), i, 1) == 1)
if (keyRec.GetPubKey() == this->GetPubKey())
{
nRecId = i;
break;
}
}
if (nRecId == -1)
throw key_error("CKey::SignCompact() : unable to construct recoverable key");
vchSig[0] = nRecId+27+(fCompressedPubKey ? 4 : 0);
BN_bn2bin(sig->r,&vchSig[33-(nBitsR+7)/8]);
BN_bn2bin(sig->s,&vchSig[65-(nBitsS+7)/8]);
fOk = true;
}
ECDSA_SIG_free(sig);
return fOk;
}
// reconstruct public key from a compact signature
// This is only slightly more CPU intensive than just verifying it.
// If this function succeeds, the recovered public key is guaranteed to be valid
// (the signature is a valid signature of the given data for that key)
bool CKey::SetCompactSignature(uint256 hash, const std::vector<unsigned char>& vchSig)
{
if (vchSig.size() != 65)
return false;
int nV = vchSig[0];
if (nV<27 || nV>=35)
return false;
ECDSA_SIG *sig = ECDSA_SIG_new();
BN_bin2bn(&vchSig[1],32,sig->r);
BN_bin2bn(&vchSig[33],32,sig->s);
EC_KEY_free(pkey);
pkey = EC_KEY_new_by_curve_name(NID_secp256k1);
if (nV >= 31)
{
SetCompressedPubKey();
nV -= 4;
}
if (ECDSA_SIG_recover_key_GFp(pkey, sig, (unsigned char*)&hash, sizeof(hash), nV - 27, 0) == 1)
{
fSet = true;
ECDSA_SIG_free(sig);
return true;
}
return false;
}
bool CKey::Verify(uint256 hash, const std::vector<unsigned char>& vchSig)
{
// -1 = error, 0 = bad sig, 1 = good
if (ECDSA_verify(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], vchSig.size(), pkey) != 1)
return false;
return true;
}
bool CKey::VerifyCompact(uint256 hash, const std::vector<unsigned char>& vchSig)
{
CKey key;
if (!key.SetCompactSignature(hash, vchSig))
return false;
if (GetPubKey() != key.GetPubKey())
return false;
return true;
}
bool CKey::IsValid()
{
if (!fSet)
return false;
bool fCompr;
CSecret secret = GetSecret(fCompr);
CKey key2;
key2.SetSecret(secret, fCompr);
return GetPubKey() == key2.GetPubKey();
}

270
src/key.h
View File

@@ -1,20 +1,18 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_KEY_H
#define BITCOIN_KEY_H
#include <stdexcept>
#include <vector>
#include <openssl/ec.h>
#include <openssl/ecdsa.h>
#include <openssl/obj_mac.h>
#include "allocators.h"
#include "uint256.h"
#include <openssl/ec.h> // for EC_KEY definition
// secp160k1
// const unsigned int PRIVATE_KEY_SIZE = 192;
// const unsigned int PUBLIC_KEY_SIZE = 41;
@@ -38,9 +36,6 @@
// see www.keylength.com
// script supports up to 75 for single byte push
int extern EC_KEY_regenerate_key(EC_KEY *eckey, BIGNUM *priv_key);
int extern ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned char *msg, int msglen, int recid, int check);
class key_error : public std::runtime_error
{
public:
@@ -62,267 +57,50 @@ protected:
bool fSet;
bool fCompressedPubKey;
void SetCompressedPubKey()
{
EC_KEY_set_conv_form(pkey, POINT_CONVERSION_COMPRESSED);
fCompressedPubKey = true;
}
void SetCompressedPubKey();
public:
void Reset()
{
fCompressedPubKey = false;
pkey = EC_KEY_new_by_curve_name(NID_secp256k1);
if (pkey == NULL)
throw key_error("CKey::CKey() : EC_KEY_new_by_curve_name failed");
fSet = false;
}
void Reset();
CKey()
{
Reset();
}
CKey();
CKey(const CKey& b);
CKey(const CKey& b)
{
pkey = EC_KEY_dup(b.pkey);
if (pkey == NULL)
throw key_error("CKey::CKey(const CKey&) : EC_KEY_dup failed");
fSet = b.fSet;
}
CKey& operator=(const CKey& b);
CKey& operator=(const CKey& b)
{
if (!EC_KEY_copy(pkey, b.pkey))
throw key_error("CKey::operator=(const CKey&) : EC_KEY_copy failed");
fSet = b.fSet;
return (*this);
}
~CKey();
~CKey()
{
EC_KEY_free(pkey);
}
bool IsNull() const;
bool IsCompressed() const;
bool IsNull() const
{
return !fSet;
}
void MakeNewKey(bool fCompressed);
bool SetPrivKey(const CPrivKey& vchPrivKey);
bool SetSecret(const CSecret& vchSecret, bool fCompressed = false);
CSecret GetSecret(bool &fCompressed) const;
CPrivKey GetPrivKey() const;
bool SetPubKey(const std::vector<unsigned char>& vchPubKey);
std::vector<unsigned char> GetPubKey() const;
bool IsCompressed() const
{
return fCompressedPubKey;
}
void MakeNewKey(bool fCompressed)
{
if (!EC_KEY_generate_key(pkey))
throw key_error("CKey::MakeNewKey() : EC_KEY_generate_key failed");
if (fCompressed)
SetCompressedPubKey();
fSet = true;
}
bool SetPrivKey(const CPrivKey& vchPrivKey)
{
const unsigned char* pbegin = &vchPrivKey[0];
if (!d2i_ECPrivateKey(&pkey, &pbegin, vchPrivKey.size()))
return false;
fSet = true;
return true;
}
bool SetSecret(const CSecret& vchSecret, bool fCompressed = false)
{
EC_KEY_free(pkey);
pkey = EC_KEY_new_by_curve_name(NID_secp256k1);
if (pkey == NULL)
throw key_error("CKey::SetSecret() : EC_KEY_new_by_curve_name failed");
if (vchSecret.size() != 32)
throw key_error("CKey::SetSecret() : secret must be 32 bytes");
BIGNUM *bn = BN_bin2bn(&vchSecret[0],32,BN_new());
if (bn == NULL)
throw key_error("CKey::SetSecret() : BN_bin2bn failed");
if (!EC_KEY_regenerate_key(pkey,bn))
{
BN_clear_free(bn);
throw key_error("CKey::SetSecret() : EC_KEY_regenerate_key failed");
}
BN_clear_free(bn);
fSet = true;
if (fCompressed || fCompressedPubKey)
SetCompressedPubKey();
return true;
}
CSecret GetSecret(bool &fCompressed) const
{
CSecret vchRet;
vchRet.resize(32);
const BIGNUM *bn = EC_KEY_get0_private_key(pkey);
int nBytes = BN_num_bytes(bn);
if (bn == NULL)
throw key_error("CKey::GetSecret() : EC_KEY_get0_private_key failed");
int n=BN_bn2bin(bn,&vchRet[32 - nBytes]);
if (n != nBytes)
throw key_error("CKey::GetSecret(): BN_bn2bin failed");
fCompressed = fCompressedPubKey;
return vchRet;
}
CPrivKey GetPrivKey() const
{
int nSize = i2d_ECPrivateKey(pkey, NULL);
if (!nSize)
throw key_error("CKey::GetPrivKey() : i2d_ECPrivateKey failed");
CPrivKey vchPrivKey(nSize, 0);
unsigned char* pbegin = &vchPrivKey[0];
if (i2d_ECPrivateKey(pkey, &pbegin) != nSize)
throw key_error("CKey::GetPrivKey() : i2d_ECPrivateKey returned unexpected size");
return vchPrivKey;
}
bool SetPubKey(const std::vector<unsigned char>& vchPubKey)
{
const unsigned char* pbegin = &vchPubKey[0];
if (!o2i_ECPublicKey(&pkey, &pbegin, vchPubKey.size()))
return false;
fSet = true;
if (vchPubKey.size() == 33)
SetCompressedPubKey();
return true;
}
std::vector<unsigned char> GetPubKey() const
{
int nSize = i2o_ECPublicKey(pkey, NULL);
if (!nSize)
throw key_error("CKey::GetPubKey() : i2o_ECPublicKey failed");
std::vector<unsigned char> vchPubKey(nSize, 0);
unsigned char* pbegin = &vchPubKey[0];
if (i2o_ECPublicKey(pkey, &pbegin) != nSize)
throw key_error("CKey::GetPubKey() : i2o_ECPublicKey returned unexpected size");
return vchPubKey;
}
bool Sign(uint256 hash, std::vector<unsigned char>& vchSig)
{
unsigned int nSize = ECDSA_size(pkey);
vchSig.resize(nSize); // Make sure it is big enough
if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], &nSize, pkey))
{
vchSig.clear();
return false;
}
vchSig.resize(nSize); // Shrink to fit actual size
return true;
}
bool Sign(uint256 hash, std::vector<unsigned char>& vchSig);
// create a compact signature (65 bytes), which allows reconstructing the used public key
// The format is one header byte, followed by two times 32 bytes for the serialized r and s values.
// The header byte: 0x1B = first key with even y, 0x1C = first key with odd y,
// 0x1D = second key with even y, 0x1E = second key with odd y
bool SignCompact(uint256 hash, std::vector<unsigned char>& vchSig)
{
bool fOk = false;
ECDSA_SIG *sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey);
if (sig==NULL)
return false;
vchSig.clear();
vchSig.resize(65,0);
int nBitsR = BN_num_bits(sig->r);
int nBitsS = BN_num_bits(sig->s);
if (nBitsR <= 256 && nBitsS <= 256)
{
int nRecId = -1;
for (int i=0; i<4; i++)
{
CKey keyRec;
keyRec.fSet = true;
if (fCompressedPubKey)
keyRec.SetCompressedPubKey();
if (ECDSA_SIG_recover_key_GFp(keyRec.pkey, sig, (unsigned char*)&hash, sizeof(hash), i, 1) == 1)
if (keyRec.GetPubKey() == this->GetPubKey())
{
nRecId = i;
break;
}
}
if (nRecId == -1)
throw key_error("CKey::SignCompact() : unable to construct recoverable key");
vchSig[0] = nRecId+27+(fCompressedPubKey ? 4 : 0);
BN_bn2bin(sig->r,&vchSig[33-(nBitsR+7)/8]);
BN_bn2bin(sig->s,&vchSig[65-(nBitsS+7)/8]);
fOk = true;
}
ECDSA_SIG_free(sig);
return fOk;
}
bool SignCompact(uint256 hash, std::vector<unsigned char>& vchSig);
// reconstruct public key from a compact signature
// This is only slightly more CPU intensive than just verifying it.
// If this function succeeds, the recovered public key is guaranteed to be valid
// (the signature is a valid signature of the given data for that key)
bool SetCompactSignature(uint256 hash, const std::vector<unsigned char>& vchSig)
{
if (vchSig.size() != 65)
return false;
int nV = vchSig[0];
if (nV<27 || nV>=35)
return false;
ECDSA_SIG *sig = ECDSA_SIG_new();
BN_bin2bn(&vchSig[1],32,sig->r);
BN_bin2bn(&vchSig[33],32,sig->s);
bool SetCompactSignature(uint256 hash, const std::vector<unsigned char>& vchSig);
EC_KEY_free(pkey);
pkey = EC_KEY_new_by_curve_name(NID_secp256k1);
if (nV >= 31)
{
SetCompressedPubKey();
nV -= 4;
}
if (ECDSA_SIG_recover_key_GFp(pkey, sig, (unsigned char*)&hash, sizeof(hash), nV - 27, 0) == 1)
{
fSet = true;
ECDSA_SIG_free(sig);
return true;
}
return false;
}
bool Verify(uint256 hash, const std::vector<unsigned char>& vchSig)
{
// -1 = error, 0 = bad sig, 1 = good
if (ECDSA_verify(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], vchSig.size(), pkey) != 1)
return false;
return true;
}
bool Verify(uint256 hash, const std::vector<unsigned char>& vchSig);
// Verify a compact signature
bool VerifyCompact(uint256 hash, const std::vector<unsigned char>& vchSig)
{
CKey key;
if (!key.SetCompactSignature(hash, vchSig))
return false;
if (GetPubKey() != key.GetPubKey())
return false;
return true;
}
bool VerifyCompact(uint256 hash, const std::vector<unsigned char>& vchSig);
bool IsValid()
{
if (!fSet)
return false;
bool fCompr;
CSecret secret = GetSecret(fCompr);
CKey key2;
key2.SetSecret(secret, fCompr);
return GetPubKey() == key2.GetPubKey();
}
bool IsValid();
};
#endif

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "keystore.h"
#include "script.h"

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_KEYSTORE_H
#define BITCOIN_KEYSTORE_H

View File

@@ -1,7 +1,8 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "checkpoints.h"
#include "db.h"
#include "net.h"
@@ -43,7 +44,7 @@ map<uint256, CBlock*> mapOrphanBlocks;
multimap<uint256, CBlock*> mapOrphanBlocksByPrev;
map<uint256, CDataStream*> mapOrphanTransactions;
multimap<uint256, CDataStream*> mapOrphanTransactionsByPrev;
map<uint256, map<uint256, CDataStream*> > mapOrphanTransactionsByPrev;
// Constant stuff for coinbase transactions we create:
CScript COINBASE_FLAGS;
@@ -160,17 +161,37 @@ void static ResendWalletTransactions()
// mapOrphanTransactions
//
void AddOrphanTx(const CDataStream& vMsg)
bool AddOrphanTx(const CDataStream& vMsg)
{
CTransaction tx;
CDataStream(vMsg) >> tx;
uint256 hash = tx.GetHash();
if (mapOrphanTransactions.count(hash))
return;
return false;
CDataStream* pvMsg = mapOrphanTransactions[hash] = new CDataStream(vMsg);
CDataStream* pvMsg = new CDataStream(vMsg);
// Ignore big transactions, to avoid a
// send-big-orphans memory exhaustion attack. If a peer has a legitimate
// large transaction with a missing parent then we assume
// it will rebroadcast it later, after the parent transaction(s)
// have been mined or received.
// 10,000 orphans, each of which is at most 5,000 bytes big is
// at most 500 megabytes of orphans:
if (pvMsg->size() > 5000)
{
printf("ignoring large orphan tx (size: %u, hash: %s)\n", pvMsg->size(), hash.ToString().substr(0,10).c_str());
delete pvMsg;
return false;
}
mapOrphanTransactions[hash] = pvMsg;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
mapOrphanTransactionsByPrev.insert(make_pair(txin.prevout.hash, pvMsg));
mapOrphanTransactionsByPrev[txin.prevout.hash].insert(make_pair(hash, pvMsg));
printf("stored orphan tx %s (mapsz %u)\n", hash.ToString().substr(0,10).c_str(),
mapOrphanTransactions.size());
return true;
}
void static EraseOrphanTx(uint256 hash)
@@ -182,14 +203,9 @@ void static EraseOrphanTx(uint256 hash)
CDataStream(*pvMsg) >> tx;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
for (multimap<uint256, CDataStream*>::iterator mi = mapOrphanTransactionsByPrev.lower_bound(txin.prevout.hash);
mi != mapOrphanTransactionsByPrev.upper_bound(txin.prevout.hash);)
{
if ((*mi).second == pvMsg)
mapOrphanTransactionsByPrev.erase(mi++);
else
mi++;
}
mapOrphanTransactionsByPrev[txin.prevout.hash].erase(hash);
if (mapOrphanTransactionsByPrev[txin.prevout.hash].empty())
mapOrphanTransactionsByPrev.erase(txin.prevout.hash);
}
delete pvMsg;
mapOrphanTransactions.erase(hash);
@@ -201,9 +217,7 @@ unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans)
while (mapOrphanTransactions.size() > nMaxOrphans)
{
// Evict a random orphan:
std::vector<unsigned char> randbytes(32);
RAND_bytes(&randbytes[0], 32);
uint256 randomhash(randbytes);
uint256 randomhash = GetRandHash();
map<uint256, CDataStream*>::iterator it = mapOrphanTransactions.lower_bound(randomhash);
if (it == mapOrphanTransactions.end())
it = mapOrphanTransactions.begin();
@@ -718,7 +732,7 @@ bool CWalletTx::AcceptWalletTransaction(CTxDB& txdb, bool fCheckInputs)
return false;
}
bool CWalletTx::AcceptWalletTransaction()
bool CWalletTx::AcceptWalletTransaction()
{
CTxDB txdb("r");
return AcceptWalletTransaction(txdb);
@@ -1129,17 +1143,28 @@ bool CTransaction::ConnectInputs(MapPrevTx inputs,
if (pindex->nBlockPos == txindex.pos.nBlockPos && pindex->nFile == txindex.pos.nFile)
return error("ConnectInputs() : tried to spend coinbase at depth %d", pindexBlock->nHeight - pindex->nHeight);
// Check for negative or overflow input values
nValueIn += txPrev.vout[prevout.n].nValue;
if (!MoneyRange(txPrev.vout[prevout.n].nValue) || !MoneyRange(nValueIn))
return DoS(100, error("ConnectInputs() : txin values out of range"));
}
// The first loop above does all the inexpensive checks.
// Only if ALL inputs pass do we perform expensive ECDSA signature checks.
// Helps prevent CPU exhaustion attacks.
for (unsigned int i = 0; i < vin.size(); i++)
{
COutPoint prevout = vin[i].prevout;
assert(inputs.count(prevout.hash) > 0);
CTxIndex& txindex = inputs[prevout.hash].first;
CTransaction& txPrev = inputs[prevout.hash].second;
// Check for conflicts (double-spend)
// This doesn't trigger the DoS code on purpose; if it did, it would make it easier
// for an attacker to attempt to split the network.
if (!txindex.vSpent[prevout.n].IsNull())
return fMiner ? false : error("ConnectInputs() : %s prev tx already used at %s", GetHash().ToString().substr(0,10).c_str(), txindex.vSpent[prevout.n].ToString().c_str());
// Check for negative or overflow input values
nValueIn += txPrev.vout[prevout.n].nValue;
if (!MoneyRange(txPrev.vout[prevout.n].nValue) || !MoneyRange(nValueIn))
return DoS(100, error("ConnectInputs() : txin values out of range"));
// Skip ECDSA signature verification when connecting blocks (fBlock=true)
// before the last blockchain checkpoint. This is safe because block merkle hashes are
// still computed and checked, and any change will be caught at the next checkpoint.
@@ -1489,7 +1514,9 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
{
uint256 hash = GetHash();
txdb.TxnBegin();
if (!txdb.TxnBegin())
return error("SetBestChain() : TxnBegin failed");
if (pindexGenesisBlock == NULL && hash == hashGenesisBlock)
{
txdb.WriteHashBestChain(hash);
@@ -1538,7 +1565,10 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
printf("SetBestChain() : ReadFromDisk failed\n");
break;
}
txdb.TxnBegin();
if (!txdb.TxnBegin()) {
printf("SetBestChain() : TxnBegin 2 failed\n");
break;
}
// errors now are not fatal, we still did a reorganisation to a new chain in a valid way
if (!block.SetBestChainInner(txdb, pindex))
break;
@@ -1596,7 +1626,8 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos)
pindexNew->bnChainWork = (pindexNew->pprev ? pindexNew->pprev->bnChainWork : 0) + pindexNew->GetBlockWork();
CTxDB txdb;
txdb.TxnBegin();
if (!txdb.TxnBegin())
return false;
txdb.WriteBlockIndex(CDiskBlockIndex(pindexNew));
if (!txdb.TxnCommit())
return false;
@@ -1824,11 +1855,11 @@ bool CheckDiskSpace(uint64 nAdditionalBytes)
if (nFreeBytesAvailable < (uint64)15000000 + nAdditionalBytes)
{
fShutdown = true;
string strMessage = _("Warning: Disk space is low ");
string strMessage = _("Warning: Disk space is low");
strMiscWarning = strMessage;
printf("*** %s\n", strMessage.c_str());
ThreadSafeMessageBox(strMessage, "Bitcoin", wxOK | wxICON_EXCLAMATION | wxMODAL);
QueueShutdown();
StartShutdown();
return false;
}
return true;
@@ -2354,7 +2385,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
// at a time so the setAddrKnowns of the chosen nodes prevent repeats
static uint256 hashSalt;
if (hashSalt == 0)
RAND_bytes((unsigned char*)&hashSalt, sizeof(hashSalt));
hashSalt = GetRandHash();
int64 hashAddr = addr.GetHash();
uint256 hashRand = hashSalt ^ (hashAddr<<32) ^ ((GetTime()+hashAddr)/(24*60*60));
hashRand = Hash(BEGIN(hashRand), END(hashRand));
@@ -2391,6 +2422,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
return error("message inv size() = %d", vInv.size());
}
// find last block in inv vector
unsigned int nLastBlock = (unsigned int)(-1);
for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) {
if (vInv[vInv.size() - 1 - nInv].type == MSG_BLOCK) {
nLastBlock = vInv.size() - 1 - nInv;
break;
}
}
CTxDB txdb("r");
for (unsigned int nInv = 0; nInv < vInv.size(); nInv++)
{
@@ -2404,13 +2443,19 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
if (fDebug)
printf(" got inventory: %s %s\n", inv.ToString().c_str(), fAlreadyHave ? "have" : "new");
// Always request the last block in an inv bundle (even if we already have it), as it is the
// trigger for the other side to send further invs. If we are stuck on a (very long) side chain,
// this is necessary to connect earlier received orphan blocks to the chain again.
if (!fAlreadyHave || (inv.type == MSG_BLOCK && nInv==vInv.size()-1))
if (!fAlreadyHave)
pfrom->AskFor(inv);
if (inv.type == MSG_BLOCK && mapOrphanBlocks.count(inv.hash))
else if (inv.type == MSG_BLOCK && mapOrphanBlocks.count(inv.hash)) {
pfrom->PushGetBlocks(pindexBest, GetOrphanRoot(mapOrphanBlocks[inv.hash]));
} else if (nInv == nLastBlock) {
// In case we are on a very long side-chain, it is possible that we already have
// the last block in an inv bundle sent in response to getblocks. Try to detect
// this situation and push another getblocks to continue.
std::vector<CInv> vGetData(1,inv);
pfrom->PushGetBlocks(mapBlockIndex[inv.hash], uint256(0));
if (fDebug)
printf("force request: %s\n", inv.ToString().c_str());
}
// Track requests for our stuff
Inventory(inv.hash);
@@ -2551,6 +2596,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
else if (strCommand == "tx")
{
vector<uint256> vWorkQueue;
vector<uint256> vEraseQueue;
CDataStream vMsg(vRecv);
CTxDB txdb("r");
CTransaction tx;
@@ -2566,37 +2612,45 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
RelayMessage(inv, vMsg);
mapAlreadyAskedFor.erase(inv);
vWorkQueue.push_back(inv.hash);
vEraseQueue.push_back(inv.hash);
// Recursively process any orphan transactions that depended on this one
for (unsigned int i = 0; i < vWorkQueue.size(); i++)
{
uint256 hashPrev = vWorkQueue[i];
for (multimap<uint256, CDataStream*>::iterator mi = mapOrphanTransactionsByPrev.lower_bound(hashPrev);
mi != mapOrphanTransactionsByPrev.upper_bound(hashPrev);
for (map<uint256, CDataStream*>::iterator mi = mapOrphanTransactionsByPrev[hashPrev].begin();
mi != mapOrphanTransactionsByPrev[hashPrev].end();
++mi)
{
const CDataStream& vMsg = *((*mi).second);
CTransaction tx;
CDataStream(vMsg) >> tx;
CInv inv(MSG_TX, tx.GetHash());
bool fMissingInputs2 = false;
if (tx.AcceptToMemoryPool(txdb, true))
if (tx.AcceptToMemoryPool(txdb, true, &fMissingInputs2))
{
printf(" accepted orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str());
SyncWithWallets(tx, NULL, true);
RelayMessage(inv, vMsg);
mapAlreadyAskedFor.erase(inv);
vWorkQueue.push_back(inv.hash);
vEraseQueue.push_back(inv.hash);
}
else if (!fMissingInputs2)
{
// invalid orphan
vEraseQueue.push_back(inv.hash);
printf(" removed invalid orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str());
}
}
}
BOOST_FOREACH(uint256 hash, vWorkQueue)
BOOST_FOREACH(uint256 hash, vEraseQueue)
EraseOrphanTx(hash);
}
else if (fMissingInputs)
{
printf("storing orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str());
AddOrphanTx(vMsg);
// DoS prevention: do not allow mapOrphanTransactions to grow unbounded
@@ -2786,7 +2840,7 @@ bool ProcessMessages(CNode* pfrom)
unsigned int nMessageSize = hdr.nMessageSize;
if (nMessageSize > MAX_SIZE)
{
printf("ProcessMessage(%s, %u bytes) : nMessageSize > MAX_SIZE\n", strCommand.c_str(), nMessageSize);
printf("ProcessMessages(%s, %u bytes) : nMessageSize > MAX_SIZE\n", strCommand.c_str(), nMessageSize);
continue;
}
if (nMessageSize > vRecv.size())
@@ -2802,7 +2856,7 @@ bool ProcessMessages(CNode* pfrom)
memcpy(&nChecksum, &hash, sizeof(nChecksum));
if (nChecksum != hdr.nChecksum)
{
printf("ProcessMessage(%s, %u bytes) : CHECKSUM ERROR nChecksum=%08x hdr.nChecksum=%08x\n",
printf("ProcessMessages(%s, %u bytes) : CHECKSUM ERROR nChecksum=%08x hdr.nChecksum=%08x\n",
strCommand.c_str(), nMessageSize, nChecksum, hdr.nChecksum);
continue;
}
@@ -2827,22 +2881,22 @@ bool ProcessMessages(CNode* pfrom)
if (strstr(e.what(), "end of data"))
{
// Allow exceptions from underlength message on vRecv
printf("ProcessMessage(%s, %u bytes) : Exception '%s' caught, normally caused by a message being shorter than its stated length\n", strCommand.c_str(), nMessageSize, e.what());
printf("ProcessMessages(%s, %u bytes) : Exception '%s' caught, normally caused by a message being shorter than its stated length\n", strCommand.c_str(), nMessageSize, e.what());
}
else if (strstr(e.what(), "size too large"))
{
// Allow exceptions from overlong size
printf("ProcessMessage(%s, %u bytes) : Exception '%s' caught\n", strCommand.c_str(), nMessageSize, e.what());
printf("ProcessMessages(%s, %u bytes) : Exception '%s' caught\n", strCommand.c_str(), nMessageSize, e.what());
}
else
{
PrintExceptionContinue(&e, "ProcessMessage()");
PrintExceptionContinue(&e, "ProcessMessages()");
}
}
catch (std::exception& e) {
PrintExceptionContinue(&e, "ProcessMessage()");
PrintExceptionContinue(&e, "ProcessMessages()");
} catch (...) {
PrintExceptionContinue(NULL, "ProcessMessage()");
PrintExceptionContinue(NULL, "ProcessMessages()");
}
if (!fRet)
@@ -2862,11 +2916,12 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
if (pto->nVersion == 0)
return true;
// Keep-alive ping. We send a nonce of zero because we don't use it anywhere
// Keep-alive ping. We send a nonce of zero because we don't use it anywhere
// right now.
if (pto->nLastSend && GetTime() - pto->nLastSend > 30 * 60 && pto->vSend.empty()) {
uint64 nonce = 0;
if (pto->nVersion > BIP0031_VERSION)
pto->PushMessage("ping", 0);
pto->PushMessage("ping", nonce);
else
pto->PushMessage("ping");
}
@@ -2945,7 +3000,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
// 1/4 of tx invs blast to all immediately
static uint256 hashSalt;
if (hashSalt == 0)
RAND_bytes((unsigned char*)&hashSalt, sizeof(hashSalt));
hashSalt = GetRandHash();
uint256 hashRand = inv.hash ^ hashSalt;
hashRand = Hash(BEGIN(hashRand), END(hashRand));
bool fTrickleWait = ((hashRand & 3) != 0);
@@ -3062,7 +3117,7 @@ void SHA256Transform(void* pstate, void* pinput, const void* pinit)
ctx.h[i] = ((uint32_t*)pinit)[i];
SHA256_Update(&ctx, data, sizeof(data));
for (int i = 0; i < 8; i++)
for (int i = 0; i < 8; i++)
((uint32_t*)pstate)[i] = ctx.h[i];
}
@@ -3188,7 +3243,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
dPriority += (double)nValueIn * nConf;
if (fDebug && GetBoolArg("-printpriority"))
printf("priority nValueIn=%-12I64d nConf=%-5d dPriority=%-20.1f\n", nValueIn, nConf, dPriority);
printf("priority nValueIn=%-12"PRI64d" nConf=%-5d dPriority=%-20.1f\n", nValueIn, nConf, dPriority);
}
// Priority is sum(valuein * age) / txsize

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_MAIN_H
#define BITCOIN_MAIN_H
@@ -594,7 +594,13 @@ public:
// Read transaction
if (fseek(filein, pos.nTxPos, SEEK_SET) != 0)
return error("CTransaction::ReadFromDisk() : fseek failed");
filein >> *this;
try {
filein >> *this;
}
catch (std::exception &e) {
return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__);
}
// Return file pointer
if (pfileRet)
@@ -976,7 +982,12 @@ public:
filein.nType |= SER_BLOCKHEADERONLY;
// Read block
filein >> *this;
try {
filein >> *this;
}
catch (std::exception &e) {
return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__);
}
// Check the header
if (!CheckProofOfWork(GetHash(), nBits))

View File

@@ -27,7 +27,7 @@ LIBS= \
-l ssl \
-l crypto
DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB
DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
DEBUGFLAGS=-g
CFLAGS=-O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
@@ -69,7 +69,7 @@ OBJS= \
all: bitcoind.exe
obj/build.h: FORCE
../share/genbuild.sh obj/build.h
/bin/sh ../share/genbuild.sh obj/build.h
version.cpp: obj/build.h
DEFS += -DHAVE_BUILD_INFO

View File

@@ -7,12 +7,12 @@ USE_UPNP:=0
INCLUDEPATHS= \
-I"C:\boost-1.47.0-mgw" \
-I"C:\db-4.8.30.NC-mgw\build_unix" \
-I"C:\openssl-1.0.0d-mgw\include"
-I"C:\openssl-1.0.1b-mgw\include"
LIBPATHS= \
-L"C:\boost-1.47.0-mgw\stage\lib" \
-L"C:\db-4.8.30.NC-mgw\build_unix" \
-L"C:\openssl-1.0.0d-mgw"
-L"C:\openssl-1.0.1b-mgw"
LIBS= \
-l boost_system-mgw45-mt-s-1_47 \
@@ -23,7 +23,7 @@ LIBS= \
-l ssl \
-l crypto
DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB
DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
DEBUGFLAGS=-g
CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)

View File

@@ -53,7 +53,7 @@ LIBS += \
TESTDEFS += -DBOOST_TEST_DYN_LINK
endif
DEFS=-DMAC_OSX -DMSG_NOSIGNAL=0
DEFS=-DMAC_OSX -DMSG_NOSIGNAL=0 -DBOOST_SPIRIT_THREADSAFE
ifdef RELEASE
# Compile for maximum compatibility and smallest size.
@@ -106,7 +106,7 @@ all: bitcoind
-include obj-test/*.P
obj/build.h: FORCE
../share/genbuild.sh obj/build.h
/bin/sh ../share/genbuild.sh obj/build.h
version.cpp: obj/build.h
DEFS += -DHAVE_BUILD_INFO

View File

@@ -4,7 +4,7 @@
USE_UPNP:=0
DEFS=
DEFS=-DBOOST_SPIRIT_THREADSAFE
DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
@@ -116,7 +116,7 @@ all: bitcoind
-include obj-test/*.P
obj/build.h: FORCE
../share/genbuild.sh obj/build.h
/bin/sh ../share/genbuild.sh obj/build.h
version.cpp: obj/build.h
DEFS += -DHAVE_BUILD_INFO

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_MRUSET_H
#define BITCOIN_MRUSET_H

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "irc.h"
#include "db.h"
@@ -35,7 +35,7 @@ void ThreadOpenAddedConnections2(void* parg);
void ThreadMapPort2(void* parg);
#endif
void ThreadDNSAddressSeed2(void* parg);
bool OpenNetworkConnection(const CAddress& addrConnect);
bool OpenNetworkConnection(const CAddress& addrConnect, bool fUseGrant = true);
@@ -64,10 +64,7 @@ map<CInv, int64> mapAlreadyAskedFor;
set<CNetAddr> setservAddNodeAddresses;
CCriticalSection cs_setservAddNodeAddresses;
static CWaitableCriticalSection csOutbound;
static int nOutbound = 0;
static CConditionVariable condOutbound;
static CSemaphore *semOutbound = NULL;
unsigned short GetListenPort()
{
@@ -368,10 +365,6 @@ CNode* ConnectNode(CAddress addrConnect, int64 nTimeout)
LOCK(cs_vNodes);
vNodes.push_back(pnode);
}
{
WAITABLE_LOCK(csOutbound);
nOutbound++;
}
pnode->nTimeConnected = GetTime();
return pnode;
@@ -517,14 +510,9 @@ void ThreadSocketHandler2(void* parg)
// remove from vNodes
vNodes.erase(remove(vNodes.begin(), vNodes.end(), pnode), vNodes.end());
if (!pnode->fInbound)
{
WAITABLE_LOCK(csOutbound);
nOutbound--;
// Connection slot(s) were removed, notify connection creator(s)
NOTIFY(condOutbound);
}
if (pnode->fHasGrant)
semOutbound->post();
pnode->fHasGrant = false;
// close socket and cleanup
pnode->CloseSocketDisconnect();
@@ -621,7 +609,7 @@ void ThreadSocketHandler2(void* parg)
if (nSelect == SOCKET_ERROR)
{
int nErr = WSAGetLastError();
if (hSocketMax > -1)
if (hSocketMax != INVALID_SOCKET)
{
printf("socket select error %d\n", nErr);
for (unsigned int i = 0; i <= hSocketMax; i++)
@@ -1201,7 +1189,7 @@ void ThreadOpenConnections2(void* parg)
{
CAddress addr(CService(strAddr, GetDefaultPort(), fAllowDNS));
if (addr.IsValid())
OpenNetworkConnection(addr);
OpenNetworkConnection(addr, false);
for (int i = 0; i < 10 && i < nLoop; i++)
{
Sleep(500);
@@ -1222,13 +1210,9 @@ void ThreadOpenConnections2(void* parg)
if (fShutdown)
return;
// Limit outbound connections
int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, (int)GetArg("-maxconnections", 125));
vnThreadsRunning[THREAD_OPENCONNECTIONS]--;
{
WAITABLE_LOCK(csOutbound);
WAIT(condOutbound, fShutdown || nOutbound < nMaxOutbound);
}
semOutbound->wait();
vnThreadsRunning[THREAD_OPENCONNECTIONS]++;
if (fShutdown)
return;
@@ -1261,11 +1245,15 @@ void ThreadOpenConnections2(void* parg)
// Only connect to one address per a.b.?.? range.
// Do this here so we don't have to critsect vNodes inside mapAddresses critsect.
int nOutbound = 0;
set<vector<unsigned char> > setConnected;
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
BOOST_FOREACH(CNode* pnode, vNodes) {
setConnected.insert(pnode->addr.GetGroup());
if (!pnode->fInbound)
nOutbound++;
}
}
int64 nANow = GetAdjustedTime();
@@ -1296,6 +1284,8 @@ void ThreadOpenConnections2(void* parg)
if (addrConnect.IsValid())
OpenNetworkConnection(addrConnect);
else
semOutbound->post();
}
}
@@ -1358,6 +1348,7 @@ void ThreadOpenAddedConnections2(void* parg)
}
BOOST_FOREACH(vector<CService>& vserv, vservConnectAddresses)
{
semOutbound->wait();
OpenNetworkConnection(CAddress(*(vserv.begin())));
Sleep(500);
if (fShutdown)
@@ -1373,7 +1364,14 @@ void ThreadOpenAddedConnections2(void* parg)
}
}
bool OpenNetworkConnection(const CAddress& addrConnect)
bool static ReleaseGrant(bool fUseGrant) {
if (fUseGrant)
semOutbound->post();
return false;
}
// only call this function when semOutbound has been waited for
bool OpenNetworkConnection(const CAddress& addrConnect, bool fUseGrant)
{
//
// Initiate outbound network connection
@@ -1382,7 +1380,7 @@ bool OpenNetworkConnection(const CAddress& addrConnect)
return false;
if ((CNetAddr)addrConnect == (CNetAddr)addrLocalHost || !addrConnect.IsIPv4() ||
FindNode((CNetAddr)addrConnect) || CNode::IsBanned(addrConnect))
return false;
return ReleaseGrant(fUseGrant);
vnThreadsRunning[THREAD_OPENCONNECTIONS]--;
CNode* pnode = ConnectNode(addrConnect);
@@ -1390,7 +1388,13 @@ bool OpenNetworkConnection(const CAddress& addrConnect)
if (fShutdown)
return false;
if (!pnode)
return false;
return ReleaseGrant(fUseGrant);
if (pnode->fHasGrant) {
// node already has connection grant, release the one that was passed to us
ReleaseGrant(fUseGrant);
} else {
pnode->fHasGrant = fUseGrant;
}
pnode->fNetworkNode = true;
return true;
@@ -1473,7 +1477,7 @@ void ThreadMessageHandler2(void* parg)
vnThreadsRunning[THREAD_MESSAGEHANDLER]--;
Sleep(100);
if (fRequestShutdown)
Shutdown(NULL);
StartShutdown();
vnThreadsRunning[THREAD_MESSAGEHANDLER]++;
if (fShutdown)
return;
@@ -1567,6 +1571,12 @@ bool BindListenPort(string& strError)
void StartNode(void* parg)
{
if (semOutbound == NULL) {
// initialize semaphore
int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, (int)GetArg("-maxconnections", 125));
semOutbound = new CSemaphore(nMaxOutbound);
}
#ifdef USE_UPNP
#if USE_UPNP
fUseUPnP = GetBoolArg("-upnp", true);
@@ -1693,7 +1703,9 @@ bool StopNode()
fShutdown = true;
nTransactionsUpdated++;
int64 nStart = GetTime();
NOTIFY_ALL(condOutbound);
if (semOutbound)
for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++)
semOutbound->post();
do
{
int nThreadsRunning = 0;

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_NET_H
#define BITCOIN_NET_H
@@ -127,6 +127,7 @@ public:
bool fNetworkNode;
bool fSuccessfullyConnected;
bool fDisconnect;
bool fHasGrant; // whether to call semOutbound.post() at disconnect
protected:
int nRefCount;
@@ -171,6 +172,7 @@ public:
nVersion = 0;
strSubVer = "";
fClient = false; // set by version message
fHasGrant = false;
fInbound = fInboundIn;
fNetworkNode = false;
fSuccessfullyConnected = false;

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "netbase.h"
#include "util.h"

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_NETBASE_H
#define BITCOIN_NETBASE_H

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "ui_interface.h"
#include <string>

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "protocol.h"
#include "util.h"

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef __cplusplus
# error This header can only be compiled as C++.

View File

@@ -123,11 +123,6 @@ void AddressBookPage::setModel(AddressTableModel *model)
connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(selectionChanged()));
if(mode == ForSending)
{
// Auto-select first row when in sending mode
ui->tableView->selectRow(0);
}
selectionChanged();
}

View File

@@ -281,12 +281,14 @@ int main(int argc, char *argv[])
#endif
app.exec();
window.hide();
window.setClientModel(0);
window.setWalletModel(0);
guiref = 0;
clientmodel = 0;
walletmodel = 0;
}
// Shutdown the core and it's threads, but don't exit Bitcoin-Qt here
Shutdown(NULL);
}
else

View File

@@ -21,9 +21,12 @@ BitcoinAddressValidator::BitcoinAddressValidator(QObject *parent) :
QValidator::State BitcoinAddressValidator::validate(QString &input, int &pos) const
{
// Correction
for(int idx=0; idx<input.size(); ++idx)
for(int idx=0; idx<input.size();)
{
switch(input.at(idx).unicode())
bool removeChar = false;
QChar ch = input.at(idx);
// Transform characters that are visually close
switch(ch.unicode())
{
case 'l':
case 'I':
@@ -33,9 +36,22 @@ QValidator::State BitcoinAddressValidator::validate(QString &input, int &pos) co
case 'O':
input[idx] = QChar('o');
break;
// Qt categorizes these as "Other_Format" not "Separator_Space"
case 0x200B: // ZERO WIDTH SPACE
case 0xFEFF: // ZERO WIDTH NO-BREAK SPACE
removeChar = true;
break;
default:
break;
}
// Remove whitespace
if(ch.isSpace())
removeChar = true;
// To next character
if(removeChar)
input.remove(idx, 1);
else
++idx;
}
// Validation

View File

@@ -1,8 +1,8 @@
/*
* Qt4 bitcoin GUI.
*
* W.J. van der Laan 20011-2012
* The Bitcoin Developers 20011-2012
* W.J. van der Laan 2011-2012
* The Bitcoin Developers 2011-2012
*/
#include "bitcoingui.h"
#include "transactiontablemodel.h"
@@ -163,8 +163,6 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
BitcoinGUI::~BitcoinGUI()
{
if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
trayIcon->hide();
#ifdef Q_WS_MAC
delete appMenuBar;
#endif
@@ -385,7 +383,6 @@ void BitcoinGUI::createTrayIcon()
#else
// Note: On Mac, the dock icon is used to provide the tray's functionality.
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
connect(dockIconHandler, SIGNAL(dockIconClicked()), toggleHideAction, SLOT(trigger()));
trayIconMenu = dockIconHandler->dockMenu();
#endif

View File

@@ -27,8 +27,9 @@ void CSVModelWriter::addColumn(const QString &title, int column, int role)
static void writeValue(QTextStream &f, const QString &value)
{
// TODO: quoting if " or \n in string
f << "\"" << value << "\"";
QString escaped = value;
escaped.replace('"', "\"\"");
f << "\"" << escaped << "\"";
}
static void writeSep(QTextStream &f)

View File

@@ -28,9 +28,6 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="warningLabel">
<property name="text">
<string>TextLabel</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>

View File

@@ -44,7 +44,7 @@
<item row="2" column="1">
<widget class="QLabel" name="labelBalance">
<property name="text">
<string>123.456 BTC</string>
<string notr="true">0 BTC</string>
</property>
</widget>
</item>
@@ -72,18 +72,20 @@
<item row="3" column="1">
<widget class="QLabel" name="labelUnconfirmed">
<property name="text">
<string>0 BTC</string>
<string notr="true">0 BTC</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<pointsize>11</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Wallet&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Wallet</string>
</property>
</widget>
</item>

View File

@@ -213,7 +213,7 @@ MainOptionsPage::MainOptionsPage(QWidget *parent):
proxy_hbox->addStretch(1);
layout->addLayout(proxy_hbox);
QLabel *fee_help = new QLabel(tr("Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB. Fee 0.01 recommended."));
QLabel *fee_help = new QLabel(tr("Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB. Fee 0.01 recommended."));
fee_help->setWordWrap(true);
layout->addWidget(fee_help);
@@ -222,7 +222,6 @@ MainOptionsPage::MainOptionsPage(QWidget *parent):
QLabel *fee_label = new QLabel(tr("Pay transaction &fee"));
fee_hbox->addWidget(fee_label);
fee_edit = new BitcoinAmountField();
fee_edit->setToolTip(tr("Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB. Fee 0.01 recommended."));
fee_label->setBuddy(fee_edit);
fee_hbox->addWidget(fee_edit);

View File

@@ -150,14 +150,21 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipie
hex = QString::fromStdString(wtx.GetHash().GetHex());
}
// Add addresses that we've sent to to the address book
// Add addresses / update labels that we've sent to to the address book
foreach(const SendCoinsRecipient &rcp, recipients)
{
std::string strAddress = rcp.address.toStdString();
std::string strLabel = rcp.label.toStdString();
{
LOCK(wallet->cs_wallet);
if (!wallet->mapAddressBook.count(strAddress))
wallet->SetAddressBookName(strAddress, rcp.label.toStdString());
std::map<CBitcoinAddress, std::string>::iterator mi = wallet->mapAddressBook.find(strAddress);
// Check if we have a new address or an updated label
if (mi == wallet->mapAddressBook.end() || mi->second != strLabel)
{
wallet->SetAddressBookName(strAddress, strLabel);
}
}
}

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2009-2012 Bitcoin Developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "init.h" // for pwalletMain
#include "bitcoinrpc.h"

View File

@@ -1,8 +1,9 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <boost/foreach.hpp>
#include <boost/tuple/tuple.hpp>
using namespace std;
using namespace boost;
@@ -12,6 +13,7 @@ using namespace boost;
#include "bignum.h"
#include "key.h"
#include "main.h"
#include "util.h"
bool CheckSig(vector<unsigned char> vchSig, vector<unsigned char> vchPubKey, CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
@@ -1099,12 +1101,67 @@ uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int
}
// Valid signature cache, to avoid doing expensive ECDSA signature checking
// twice for every transaction (once when accepted into memory pool, and
// again when accepted into the block chain)
class CSignatureCache
{
private:
// sigdata_type is (signature hash, signature, public key):
typedef boost::tuple<uint256, std::vector<unsigned char>, std::vector<unsigned char> > sigdata_type;
std::set< sigdata_type> setValid;
CCriticalSection cs_sigcache;
public:
bool
Get(uint256 hash, const std::vector<unsigned char>& vchSig, const std::vector<unsigned char>& pubKey)
{
LOCK(cs_sigcache);
sigdata_type k(hash, vchSig, pubKey);
std::set<sigdata_type>::iterator mi = setValid.find(k);
if (mi != setValid.end())
return true;
return false;
}
void
Set(uint256 hash, const std::vector<unsigned char>& vchSig, const std::vector<unsigned char>& pubKey)
{
// DoS prevention: limit cache size to less than 10MB
// (~200 bytes per cache entry times 50,000 entries)
// Since there are a maximum of 20,000 signature operations per block
// 50,000 is a reasonable default.
int64 nMaxCacheSize = GetArg("-maxsigcachesize", 50000);
if (nMaxCacheSize <= 0) return;
LOCK(cs_sigcache);
while (static_cast<int64>(setValid.size()) > nMaxCacheSize)
{
// Evict a random entry. Random because that helps
// foil would-be DoS attackers who might try to pre-generate
// and re-use a set of valid signatures just-slightly-greater
// than our cache size.
uint256 randomHash = GetRandHash();
std::vector<unsigned char> unused;
std::set<sigdata_type>::iterator it =
setValid.lower_bound(sigdata_type(randomHash, unused, unused));
if (it == setValid.end())
it = setValid.begin();
setValid.erase(*it);
}
sigdata_type k(hash, vchSig, pubKey);
setValid.insert(k);
}
};
bool CheckSig(vector<unsigned char> vchSig, vector<unsigned char> vchPubKey, CScript scriptCode,
const CTransaction& txTo, unsigned int nIn, int nHashType)
{
CKey key;
if (!key.SetPubKey(vchPubKey))
return false;
static CSignatureCache signatureCache;
// Hash type is one byte tacked on to the end of the signature
if (vchSig.empty())
@@ -1115,7 +1172,20 @@ bool CheckSig(vector<unsigned char> vchSig, vector<unsigned char> vchPubKey, CSc
return false;
vchSig.pop_back();
return key.Verify(SignatureHash(scriptCode, txTo, nIn, nHashType), vchSig);
uint256 sighash = SignatureHash(scriptCode, txTo, nIn, nHashType);
if (signatureCache.Get(sighash, vchSig, vchPubKey))
return true;
CKey key;
if (!key.SetPubKey(vchPubKey))
return false;
if (!key.Verify(sighash, vchSig))
return false;
signatureCache.Set(sighash, vchSig, vchPubKey);
return true;
}

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef H_BITCOIN_SCRIPT
#define H_BITCOIN_SCRIPT

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_SERIALIZE_H
#define BITCOIN_SERIALIZE_H

View File

@@ -15,20 +15,20 @@ BOOST_AUTO_TEST_SUITE(Checkpoints_tests)
BOOST_AUTO_TEST_CASE(sanity)
{
uint256 p11111 = uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d");
uint256 p140700 = uint256("0x000000000000033b512028abb90e1626d8b346fd0ed598ac0a3c371138dce2bd");
uint256 p134444 = uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe");
BOOST_CHECK(Checkpoints::CheckBlock(11111, p11111));
BOOST_CHECK(Checkpoints::CheckBlock(140700, p140700));
BOOST_CHECK(Checkpoints::CheckBlock(134444, p134444));
// Wrong hashes at checkpoints should fail:
BOOST_CHECK(!Checkpoints::CheckBlock(11111, p140700));
BOOST_CHECK(!Checkpoints::CheckBlock(140700, p11111));
BOOST_CHECK(!Checkpoints::CheckBlock(11111, p134444));
BOOST_CHECK(!Checkpoints::CheckBlock(134444, p11111));
// ... but any hash not at a checkpoint should succeed:
BOOST_CHECK(Checkpoints::CheckBlock(11111+1, p140700));
BOOST_CHECK(Checkpoints::CheckBlock(140700+1, p11111));
BOOST_CHECK(Checkpoints::CheckBlock(11111+1, p134444));
BOOST_CHECK(Checkpoints::CheckBlock(134444+1, p11111));
BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 140700);
BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 134444);
}
BOOST_AUTO_TEST_SUITE_END()

View File

@@ -1,7 +1,10 @@
//
// Unit tests for denial-of-service detection/prevention code
//
#include <algorithm>
#include <boost/assign/list_of.hpp> // for 'map_list_of()'
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/foreach.hpp>
@@ -13,10 +16,10 @@
#include <stdint.h>
// Tests this internal-to-main.cpp method:
extern void AddOrphanTx(const CDataStream& vMsg);
extern bool AddOrphanTx(const CDataStream& vMsg);
extern unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans);
extern std::map<uint256, CDataStream*> mapOrphanTransactions;
extern std::multimap<uint256, CDataStream*> mapOrphanTransactionsByPrev;
extern std::map<uint256, std::map<uint256, CDataStream*> > mapOrphanTransactionsByPrev;
CService ip(uint32_t i)
{
@@ -57,7 +60,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
BOOST_CHECK(!CNode::IsBanned(addr1));
dummyNode1.Misbehaving(1);
BOOST_CHECK(CNode::IsBanned(addr1));
mapArgs["-banscore"] = "100";
mapArgs.erase("-banscore");
}
BOOST_AUTO_TEST_CASE(DoS_bantime)
@@ -129,18 +132,10 @@ BOOST_AUTO_TEST_CASE(DoS_checknbits)
}
static uint256 RandomHash()
{
std::vector<unsigned char> randbytes(32);
RAND_bytes(&randbytes[0], 32);
uint256 randomhash(randbytes);
return randomhash;
}
CTransaction RandomOrphan()
{
std::map<uint256, CDataStream*>::iterator it;
it = mapOrphanTransactions.lower_bound(RandomHash());
it = mapOrphanTransactions.lower_bound(GetRandHash());
if (it == mapOrphanTransactions.end())
it = mapOrphanTransactions.begin();
const CDataStream* pvMsg = it->second;
@@ -162,7 +157,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
CTransaction tx;
tx.vin.resize(1);
tx.vin[0].prevout.n = 0;
tx.vin[0].prevout.hash = RandomHash();
tx.vin[0].prevout.hash = GetRandHash();
tx.vin[0].scriptSig << OP_1;
tx.vout.resize(1);
tx.vout[0].nValue = 1*CENT;
@@ -192,6 +187,32 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
AddOrphanTx(ds);
}
// This really-big orphan should be ignored:
for (int i = 0; i < 10; i++)
{
CTransaction txPrev = RandomOrphan();
CTransaction tx;
tx.vout.resize(1);
tx.vout[0].nValue = 1*CENT;
tx.vout[0].scriptPubKey.SetBitcoinAddress(key.GetPubKey());
tx.vin.resize(500);
for (int j = 0; j < tx.vin.size(); j++)
{
tx.vin[j].prevout.n = j;
tx.vin[j].prevout.hash = txPrev.GetHash();
}
SignSignature(keystore, txPrev, tx, 0);
// Re-use same signature for other inputs
// (they don't have to be valid for this test)
for (int j = 1; j < tx.vin.size(); j++)
tx.vin[j].scriptSig = tx.vin[0].scriptSig;
CDataStream ds(SER_DISK, CLIENT_VERSION);
ds << tx;
BOOST_CHECK(!AddOrphanTx(ds));
}
// Test LimitOrphanTxSize() function:
LimitOrphanTxSize(40);
BOOST_CHECK(mapOrphanTransactions.size() <= 40);
@@ -202,4 +223,92 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
BOOST_CHECK(mapOrphanTransactionsByPrev.empty());
}
BOOST_AUTO_TEST_CASE(DoS_checkSig)
{
// Test signature caching code (see key.cpp Verify() methods)
CKey key;
key.MakeNewKey(true);
CBasicKeyStore keystore;
keystore.AddKey(key);
// 100 orphan transactions:
static const int NPREV=100;
CTransaction orphans[NPREV];
for (int i = 0; i < NPREV; i++)
{
CTransaction& tx = orphans[i];
tx.vin.resize(1);
tx.vin[0].prevout.n = 0;
tx.vin[0].prevout.hash = GetRandHash();
tx.vin[0].scriptSig << OP_1;
tx.vout.resize(1);
tx.vout[0].nValue = 1*CENT;
tx.vout[0].scriptPubKey.SetBitcoinAddress(key.GetPubKey());
CDataStream ds(SER_DISK, CLIENT_VERSION);
ds << tx;
AddOrphanTx(ds);
}
// Create a transaction that depends on orphans:
CTransaction tx;
tx.vout.resize(1);
tx.vout[0].nValue = 1*CENT;
tx.vout[0].scriptPubKey.SetBitcoinAddress(key.GetPubKey());
tx.vin.resize(NPREV);
for (int j = 0; j < tx.vin.size(); j++)
{
tx.vin[j].prevout.n = 0;
tx.vin[j].prevout.hash = orphans[j].GetHash();
}
// Creating signatures primes the cache:
boost::posix_time::ptime mst1 = boost::posix_time::microsec_clock::local_time();
for (int j = 0; j < tx.vin.size(); j++)
BOOST_CHECK(SignSignature(keystore, orphans[j], tx, j));
boost::posix_time::ptime mst2 = boost::posix_time::microsec_clock::local_time();
boost::posix_time::time_duration msdiff = mst2 - mst1;
long nOneValidate = msdiff.total_milliseconds();
if (fDebug) printf("DoS_Checksig sign: %ld\n", nOneValidate);
// ... now validating repeatedly should be quick:
// 2.8GHz machine, -g build: Sign takes ~760ms,
// uncached Verify takes ~250ms, cached Verify takes ~50ms
// (for 100 single-signature inputs)
mst1 = boost::posix_time::microsec_clock::local_time();
for (int i = 0; i < 5; i++)
for (int j = 0; j < tx.vin.size(); j++)
BOOST_CHECK(VerifySignature(orphans[j], tx, j, true, SIGHASH_ALL));
mst2 = boost::posix_time::microsec_clock::local_time();
msdiff = mst2 - mst1;
long nManyValidate = msdiff.total_milliseconds();
if (fDebug) printf("DoS_Checksig five: %ld\n", nManyValidate);
BOOST_CHECK_MESSAGE(nManyValidate < nOneValidate, "Signature cache timing failed");
// Empty a signature, validation should fail:
CScript save = tx.vin[0].scriptSig;
tx.vin[0].scriptSig = CScript();
BOOST_CHECK(!VerifySignature(orphans[0], tx, 0, true, SIGHASH_ALL));
tx.vin[0].scriptSig = save;
// Swap signatures, validation should fail:
std::swap(tx.vin[0].scriptSig, tx.vin[1].scriptSig);
BOOST_CHECK(!VerifySignature(orphans[0], tx, 0, true, SIGHASH_ALL));
BOOST_CHECK(!VerifySignature(orphans[1], tx, 1, true, SIGHASH_ALL));
std::swap(tx.vin[0].scriptSig, tx.vin[1].scriptSig);
// Exercise -maxsigcachesize code:
mapArgs["-maxsigcachesize"] = "10";
// Generate a new, different signature for vin[0] to trigger cache clear:
CScript oldSig = tx.vin[0].scriptSig;
BOOST_CHECK(SignSignature(keystore, orphans[0], tx, 0));
BOOST_CHECK(tx.vin[0].scriptSig != oldSig);
for (int j = 0; j < tx.vin.size(); j++)
BOOST_CHECK(VerifySignature(orphans[j], tx, j, true, SIGHASH_ALL));
mapArgs.erase("-maxsigcachesize");
LimitOrphanTxSize(0);
}
BOOST_AUTO_TEST_SUITE_END()

View File

@@ -26,3 +26,9 @@ void Shutdown(void* parg)
{
exit(0);
}
void StartShutdown()
{
exit(0);
}

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_UI_INTERFACE_H
#define BITCOIN_UI_INTERFACE_H

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_UINT256_H
#define BITCOIN_UINT256_H

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "util.h"
#include "strlcpy.h"
@@ -26,6 +26,7 @@ namespace boost {
#include <boost/interprocess/sync/interprocess_mutex.hpp>
#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
#include <boost/foreach.hpp>
#include <boost/thread.hpp>
#include <openssl/crypto.h>
#include <openssl/rand.h>
@@ -174,6 +175,12 @@ int GetRandInt(int nMax)
return GetRand(nMax);
}
uint256 GetRandHash()
{
uint256 hash;
RAND_bytes((unsigned char*)&hash, sizeof(hash));
return hash;
}
@@ -209,6 +216,8 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
if (fileout)
{
static bool fStartedNewLine = true;
static boost::mutex mutexDebugLog;
boost::mutex::scoped_lock scoped_lock(mutexDebugLog);
// Debug print useful for profiling
if (fLogTimestamps && fStartedNewLine)
@@ -843,7 +852,7 @@ boost::filesystem::path GetDefaultDataDir()
#ifdef MAC_OSX
// Mac
pathRet /= "Library/Application Support";
filesystem::create_directory(pathRet);
fs::create_directory(pathRet);
return pathRet / "Bitcoin";
#else
// Unix

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_UTIL_H
#define BITCOIN_UTIL_H
@@ -23,7 +23,7 @@ typedef int pid_t; /* define for windows compatiblity */
#include <boost/filesystem/path.hpp>
#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/interprocess/sync/interprocess_condition.hpp>
#include <boost/interprocess/sync/interprocess_semaphore.hpp>
#include <boost/interprocess/sync/lock_options.hpp>
#include <boost/date_time/gregorian/gregorian_types.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
@@ -168,6 +168,7 @@ bool SetStartOnSystemStartup(bool fAutoStart);
void ShrinkDebugFile();
int GetRandInt(int nMax);
uint64 GetRand(uint64 nMax);
uint256 GetRandHash();
int64 GetTime();
void SetMockTime(int64 nMockTimeIn);
int64 GetAdjustedTime();
@@ -217,9 +218,11 @@ public:
{
printf("LOCKCONTENTION: %s\n", pszName);
printf("Locker: %s:%d\n", pszFile, nLine);
}
#endif
lock.lock();
#ifdef DEBUG_LOCKCONTENTION
}
#endif
}
}
@@ -270,24 +273,10 @@ public:
};
typedef CMutexLock<CCriticalSection> CCriticalBlock;
typedef CMutexLock<CWaitableCriticalSection> CWaitableCriticalBlock;
typedef boost::interprocess::interprocess_condition CConditionVariable;
/** Wait for a given condition inside a WAITABLE_CRITICAL_BLOCK */
#define WAIT(name,condition) \
do { while(!(condition)) { (name).wait(waitablecriticalblock.GetLock()); } } while(0)
/** Notify waiting threads that a condition may hold now */
#define NOTIFY(name) \
do { (name).notify_one(); } while(0)
#define NOTIFY_ALL(name) \
do { (name).notify_all(); } while(0)
#define LOCK(cs) CCriticalBlock criticalblock(cs, #cs, __FILE__, __LINE__)
#define LOCK2(cs1,cs2) CCriticalBlock criticalblock1(cs1, #cs1, __FILE__, __LINE__),criticalblock2(cs2, #cs2, __FILE__, __LINE__)
#define TRY_LOCK(cs,name) CCriticalBlock name(cs, #cs, __FILE__, __LINE__, true)
#define WAITABLE_LOCK(cs) CWaitableCriticalBlock waitablecriticalblock(cs, #cs, __FILE__, __LINE__)
#define ENTER_CRITICAL_SECTION(cs) \
{ \
@@ -301,6 +290,47 @@ typedef boost::interprocess::interprocess_condition CConditionVariable;
LeaveCritical(); \
}
#ifdef MAC_OSX
// boost::interprocess::interprocess_semaphore seems to spinlock on OSX; prefer polling instead
class CSemaphore
{
private:
CCriticalSection cs;
int val;
public:
CSemaphore(int init) : val(init) {}
void wait() {
do {
{
LOCK(cs);
if (val>0) {
val--;
return;
}
}
Sleep(100);
} while(1);
}
bool try_wait() {
LOCK(cs);
if (val>0) {
val--;
return true;
}
return false;
}
void post() {
LOCK(cs);
val++;
}
};
#else
typedef boost::interprocess::interprocess_semaphore CSemaphore;
#endif
inline std::string i64tostr(int64 n)
{

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <string>
#include "version.h"

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_VERSION_H
#define BITCOIN_VERSION_H
@@ -10,10 +10,11 @@
// client versioning
//
static const int CLIENT_VERSION_MAJOR = 0;
static const int CLIENT_VERSION_MINOR = 6;
static const int CLIENT_VERSION_REVISION = 1;
static const int CLIENT_VERSION_BUILD = 3;
// These need to be macro's, as version.cpp's voodoo requires it
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 6
#define CLIENT_VERSION_REVISION 3
#define CLIENT_VERSION_BUILD 0
static const int CLIENT_VERSION =
1000000 * CLIENT_VERSION_MAJOR

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "wallet.h"
#include "walletdb.h"
@@ -242,7 +242,8 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
if (fFileBacked)
{
pwalletdbEncryption = new CWalletDB(strWalletFile);
pwalletdbEncryption->TxnBegin();
if (!pwalletdbEncryption->TxnBegin())
return false;
pwalletdbEncryption->WriteMasterKey(nMasterKeyMaxID, kMasterKey);
}

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_WALLET_H
#define BITCOIN_WALLET_H

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "walletdb.h"
#include "wallet.h"
@@ -189,7 +189,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
//// debug print
//printf("LoadWallet %s\n", wtx.GetHash().ToString().c_str());
//printf(" %12I64d %s %s %s\n",
//printf(" %12"PRI64d" %s %s %s\n",
// wtx.vout[0].nValue,
// DateTimeStrFormat("%x %H:%M:%S", wtx.GetBlockTime()).c_str(),
// wtx.hashBlock.ToString().substr(0,20).c_str(),

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_WALLETDB_H
#define BITCOIN_WALLETDB_H