Commit Graph

564 Commits

Author SHA1 Message Date
Pieter Wuille 89b7019be8 Reconstruct coins/ from scratch when missing. 2012-12-06 17:00:12 +01:00
Pieter Wuille d79775a04d Merge pull request #2057 from Diapolo/FlushBlockFile
FlushBlockFile(): check for valid FILE pointer
2012-12-06 01:35:36 -08:00
Pieter Wuille cd1391ae4d Merge pull request #2056 from sipa/fix_2052
Fixes for obscure mempool-checkpoint interaction
2012-12-05 14:15:17 -08:00
Pieter Wuille 8a28bb6dee Add -benchmark for reporting block processing times 2012-12-05 23:06:01 +01:00
Pieter Wuille a485c1b69e Merge pull request #2063 from Diapolo/CDiskBlockPos
add 2 constructors in CDiskBlockPos to simplify class usage
2012-12-05 14:01:03 -08:00
Philip Kaufmann fa45c26a0e call CheckDiskSpace() before pre-allocating space
- even if we are allowed to fail pre-allocating, it's better to check
  for sufficient space before calling AllocateFileRange() and if we
  are out of disk space return with error()
- the above change allows us to remove the CheckDiskSpace() check
  in CBlock::AcceptBlock()
2012-12-05 14:39:09 +01:00
Philip Kaufmann a8a4b9673e add 2 constructors in CDiskBlockPos to simplify class usage
- add a default-constructor, which simply calls SetNull() and a
  constructor to directly pass nFile and nPos
- change code to use that new constructors
2012-12-03 10:19:17 +01:00
Pieter Wuille d33a9218ab Make SetBestChain() atomic
In case a reorganisation fails, the internal state could become
inconsistent (memory only). Previously, a cache per block connect
or disconnect action was used, so blocks could not be applied in
a partial way. Extend this to a cache for the entire reorganisation,
making it atomic entirely. This also simplifies the code a bit.
2012-12-02 01:43:35 +01:00
Philip Kaufmann b19388dd88 FlushBlockFile(): check for valid FILE pointer
- don't call FileCommit() and fclose() if no valid FILE pointer was
  returned by OpenBlockFile()
2012-12-01 11:36:53 +01:00
Pieter Wuille cd7fb7d1de Merge pull request #2033 from sipa/kickconflicts
Bugfix: remove conflicting transactions from memory pool
2012-11-30 17:10:07 -08:00
Pieter Wuille 8259c57321 Only send reorged txn to mempool after checkpoint 2012-12-01 02:09:41 +01:00
Gavin Andresen aaef016a07 Merge pull request #2037 from luke-jr/printpriority
Allow -printpriority without -debug
2012-11-30 16:16:59 -08:00
Pieter Wuille 038784b979 Enable script verification for reorganized mempool tx 2012-12-01 00:45:17 +01:00
Luke Dashjr 2646080e3d Allow -printpriority without -debug 2012-11-26 16:30:54 +00:00
Philip Kaufmann 5350ea4171 update CClientUIInterface and remove orphan Wx stuff
- fix ThreadSafeMessageBox always displays error icon
- allow to specify MSG_ERROR / MSG_WARNING or MSG_INFORMATION without a
  custom caption / title
- allow to specify CClientUIInterface::ICON_ERROR / ICON_WARNING and
  ICON_INFORMATION (which is default) as message box icon
- remove CClientUIInterface::OK from ThreadSafeMessageBox-calls, as
  the OK button will be set as default, if none is specified
- prepend "Bitcoin - " to used captions
- rename BitcoinGUI::error() -> BitcoinGUI::message() and add function
  documentation
- change all style parameters and enum flags to unsigned
- update code to use that new API

- update Client- and WalletModel to use new BitcoinGUI::message() and
  rename the classes error() method into message()
- include the possibility to supply the wanted icon for messages from
  Client- and WalletModel via "style" parameter
2012-11-26 13:32:31 +01:00
Pieter Wuille 231b399952 Bugfix: remove conflicting transactions from memory pool
When a transaction A is in the memory pool, while a transaction B
(which shares an input with A) gets accepted into a block, A was
kept forever in the memory pool.

This commit adds a CTxMemPool::removeConflicts method, which
removes transactions that conflict with a given transaction, and
all their children.

This results in less transactions in the memory pool, and faster
construction of new blocks.
2012-11-25 11:50:35 +01:00
Pieter Wuille 7818d230a2 Merge pull request #2013 from sipa/blockheader
Split off CBlockHeader from CBlock
2012-11-24 13:54:12 -08:00
Pieter Wuille c07a1a6ee4 Merge pull request #1980 from sipa/noreorgsame
Do not reorganize if new branch has same amount of work
2012-11-22 13:33:03 -08:00
Philip Kaufmann 11406c89fe ConnectBlock(): fix error() format to be unsigned
- I introduced the wrong format macro with my former patch (#2018), this
  needs to be signed not unsigned (thanks Luke-Jr)
2012-11-17 09:57:58 +01:00
Philip Kaufmann 42152c3da9 ensure we use our format macros to avoid compilation warnings
- fixes 2 warnings I observed while compiling on Windows with MinGW
2012-11-16 08:29:47 +01:00
Jeff Garzik 3ef292dc7d Merge pull request #1670 from luke-jr/blksubstr
Use full block hash as unique identifier in debug.log
2012-11-15 18:47:07 -08:00
Jeff Garzik 824e196054 Merge pull request #2005 from Diapolo/fixes_main
some small fixes for main.cpp/.h
2012-11-15 18:20:35 -08:00
Jeff Garzik a0bf93b809 Merge pull request #2012 from luke-jr/invblk_errs
Print error for coinbase-pays-too-much case of ConnectBlock failing
2012-11-15 18:18:55 -08:00
Pieter Wuille e754cf4133 Split off CBlockHeader from CBlock
Cleaner and removes the need for the application-specific flags in
serialize.h.
2012-11-16 00:12:33 +01:00
Pieter Wuille 99d0d0f356 Introduce script verification flags
These flags select features to be enabled/disabled during script
evaluation/checking, instead of several booleans passed along.
Currently these flags are defined:
* SCRIPT_VERIFY_P2SH: enable BIP16-style subscript evaluation
* SCRIPT_VERIFY_STRICTENC: enforce strict adherence to pubkey/sig encoding standards.
2012-11-15 23:00:16 +01:00
Luke Dashjr 4ade04ddbd Print error for coinbase-pays-too-much case of ConnectBlock failing 2012-11-14 19:16:56 +00:00
Luke Dashjr f3a84c3a6b Abstract block hash substr extraction (for debug.log) into BlockHashStr inline 2012-11-13 21:18:32 +00:00
Philip Kaufmann 13e5cce4c3 some small fixes for main.cpp/.h
- remove an unwanted ";" at the end of the ~CCoinsView() destructor
- in FindBlockPos() and FindUndoPos() only call fclose(), is file is open
- fix an error string in the CBlockUndo class
2012-11-11 13:16:42 +01:00
Philip Kaufmann b56585d067 fix some missing indentations in main.cpp for better readability 2012-11-10 14:26:34 +01:00
Pieter Wuille 7fea484674 Add -reindex, to perform in-place reindexing of block chain files
Flushes the blktree/ and coins/ databases, and reindexes the
block chain files, as if their contents was loaded via -loadblock.

Based on earlier work by Jeff Garzik.
2012-11-09 01:06:32 +01:00
Pieter Wuille 7a5b7535bf Move ThreadImport to init.cpp 2012-11-09 01:06:32 +01:00
Pieter Wuille 05d9726805 LoadExternalBlockFile switched to CBufferedFile 2012-11-09 01:06:06 +01:00
Pieter Wuille cd6dc96c4f Do not reorganize if new branch has same amount of work 2012-11-05 21:24:11 +01:00
Pieter Wuille 1c83b0a377 Cache size optimizations 2012-11-04 18:06:25 +01:00
Pieter Wuille 28982cc9dc Remove P2SH transition code: P2SH violations may cause DoS trigger 2012-10-29 00:41:39 +01:00
Pieter Wuille 344620e953 Merge pull request #1904 from laanwj/2012_10_remove_getorder
remove "checkorder" P2P command
2012-10-25 11:41:22 -07:00
Pieter Wuille 66444558a5 Merge pull request #1953 from gmaxwell/createnewblock-race
Fixes a race condition in CreateNewBlock and a future null deref on testnet.
2012-10-25 11:30:51 -07:00
Wladimir J. van der Laan 1f7c5c5a3e Merge pull request #1926 from laanwj/2012_10_maindummybounds
Fix out-of-bounds read in main (issue #1924)
2012-10-25 06:12:10 -07:00
Wladimir J. van der Laan 62e21fb5d0 Show warning when using prerelease version
Implements #1948

- Add macro `CLIENT_VERSION_IS_RELEASE` to clientversion.h
- When running a prerelease (the above macro is `false`):
  - In UI, show an orange warning bar at the top. This will be used for other
    warnings (and alerts) as well, instead of the status bar.
  - For `bitcoind`, show the warning in the "errors" field in `getinfo`
    response.
2012-10-25 07:33:45 +02:00
Wladimir J. van der Laan 4fbad9124e Fix out-of-bounds read noticed by Ricardo Correia
Sizeof() returned the size of a pointer instead of the size of the buffer.
Fixes issue #1924.
2012-10-24 08:26:50 +02:00
Gregory Maxwell faff50d129 Fixes a race condition in CreateNewBlock and a future null deref on testnet.
CreateNewBlock was reading pindexBest at the start before taking the lock
so it was possible to have the the block content not match the prevheader
and this can also trigger a newly added assert in ConnectBlock.

I noticed this during a code review after twobitcoins reported that ab91bf39
(BIP30 for all blocks) could cause a null dereference on a modified node
that mined during the IBD, or on testnet when it reached heights 91842 and
91880 due to CreateNewBlock calling ConnectBlock with pindex->phashBlock NULL.
2012-10-24 02:13:03 -04:00
Pieter Wuille 4afc0b5411 Bugfix: actually use CCoinsViewMemPool 2012-10-23 01:43:33 +02:00
Pieter Wuille c2ed184f98 Added some comments
Some clarifications after a code review by Mike Hearn.
2012-10-23 00:27:17 +02:00
Pieter Wuille 1e64c2d585 Bugfix: off-by-one in priority calculation 2012-10-23 00:23:39 +02:00
Pieter Wuille 9e957fb3b1 Bugfix: add missing fee check 2012-10-23 00:23:39 +02:00
Pieter Wuille 56424040a4 Bugfix: off-by-one error in coinbase maturity check 2012-10-23 00:23:39 +02:00
Philip Kaufmann 729b180686 change blockchain -> block chain (spelling)
- Wiki says "block chain" is correct ;)
- remove some unneeded spaces I found in the source, while fixing the spelling
2012-10-21 21:32:25 +02:00
Philip Kaufmann 039bcbf12d remove init messages from ThreadImport()
- remove uiInterface.InitMessage() calls from ThreadImport(), as Qt
  doesn't like them getting called out of it's main thread and because the
  thread will continue to run after the GUI was loaded
2012-10-21 21:16:52 +02:00
Pieter Wuille beeb57610c Add gettxout and gettxoutsetinfo RPCs 2012-10-20 23:08:57 +02:00
Pieter Wuille 2d8a48292b LevelDB block and coin databases
Split off CBlockTreeDB and CCoinsViewDB into txdb-*.{cpp,h} files,
implemented by either LevelDB or BDB.

Based on code from earlier commits by Mike Hearn in his leveldb
branch.
2012-10-20 23:08:57 +02:00
Pieter Wuille 44d40f26dc Flush and sync block data 2012-10-20 23:08:57 +02:00
Pieter Wuille d979e6e36a Use singleton block tree database instance 2012-10-20 23:08:57 +02:00
Pieter Wuille 857c61df0b Prepare database format for multi-stage block processing
This commit adds a status field and a transaction counter to the block
indexes.
2012-10-20 23:08:57 +02:00
Pieter Wuille 13c51f20f6 Direct CCoins references
To prevent excessive copying of CCoins in and out of the CCoinsView
implementations, introduce a GetCoins() function in CCoinsViewCache
with returns a direct reference. The block validation and connection
logic is updated to require caching CCoinsViews, and exploits the
GetCoins() function heavily.
2012-10-20 23:08:57 +02:00
Pieter Wuille 64dd46fd05 Transaction hash caching
Use CBlock's vMerkleTree to cache transaction hashes, and pass them
along as argument in more function calls. During initial block download,
this results in every transaction's hash to be only computed once.
2012-10-20 23:08:57 +02:00
Pieter Wuille ae8bfd12da Batch block connection during IBD
During the initial block download (or -loadblock), delay connection
of new blocks a bit, and perform them in a single action. This reduces
the load on the database engine, as subsequent blocks often update an
earlier block's transaction already.
2012-10-20 23:08:57 +02:00
Pieter Wuille 450cbb0944 Ultraprune
This switches bitcoin's transaction/block verification logic to use a
"coin database", which contains all unredeemed transaction output scripts,
amounts and heights.

The name ultraprune comes from the fact that instead of a full transaction
index, we only (need to) keep an index with unspent outputs. For now, the
blocks themselves are kept as usual, although they are only necessary for
serving, rescanning and reorganizing.

The basic datastructures are CCoins (representing the coins of a single
transaction), and CCoinsView (representing a state of the coins database).
There are several implementations for CCoinsView. A dummy, one backed by
the coins database (coins.dat), one backed by the memory pool, and one
that adds a cache on top of it. FetchInputs, ConnectInputs, ConnectBlock,
DisconnectBlock, ... now operate on a generic CCoinsView.

The block switching logic now builds a single cached CCoinsView with
changes to be committed to the database before any changes are made.
This means no uncommitted changes are ever read from the database, and
should ease the transition to another database layer which does not
support transactions (but does support atomic writes), like LevelDB.

For the getrawtransaction() RPC call, access to a txid-to-disk index
would be preferable. As this index is not necessary or even useful
for any other part of the implementation, it is not provided. Instead,
getrawtransaction() uses the coin database to find the block height,
and then scans that block to find the requested transaction. This is
slow, but should suffice for debug purposes.
2012-10-20 23:08:57 +02:00
Pieter Wuille bba89aa82a Pre-allocate block and undo files in chunks
Introduce a AllocateFileRange() function in util, which wipes or
at least allocates a given range of a file. It can be overriden
by more efficient OS-dependent versions if necessary.

Block and undo files are now allocated in chunks of 16 and 1 MiB,
respectively.
2012-10-20 23:08:57 +02:00
Pieter Wuille 5382bcf8cd Multiple blocks per file
Change the block storage layer again, this time with multiple files
per block, but tracked by txindex.dat database entries. The file
format is exactly the same as the earlier blk00001.dat, but with
smaller files (128 MiB for now).

The database entries track how many bytes each block file already
uses, how many blocks are in it, which range of heights is present
and which range of dates.
2012-10-20 23:08:57 +02:00
Pieter Wuille 8adf48dc9b Preliminary undo file creation
Create files (one per block) with undo information for the transactions
in it.
2012-10-20 23:08:57 +02:00
Pieter Wuille 630fd8dcb6 One file per block
Refactor of the block storage code, which now stores one file per block.
This will allow easier pruning, as blocks can be removed individually.
2012-10-20 23:08:57 +02:00
Pieter Wuille 0fa593d0fb Compact serialization for amounts
Special serializer/deserializer for amount values. It is optimized for
values which have few non-zero digits in decimal representation. Most
amounts currently in the txout set take only 1 or 2 bytes to
represent.
2012-10-20 23:08:56 +02:00
Jeff Garzik 38ac953b9d Merge pull request #1880 from sipa/threadimport
Move external block import to separate thread
2012-10-20 13:36:36 -07:00
Jeff Garzik dee0ee2ac9 Merge pull request #1742 from sipa/canonical
Check for canonical public keys and signatures
2012-10-20 10:56:04 -07:00
Pieter Wuille 66b02c93e6 Move external block import to separate thread 2012-10-20 01:54:10 +02:00
Jeff Garzik de2b9459bd Merge pull request #1834 from jgarzik/kickblocks
P2P: Do not request blocks from peers with fewer blocks than us
2012-10-08 15:15:58 -07:00
Jeff Garzik b855abb8db Revert "Send 'mempool' P2P command at the start of each P2P session"
Fat-fingered on github, and merged this too early.

This reverts commit 22f9b06903.
2012-10-08 18:14:15 -04:00
Jeff Garzik 56caa38a67 Merge pull request #1833 from jgarzik/mempool-query
Send 'mempool' P2P command at the start of each P2P session
2012-10-08 15:12:25 -07:00
Wladimir J. van der Laan 529a4d4824 remove "checkorder" and "reply" P2P commands
These command are a leftover from send-to-IP transactions, which have been
removed a long time ago.
Also removes CNode::mapRequests and CNode::PushRequests, as these were
only used for the mentioned commands.
2012-10-03 20:09:33 +02:00
Philip Kaufmann d210f4f5b8 fix -Wformat warnings all over the source 2012-10-01 19:45:42 +02:00
Jeff Garzik 22f9b06903 Send 'mempool' P2P command at the start of each P2P session
to query remote node mempool contents.
2012-09-24 13:53:44 -04:00
Jeff Garzik 93dd68e924 P2P: Do not request blocks from peers with fewer blocks than us
If the remote node has a shorter chain, do not waste our
special getblocks request on them.
2012-09-24 13:26:09 -04:00
Pieter Wuille 58bc86e37f Check for canonical public keys and signatures
Only enabled inside tests for now.
2012-09-21 01:24:25 +02:00
Jeff Garzik b1d3e95a0a When rejected TX relay due to lack of fees, log full txid 2012-09-18 15:24:31 -04:00
Jeff Garzik f8c449b5c8 Merge pull request #1812 from jgarzik/misc-07
Two minor generic cleanups done during OP_DROP hacking
2012-09-18 09:14:53 -07:00
Gregory Maxwell ab91bf39b7 Apply BIP30 checks to all blocks except the two historic violations.
Matt pointed out some time ago that there existed a minor DOS
attack where a node in its initial block download could be wedged
by an overwrite attack in a fork created between checkpoints before
a time where BIP30 was enforced. Now that the BIP30 timestamp
is irreversibly past the check can be more aggressive and apply to
all blocks except the two historic violations.
2012-09-09 20:11:04 -04:00
Jeff Garzik 17f8d6e400 Improve debug logging, for mempool TXs that do not include sufficient fees 2012-09-09 17:05:26 -04:00
Jeff Garzik 76970091f1 Cosmetic: move CTransaction::GetMinFee out of header file 2012-09-09 17:01:18 -04:00
Gavin Andresen 91c218a1cb Merge branch 'testnet_alert' of git://github.com/gavinandresen/bitcoin-git 2012-09-05 11:38:38 -04:00
Philip Kaufmann 8d367c7e66 fix signed/unsigned usage in BlockFilePath() 2012-09-05 08:34:41 +02:00
Jeff Garzik 42613c97d5 Add block file naming helper, BlockFilePath() 2012-09-04 21:40:26 -04:00
Jeff Garzik bec02998b4 Merge pull request #1779 from xanatos/patch-15
Useless vector declaration
2012-09-04 08:59:05 -07:00
xanatos 89fbd1f11c Useless vector declaration
The vector isn't referenced in the small code block it's declared. I don't see any "useful" side effect in its declaration.
2012-09-03 17:53:27 +03:00
Wladimir J. van der Laan 4d1d94c56c Rename CreateThread to NewThread
Prevent clash with win32 API symbol
2012-08-29 20:25:37 +02:00
Gavin Andresen f35c6c4fb9 Refactor: move alert code from main to alert.cpp/h 2012-08-28 17:04:54 -04:00
Gavin Andresen ea2fda46c3 Special-case the last alert for alert-key-compromised case
Hard-code a special nId=max int alert, to be broadcast if the
alert key is ever compromised. It applies to all versions, never
expires, cancels all previous alerts, and has a fixed message:
   URGENT: Alert key compromised, upgrade required

Variations are not allowed (ignored), so an attacker with
the private key cannot broadcast empty-message nId=max alerts.
2012-08-27 10:22:57 -04:00
Gavin Andresen d5a52d9b3e Alert system DoS prevention
This fixes two alert system vulnerabilities found by
Sergio Lerner; you could send peers unlimited numbers
of invalid alert message to try to either fill up their
debug.log with messages and/or keep their CPU busy
checking signatures.

Fixed by disconnecting/banning peers if they send 10 or more
bad (invalid/expired/cancelled) alerts.
2012-08-26 17:08:18 -04:00
Pieter Wuille 65ce215641 Make 0-value outputs non-standard 2012-08-24 12:15:12 +02:00
Gregory Maxwell bdab0cf58c Avoid leaving return types or function attributes on their own lines. 2012-08-24 02:48:19 -04:00
Pieter Wuille 5c88e3c108 Do not accept orphan blocks in -loadblock mode 2012-08-21 19:18:53 +02:00
Gavin Andresen d18f2fd9d6 Reject block.nVersion<=1 blocks if network has upgraded to version=2
If 950 of the last 1,000 blocks are nVersion=2, reject nVersion=1
(or zero, but no bitcoin release has created block.nVersion=0) blocks
-- 75 of last 100 on testnet3.

This rule is being put in place now so that we don't have to go
through another "express support" process to get what we really
want, which is for every single new block to include the block height
in the coinbase.
2012-08-20 10:46:07 -04:00
Gavin Andresen de237cbfa4 Block height in coinbase as a new block rule
"Version 2" blocks are blocks that have nVersion=2 and
have the block height as the first item in their coinbase.
Block-height-in-the-coinbase is strictly enforced when
version=2 blocks are a supermajority in the block chain
(750 of the last 1,000 blocks on main net, 51 of 100 for
testnet). This does not affect old clients/miners at all,
which will continue producing nVersion=1 blocks, and
which will continue to be valid.
2012-08-20 10:46:07 -04:00
Jeff Garzik b3a570d158 Merge pull request #1641 from jgarzik/mempool
Add 'mempool' P2P command, and extend 'getdata' behavior
2012-08-20 07:21:34 -07:00
Jeff Garzik dabb95b892 Merge pull request #1678 from Diapolo/LoadExternalBlockFile_add_timer
log how long LoadExternalBlockFile() takes in ms (Benchmark)
2012-08-17 08:45:11 -07:00
Philip Kaufmann 1e7027b41e fix a compiler sign warning in OpenBlockFile() 2012-08-17 10:35:51 +02:00
Philip Kaufmann 746f502a79 log how long LoadExternalBlockFile() takes in ms (Benchmark) 2012-08-17 00:14:40 +02:00
Gregory Maxwell 8ce7915aad Merge pull request #1612 from luke-jr/opti_getblkhash
Optimize JSON-RPC getblockhash
2012-08-01 11:49:26 -07:00
Luke Dashjr 1be064190e Optimize JSON-RPC getblockhash
- If the height is in the first half, start at the genesis block and go up, rather than at the top
- Cache the last lookup and use it as a reference point if it's close to the next request, to make linear lookups always fast
2012-08-01 18:23:30 +00:00
Jeff Garzik f81e6f779b Merge pull request #1632 from luke-jr/spelling
Fix spelling and grammar errors
2012-08-01 10:56:47 -07:00
Luke Dashjr b49f1398a1 Bugfix: Correct English grammar regarding "'s" 2012-08-01 17:50:00 +00:00
Luke Dashjr 814efd6f1f Bugfix: Fix a variety of misspellings 2012-08-01 17:49:51 +00:00
Philip Kaufmann e6bc9c35f3 Update Warning-strings to use a standard-format
- ensure warnings always start with "Warning:" and that the first
  character after ":" is written uppercase
- ensure the first sentence in warnings ends with an "!"
- remove unneeded spaces from Warning-strings
- add missing Warning-string translation
- remove a "\n" and replace with untranslatable "<br><br>"
2012-08-01 19:33:32 +02:00
Jeff Garzik 05a85b2b38 Add 'mempool' P2P command, and extend 'getdata' behavior
to permit downloading of mempool transactions from the remote peer.
2012-07-31 17:42:35 -04:00
Gregory Maxwell a9d811a976 Switch testnet3's message bytes to avoid connecting to old nodes.
The new bytes are based on "11" to appeal to Gavin's 11 fetish.

This breaks existing testnet3 nodes as the blockchain files
are also versioned.  To upgrade a node delete everything
except wallet.dat from your .bitcoin/testnet3 folder.
2012-07-26 17:50:23 -04:00
Gavin Andresen e0e54740b1 Handle should-never-happen case of orphan in mempool 2012-07-26 15:29:59 -04:00
Gavin Andresen c555400ca1 When creating new blocks, sort 'paid' area by fee-per-kb
Modify CreateNewBlock so that instead of processing all transactions
in priority order, process the first 27K of transactions in
priority order and then process the rest in fee-per-kilobyte
order.

This is the first, minimal step towards better a better fee-handling
system for both miners and end-users; this patch should be easy
to backport to the old versions of Bitcoin, and accomplishes the
most important goal-- allow users to "buy their way in" to blocks
using transaction fees.
2012-07-26 14:24:19 -04:00
Gavin Andresen 29c8fb0d93 Merge branch 'checknewblock' of git://github.com/luke-jr/bitcoin 2012-07-26 13:55:27 -04:00
Rune K. Svendsen 5f2e4b0565 Let the comment in GetBlockValue() reflect the uncertainty about the time interval between subsidy reductions 2012-07-18 09:37:05 +02:00
Giel van Schijndel 9f46ab62b1 Fix thread names after review
* Fix wrong thread name for wallet *relocking* thread
  - Was named the unlocking thread
 * Use consistent naming

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-07-17 01:50:35 +02:00
Giel van Schijndel 96931d6f78 Give threads a recognisable name to aid in debugging
NOTE: These thread names are visible in gdb when using 'info threads'.
      Additionally both 'top' and 'ps' show these names *unless* told to
      display the command-line instead of task name.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2012-07-17 01:50:35 +02:00
Luke Dashjr 639b61d78e Tests for CreateNewBlock 2012-07-12 16:35:34 +00:00
Luke Dashjr fbf99a9cdc Merge branch 'checknewblock_0.6.0' into checknewblock
Conflicts:
	src/main.cpp
2012-07-11 04:24:58 +00:00
Gavin Andresen 2a919e396d Warn if blockchain majority doesn't match CBlock::CURRENT_VERSION
This adds a warning "this version is obsolete, upgrade required" if
more than 50 of the previous 100 blocks in the blockchain are
a new version.
2012-07-06 11:37:01 -04:00
Gavin Andresen dae3e10a5a Treat non-version-1 transactions as non-standard
Adds CBlock::CURRENT_VERSION and CTransaction::CURRENT_VERSION
constants, and makes non-CURRENT_VERSION transactions nonstandard.
This will help make future upgrades smoother.
2012-07-06 11:37:01 -04:00
Jeff Garzik 6e3a1a3742 Merge pull request #1304 from rebroad/ShowBlockTimestamp
Show block timestamp
2012-07-05 15:28:42 -07:00
Jeff Garzik f77654a0e9 CTxMemPool: eliminate redundant lock, GetHash() call
::addUnchecked()'s only caller already takes the necessary lock,
and has already calculated the TX's hash.
2012-07-04 01:12:44 -04:00
Matt Corallo 96929a5515 Remove duplicate GetHash() in ConnectBlock 2012-07-04 00:04:57 -04:00
Jeff Garzik e75acc006e Merge pull request #1511 from jgarzik/quieten2
Quieten 'getdata' P2P message output
2012-06-27 09:06:59 -07:00
Pieter Wuille abbb9a829c Merge pull request #1347 from rebroad/FixAlreadyAskedFor
mapAlreadyAskedFor gets additions when AlreadyHave()
2012-06-27 08:06:57 -07:00
Matt Corallo 9d6cd04b3b Stop processing messages on full send buffer and dont disconnect.
Also decrease default send/receive buffer sizes from 10 to 5 mb
as this patch makes it easy for a node to fill both instead of
only send.
2012-06-27 15:31:34 +02:00
Gregory Maxwell 817ee0d826 Merge pull request #1174 from sipa/torhs
Tor hidden service support
2012-06-23 19:21:13 -07:00
Gregory Maxwell 0ae2ac5431 Merge pull request #1503 from gmaxwell/testnet_tweaks
Remove some rule differences which aren't needed with testnet3.
2012-06-23 19:02:55 -07:00
Jeff Garzik 983e4bdef0 Quieten 'getdata' P2P message output
Output one message per getdata, not one message per 'inv' entry.
2012-06-23 21:38:33 -04:00
Pieter Wuille 863e995b79 Debug version messages 2012-06-23 01:11:38 +02:00
Jeff Garzik d62a1947be Merge pull request #1458 from jgarzik/tracenet
Introduce -tracenet option, thereby quieting some redundant debug messages
2012-06-22 10:13:31 -07:00
Jeff Garzik d07eaba195 Introduce -debugnet option, thereby quieting some redundant debug messages
Prior to this change, each TX typically generated 3+ debug messages,

	askfor tx 8644cc97480ba1537214   0
	sending getdata: tx 8644cc97480ba1537214
	askfor tx 8644cc97480ba1537214   1339640761000000
	askfor tx 8644cc97480ba1537214   1339640881000000
	CTxMemPool::accept() : accepted 8644cc9748 (poolsz 6857)

After this change, there is only one message for each valid TX received

	CTxMemPool::accept() : accepted 22a73c5d8c (poolsz 42)

and two messages for each orphan tx received

	ERROR: FetchInputs() : 673dc195aa mempool Tx prev not found 1e439346fc
	stored orphan tx 673dc195aa (mapsz 19)

The -debugnet option, or its superset -debug, will restore the full debug
output.
2012-06-22 13:11:57 -04:00
Gregory Maxwell e6332751c6 Remove some rule differences which aren't needed with testnet3.
Bip16 and Bip30 had early activation dates for testnet, but
with the reset they might as well use the same dates as
the main network.
2012-06-22 11:50:52 -04:00
Jeff Garzik 25d5c19522 RPC: add 'getrawmempool', listing all transaction ids in memory pool 2012-06-22 11:43:34 -04:00
Gavin Andresen c283b3c569 print large orphan warning BEFORE deleting pvMsg 2012-06-19 17:14:29 -04:00
Gavin Andresen 550c73f4c8 Merge branch 'signbugs' of https://github.com/wizeman/bitcoin
Resolved minor conflict in main.cpp
2012-06-18 10:48:40 -04:00
Pieter Wuille c971112dfa Use a 64-bit nonce in ping
Former code sent '0' as nonce, which was serialized as 32-bit.
2012-06-14 18:31:08 +02:00
Philip Kaufmann 9247134eab introduce a new StartShutdown() function, which starts a thread with Shutdown() if no GUI is used and calls uiInterface.QueueShutdown() if a GUI is used / all direct uiInterface.QueueShutdown() calls are replaced with Shutdown() - this ensures a clean GUI shutdown, even when catching a SIGTERM and allows the BitcoinGUI destructor to get called (which fixes a tray-icon issue and keeps the tray-icon until Bitcoin-Qt exits) 2012-06-12 07:21:03 +02:00
Pieter Wuille 587f929c64 Rework network config settings 2012-05-31 18:12:35 +02:00
R E Broadley e69a797990 Show the timestamp for the block.
wrap lines
2012-05-29 20:11:37 +01:00
Gregory Maxwell 20cb17e1f9 Merge pull request #1392 from gavinandresen/testnet_reset
Testnet reset
2012-05-27 19:26:47 -07:00
Luke Dashjr 3cd01fdf0e CreateNewBlock: Check that the produced CBlock is acceptable (except for proof-of-work and merkletree, since those need to be provided later)
This throws an exception from CreateNewBlock otherwise, which is not safe without #1245!
2012-05-27 12:27:33 +00:00
Gavin Andresen 248bceb30c Fix issue#1082, testnet difficulty unsigned integer underflow 2012-05-25 14:36:40 -04:00
Gavin Andresen feeb761ba0 Testnet, Mark III 2012-05-25 14:36:40 -04:00
Pieter Wuille fd61d6f506 Encapsulate public keys in CPubKey 2012-05-24 19:58:12 +02:00
Jeff Garzik ec9c902133 Merge pull request #1383 from jgarzik/rawtx
JSON-RPC: Add 'sendrawtx' op, for sending pre-built TX's to network
2012-05-24 09:14:04 -07:00
Jeff Garzik 429039d45d Refactor: move runCommand() to util.cpp 2012-05-23 23:10:59 -04:00
Jeff Garzik 976c08b68a JSON-RPC: Add 'sendrawtx' op, for sending pre-built TX's to network 2012-05-23 16:21:25 -04:00
Jeff Garzik 0134a1c08c Merge branch 'dbenv' into tmp
Conflicts:
	src/db.cpp
2012-05-22 17:45:00 -04:00
Jeff Garzik 5d0f7c4f47 Merge pull request #1381 from jgarzik/check-deser
Prevent crashes due to missing or corrupted database records
2012-05-22 14:39:49 -07:00
Jeff Garzik 78eb2789b2 ProcessMessage(): remove duplicate orphan tx debug message 2012-05-22 15:33:04 -04:00
Jeff Garzik 8fe791e4e2 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-05-22 15:23:17 -04:00
Gavin Andresen 43d16f0361 Merge branch 'master' of github.com:bitcoin/bitcoin 2012-05-22 11:14:30 -04:00
Gavin Andresen d0e4051cd8 Merge branch 'optimize' 2012-05-22 11:13:00 -04:00
R E Broadley ea591ead85 Correct debug.log output to show correct function the debug is coming from. 2012-05-22 12:06:08 +01:00
Pieter Wuille 46784d0826 Merge pull request #1354 from fanquake/master
Update Header Licenses
2012-05-20 12:27:50 -07:00
Wladimir J. van der Laan 239c11d0dd Make testcases build, prevent windows symbol collision 2012-05-20 10:44:50 +02:00
Wladimir J. van der Laan ab1b288fa7 Convert UI interface to boost::signals2.
- Signals now go directly from the core to WalletModel/ClientModel.
  - WalletModel subscribes to signals on CWallet: Prepares for multi-wallet support, by no longer assuming an implicit global wallet.
- Gets rid of noui.cpp, the few lines that were left are merged into init.cpp
- Rename wxXXX message flags to MF_XXX, to make them UI indifferent.
- ThreadSafeMessageBox no longer returns the value `4` which was never used, converted to void.
2012-05-20 10:44:50 +02:00
Wladimir J. van der Laan fe4a655042 Fine-grained UI updates
Gets rid of `MainFrameRepaint` in favor of specific update functions that tell the UI exactly what changed.

This improves the efficiency of various handlers. Also fixes problems with mined transactions not showing up until restart.

The following notifications were added:

- `NotifyBlocksChanged`: Block chain changed
- `NotifyKeyStoreStatusChanged`: Wallet status (encrypted, locked) changed.
- `NotifyAddressBookChanged`: Address book entry changed.
- `NotifyTransactionChanged`: Wallet transaction added, removed or updated.
- `NotifyNumConnectionsChanged`: Number of connections changed.
- `NotifyAlertChanged`: New, updated or cancelled alert. As this finally makes it possible for the UI to know when a new alert arrived, it can be shown as OS notification.

These notifications could also be useful for RPC clients. However, currently, they are ignored in bitcoind (in noui.cpp).

Also brings back polling with timer for numBlocks in ClientModel. This value updates so frequently during initial download that the number of signals clogs the UI thread and causes heavy CPU usage. And after initial block download, the value changes so rarely that a delay of half a second until the UI updates is unnoticable.
2012-05-20 10:41:54 +02:00
Jeff Garzik b52a270538 Reorganize(): remove spurious TxnAbort()
If Reorganize() fails, then its caller, CBlock::SetBestChain(),
will call TxnAbort().

Redundant TxnAbort() calls are harmless.  The second will return an
error return value, with no other side effects.  TxnAbort() return
values are generally never checked.  The impact is nil.
2012-05-19 20:40:43 -04:00
Gavin Andresen 973ca019bc Merge pull request #1296 from Diapolo/CheckDiskSpace
make CheckDiskSpace() use 50 * 1024 * 1024 Bytes
2012-05-19 05:48:48 -07:00
Gavin Andresen 4add41a2a6 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-05-18 10:41:18 -04:00
Gavin Andresen 7a15109c04 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-05-18 10:41:17 -04:00
Gavin Andresen 77b99cf7ad Optimize orphan transaction handling
Changes suggested by Sergio Demian Lerner to
help prevent potential DoS attacks.
2012-05-18 10:13:21 -04:00
Fordy 3a25a2b9b0 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-18 22:02:28 +08:00
Jeff Garzik 6d64a0bfed 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-05-17 20:36:55 -04:00
R E Broadley 757cec9ddd Should only be mapped when the getdata is done.
Without this change, mappings will be created even after AlreadyHave equals true, and will never be erased.
2012-05-17 23:01:00 +01:00
Gavin Andresen f718aedd9f Refactor: GetRandHash() method for util 2012-05-17 16:33:27 -04:00
Jeff Garzik cf2f7c30a3 Merge pull request #1295 from jgarzik/txn-retval
[FIX] Always check return values of TxnBegin() and TxnCommit()
2012-05-17 08:49:16 -07:00
Pieter Wuille 385f730f31 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-15 17:53:46 +02:00
Philip Kaufmann 966ae00fe4 make CheckDiskSpace() use a global static const uint64 for checking required disk space and remove 2 ugly spaces from a message string 2012-05-14 14:02:36 +02:00
Jeff Garzik 0fb78eae34 Always check return values of TxnBegin() and TxnCommit() 2012-05-14 01:11:11 -04:00
Ricardo M. Correia 4843b55fd1 Make CNetAddr::GetHash() return an unsigned val.
This prevents an undefined operation in main.cpp, when shifting the hash value
left by 32 bits.
Shifting a signed int left into the sign bit is undefined in C++11.
2012-05-13 21:42:54 +02:00
Philip Kaufmann 0985816bf6 ensure that no double timestamps show up in the debug.log, by removing manual timestamps from the source (now only -logtimestamps parameter adds timestamps to debug.log) 2012-05-13 14:36:35 +02:00
Pieter Wuille a3878873f3 Merge pull request #1021 from sipa/ipv6
IPv6 node support
2012-05-11 18:23:56 -07:00
Pieter Wuille 090e5b40f1 Limited relaying/storing of foreign addresses
Introduce a boolean variable for each "network" (ipv4, ipv6, tor, i2p),
and track whether we are likely to able to connect to it. Addresses in
"addr" messages outside of our network get limited relaying and are not
stored in addrman.
2012-05-11 15:29:19 +02:00
Pieter Wuille 23aa78c405 IPv6 node support
This will make bitcoin relay valid routable IPv6 addresses, and when
USE_IPV6 is enabled, listen on IPv6 interfaces and attempt connections
to IPv6 addresses.
2012-05-11 15:29:19 +02:00
Jeff Garzik 33a53bc13b CTxMemPool::accept(): do not log FetchInputs failure redundantly
FetchInputs already logs failures internally.  This commit makes the logging
more consistent with other FetchInputs callsites also.

Prior to this commit, two log lines were logged for one condition:

     ERROR: FetchInputs() : de15fde415 mempool Tx prev not found a2c75da227
     ERROR: CTxMemPool::accept() : FetchInputs failed de15fde415

After this commit, only one line is logged:

     ERROR: FetchInputs() : e0507ab2c7 mempool Tx prev not found 9a620262cd
2012-05-10 20:31:46 -04:00
Jeff Garzik 133dce6a37 CTxMemPool: consolidate two frequently-printed debug.log lines into one
Previously, a single TX would trigger two log lines in quick succession,

        addUnchecked(): size 152
        CTxMemPool::accept() : accepted c4cfdd48b7

After this change, only one log line is used:

        CTxMemPool::accept() : accepted 98885e65db (poolsz 26)
2012-05-10 20:20:31 -04:00
Pieter Wuille f621326c24 Clean up warnings
* Use -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameters
* Remove xCXXFLAGS usage in makefile.unix
* Fix several recent and older sign-compare warnings
2012-05-09 03:48:30 +02:00
Jeff Garzik 203f9e6c00 Merge branch 'tmp-ipv6' into merge-ipv6 2012-05-08 19:43:17 -04:00
Jeff Garzik a2ea797593 Merge pull request #1180 from jgarzik/sign-compare
Fix final sign comparison warnings
2012-05-08 13:50:27 -07:00
Gregory Maxwell 2f1dca645b Merge pull request #841 from sipa/getalltransactions
gettransaction RPC for non-wallet transactions
2012-05-08 13:19:11 -07:00
Gregory Maxwell f1ae31d8af Merge pull request #883 from sipa/loadblock
Add -loadblock to load from an external blk000?.dat file
2012-05-08 12:37:27 -07:00
Pieter Wuille 6860133373 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-06 23:37:45 +02:00
Luke Dashjr 82e6b92b0a Bugfix: %-12I64d is not valid and causes the parameter to be skipped, use %12"PRI64d" instead 2012-05-05 14:24:55 -04:00
Pieter Wuille 39857190de Support for multiple local addresses 2012-05-04 16:12:23 +02:00
Pieter Wuille 478b01d9a7 Add -seednode connections, and use this for -dnsseed + -proxydns 2012-05-04 16:11:54 +02:00
Jeff Garzik 10ab9c2f42 OpenBlockFile(): cast to eliminate signed/unsigned comparison warning
nFile's null value is -1.  Cast that to unsigned int, to avoid warning.

Additionally, avoid nFile==0 because the first valid value is 1.
2012-05-01 17:50:33 -04:00
Gavin Andresen be8651dde7 Check earlier for blocks with duplicate transactions. Fixes #1167 2012-04-30 11:08:07 -04:00
Jeff Garzik 1d8c7a9557 Add casts for unavoidable signed/unsigned comparisons
At these code sites, it is preferable to cast rather than change
a variable's type.
2012-04-23 14:14:36 -04:00
Jeff Garzik c0a0a93d02 Test ScriptSigArgsExpected() for error, before accumulating return value 2012-04-23 14:14:36 -04:00
Jeff Garzik 7bd9c3a3cf SigOp and orphan-tx constants and counts are always unsigned.
Fixes several sign-comparison warnings.
2012-04-23 14:14:03 -04:00
Pieter Wuille 1d740055da -loadblock to load from an external blk000?.dat file 2012-04-22 03:09:35 +02:00
Pieter Wuille c73ba23eb5 gettransaction RPC for non-wallet transactions
Works for wallet transactions, memory-pool transaction and block chain
transactions.

Available for all:
 * txid
 * version
 * locktime
 * size
 * coinbase/inputs/outputs
 * confirmations

Available only for wallet transactions:
 * amount
 * fee
 * details
 * blockindex

Available for wallet transactions and block chain transactions:
 * blockhash
 * time
2012-04-18 23:42:07 +02:00
Pieter Wuille c23617fef3 Merge remote-tracking branch 'jgarzik/mempool' 2012-04-17 20:12:48 +02:00
Pieter Wuille caeddc5d37 Merge pull request #1117 from sipa/deadlockfix
Fix potential deadlock
2012-04-17 11:05:02 -07:00
Pieter Wuille 6b6aaa1698 Further reduce header dependencies
This commit removes the dependency of serialize.h on PROTOCOL_VERSION,
and makes this parameter required instead of implicit. This is much saner,
as it makes the places where changing a version number can have an
influence obvious.
2012-04-17 20:03:42 +02:00
Pieter Wuille ed6d0b5f85 Remove headers.h 2012-04-17 20:00:55 +02:00
Gavin Andresen b97d54355e Merge pull request #1106 from jgarzik/sign-compare
Fix many sign-comparison warnings found in bitcoin codebase
2012-04-17 10:55:56 -07:00
Pieter Wuille c581cc16bb 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 18:50:52 +02:00
Jeff Garzik ce8c93498a main.cpp: replace tabs with spaces
Sometimes they sneak in through the 'vi' door
2012-04-17 12:31:51 -04:00
Jeff Garzik 8bff8ac079 AlreadyHave(): only hold lock during mapTransactions access 2012-04-17 12:30:00 -04:00
Jeff Garzik dd21ce5f1b Merge pull request #1094 from jgarzik/already-have-locking
Locking fix for AlreadyHave()
2012-04-17 09:23:49 -07:00
Jeff Garzik 865a0c1674 Merge pull request #1081 from jgarzik/pong
BIP 0031: pong message
2012-04-17 08:51:17 -07:00
Jeff Garzik c376ac359e 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-15 16:52:09 -04:00
Jeff Garzik ca4c4c53a8 CTxMemPool: add helper methods, to reduce global mempool.mapTx accesses 2012-04-15 14:43:19 -04:00
Jeff Garzik d01903e751 CTxMemPool: encapsulate AcceptToMemoryPool 2012-04-15 14:43:19 -04:00
Jeff Garzik 8e45ed66dd CTxMemPool: encapsulate AddToMemoryPoolUnchecked(), RemoveFromMemoryPool(),
and nPooledTx
2012-04-15 14:42:52 -04:00
Jeff Garzik 235507ae48 New class CTxMemPool, encapsulating TX memory pool data members 2012-04-15 14:41:27 -04:00
Wladimir J. van der Laan da7bbd9dfd fix warnings: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses] 2012-04-15 13:40:14 +02:00
Jeff Garzik 8deb9822e4 Locking fix for AlreadyHave()
Access to mapTransactions[] must be guarded by cs_mapTransactions lock.

Also, reformat long lines to make the switch statement more readable.
2012-04-13 18:24:55 -04:00
Jeff Garzik 9925d34a49 Database micro-optimization for "tx" network message
Open database once per "tx" message, rather than multiple times,
in the case of orphan transaction presence.

As a side effect, a now-unused CTransaction::AcceptToMemoryPool()
variant is removed.
2012-04-13 17:48:15 -04:00
Jeff Garzik 8b09cd3a4d Replace several network protocol version numbers with named constants
stored in version.h.

Also, a minor CAddress code reformat while we're in there, fixing
some incorrect indentation.
2012-04-12 20:07:49 -04:00
Jeff Garzik 460b66b14b Remove obsolete Win32 AffinityBugWorkaround()
Reference miner exists for testnet-in-a-box type situations, and as a
reference.  We don't care enough about highly optimized internal
mining to keep workarounds like this.
2012-04-12 13:24:00 -04:00
Jeff Garzik 93e447b631 BIP 0031: pong message
Add a pong message that is sent in reply to a ping. It echoes back a nonce
field that is now added to the ping message. Send a nonce of zero in ping
messages.

Original author: Mike Hearn @ Google

Modified Mike's change to introduce a mild form of protocol documentation in
version.h.
2012-04-12 12:11:56 -04:00
Pieter Wuille ee12c3d60c Use filesystem::path instead of manual string tinkering
Where possible, use boost::filesystem::path instead of std::string or
char* for filenames. This avoids a lot of manual string tinkering, in
favor of path::operator/.

GetDataDir is also reworked significantly, it now only keeps two cached
directory names (the network-specific data dir, and the root data dir),
which are decided through a parameter instead of pre-initialized global
variables.

Finally, remove the "upgrade from 0.1.5" case where a debug.log in the
current directory has to be removed.
2012-04-11 22:30:23 +02:00
Pieter Wuille 702764f53b Merge pull request #1054 from sipa/buildinfo
Build identification strings
2012-04-10 13:31:12 -07:00
Pieter Wuille a20c0d0f67 Build identification strings
All client version information is moved to version.cpp, which optionally
(-DHAVE_BUILD_INFO) includes build.h. build.h is automatically generated
on supporting platforms via contrib/genbuild.sh, using git describe.

The git export-subst attribute is used to put the commit id statically
in version.cpp inside generated archives, and this value is used if no
build.h is present.

The gitian descriptors are modified to use git archive instead of a
copy, to create the src/ directory in the output. This way,
src/src/version.cpp will contain the static commit id. To prevent
gitian builds from getting the "-dirty" marker in their git-describe
generated identifiers, no touching of files or running sed on the
makefile is performed anymore. This does not seem to influence
determinism.
2012-04-10 18:16:53 +02:00
Pieter Wuille f8dcd5ca6f Use scoped locks instead of CRITICAL_BLOCK 2012-04-09 01:59:46 +02:00
Wladimir J. van der Laan 7cfbe1fee4 qtui.h/noui.h interface cleanup
- rename wxMessageBox, remove redundant arguments to noui/qtui calls
- also, add flag to force blocking, modal dialog box for disk space warning etc
- clarify function naming
- no more special MessageBox needed from AppInit2, as window object is created before calling AppInit2
2012-04-04 09:37:25 +02:00
Wladimir J. van der Laan 1a3f0da922 support RPC stop and encryptwallet with UI 2012-04-04 09:35:01 +02:00
Wladimir J. van der Laan f0b5e9e116 remove unused CalledSetStatusBar and UIThreadCall notifications 2012-04-04 09:35:01 +02:00
Gavin Andresen 85ea8b4f43 Merge pull request #951 from TheBlueMatt/headerslimit
Limit getheaders to a hard 2000.
2012-04-02 11:22:11 -07:00
Gavin Andresen a6b4a11385 Merge branch 'addrman' of https://github.com/sipa/bitcoin 2012-03-22 09:19:01 -04:00
Gavin Andresen 8f188ece3c Remove -bip16 and -paytoscripthashtime command-line arguments 2012-03-21 15:45:58 -04:00
Gavin Andresen b2fe3a5ca6 Merge pull request #948 from sipa/unstuck
Prevent stuck block download in large reorganisations
2012-03-21 12:16:28 -07:00
Pieter Wuille a1a0469f91 More debug output for failed reorganizations 2012-03-21 13:15:27 +01:00
Pieter Wuille 0aa89c08ff 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-03-21 05:09:02 +01:00
Gavin Andresen eae82d8ee5 Use last checkpoint instead of hard-coded 140,700. Fixes #913. 2012-03-20 13:45:45 -04:00
Pieter Wuille 9aa459b294 assertion in CBlock::SetBestChainInner was too strong 2012-03-20 16:41:36 +01:00
Matt Corallo ecf07f2729 Limit getheaders to a hard 2000.
Previously getheaders would return any number of headers up to
2000 + the distance the locator parameter was back (which is up to
~ the number of items in the locator ^ 2).

The only client I was able to find which actually handles the headers
message is BitcoinJ, and it clearly expects no more than 2000 headers
See:
http://code.google.com/p/bitcoinj/source/browse/core/src/main/java/com/google/bitcoin/core/HeadersMessage.java#35

Additionally, the wiki clearly states that getheaders will only ever
return 2000 headers: https://en.bitcoin.it/wiki/Network#Messages
2012-03-19 00:13:15 -04:00
Pieter Wuille d68dcf741e Limit the impact of reorganisations on the database
Sometimes a new block arrives in a new chain that was already the
best valid one, but wasn't marked that way. This happens for example
when network rules change to recover after a fork.

In this case, it is not necessary to do the entire reorganisation
inside a single db commit. These can become huge, and exceed the
objects/lockers limits in bdb. This patch limits the blocks the
actual reorganisation is applied to, and adds the next blocks
afterwards in separate db transactions.
2012-03-12 20:31:56 +01:00
Pieter Wuille a206b0ea12 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:26:36 +01:00
Gavin Andresen 142e604184 DoS fix for mapOrphanTransactions 2012-02-29 11:46:46 -05:00
Michael Ford 27adfb2e0c "February" 2012-02-28 20:31:56 +08:00
Gavin Andresen 21503e4556 Merge branch 'nodosbip16' of https://github.com/sipa/bitcoin 2012-02-27 15:47:27 -05:00
Gavin Andresen 972060ce0e bitcoind changes to stop storing settings in wallet.dat. 2012-02-26 23:21:33 +01:00
Pieter Wuille db9f2e0117 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-02-25 19:05:50 +01:00
Pieter Wuille 5fee401fe1 CAddrMan: stochastic address manager
Design goals:
 * Only keep a limited number of addresses around, so that addr.dat does not grow without bound.
 * Keep the address tables in-memory, and occasionally write the table to addr.dat.
 * Make sure no (localized) attacker can fill the entire table with his nodes/addresses.

See comments in addrman.h for more detailed information.
2012-02-24 13:41:04 +01:00
Gavin Andresen 6fe8c45375 Merge branch 'fixnullpfrom' of https://github.com/sipa/bitcoin 2012-02-22 11:25:08 -05:00
Gavin Andresen e7e6ae2104 Merge branch 'postfeb20' of https://github.com/sipa/bitcoin 2012-02-22 11:06:44 -05:00
Gavin Andresen 8c7358e1dd Merge branch 'reorginfo' of https://github.com/sipa/bitcoin 2012-02-22 11:03:19 -05:00
Luke Dashjr c170d03e03 Bugfix: Instead of reporting "bitcoin-qt" for both bitcoind and Bitcoin-Qt, report "Satoshi" which is at least correct 2012-02-22 10:36:19 -05:00
Pieter Wuille 18c0fa97d0 Post-feb20 simplifications
Now the entire network upgraded to (initial) protocol version 209,
crtainl simplifications in the source code are possible.
2012-02-21 20:46:39 +01:00
Pieter Wuille 73aa0421a7 ProcessBlock is sometimes called with pfrom==NULL 2012-02-20 22:35:08 +01:00
Pieter Wuille ceaa13eff2 Report number of (dis)connected blocks in reorganization
Also report old and new best, and fork point.
2012-02-19 20:06:04 +01:00
Gavin Andresen 0a6b081cca Merge branch 'testnetmining' of github.com:gavinandresen/bitcoin-git 2012-02-17 13:48:01 -05:00
Gavin Andresen 0f8cb5db73 Fix issue #848 : broken mining on testnet 2012-02-16 11:37:54 -05:00
Pieter Wuille c59881eaee Symbolic names for threads
Introduce an enum threadId, and use symbolic indices when accessing
vnThreadsRunning.
2012-02-16 12:43:06 +01:00
Chris Moore 74f28bf1fd Fix #794. Only remove transactions from memory pool when they're actually in the memory pool. 2012-02-09 05:21:41 -08:00
Gavin Andresen 882164196e Update all copyrights to 2012 2012-02-07 11:28:30 -05:00
Gavin Andresen 0b452dff5e Merge branch 'standardScriptSigs' of github.com:gavinandresen/bitcoin-git 2012-02-07 09:04:56 -05:00
Gavin Andresen 7bf8b7c25c -bip16 option (default: 1) to support / not support BIP 16. And bumped default BIP16 switchover date from Feb 15 to Mar 1 2012-02-06 16:27:05 -05:00
Gregory Maxwell 5d1b8f1725 Avoid advertising the node's address when it is not listening or IsInitialBlockDownload().
This also avoids flushing setAddrKnown until 24 hours has passed,
and avoids contacting the external IP services when not listening.

Advertising non-listening nodes is just addr message spam.
It doesn't help the network, in fact it hurts the network,
and it also hurts user's privacy.

Advertising far out of sync nodes doesn't help the network—
they can't even forward (most) transactions and wastes nodes
outbound slots.
2012-02-01 18:08:03 -05:00
Gavin Andresen c52296a73e 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-01-31 13:20:01 -05:00