Commit graph

287 commits

Author SHA1 Message Date
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 44ac1c0fe3 Add CTxUndo: transaction undo information
The CTxUndo class encapsulates data necessary to undo the effects of
a transaction on the txout set, namely the previous outputs consumed
by it (script + amount), and potentially transaction meta-data when
it is spent entirely.
2012-10-20 23:08:56 +02:00
Pieter Wuille 10fd8604d7 Add CCoins: pruned list of transaction outputs
The CCoins class represents a pruned set of transaction outputs from
a given transaction. It only retains information about its height in
the block chain, whether it was a coinbase transaction, and its
unspent outputs (script + amount).

It has a custom serializer that has very low redundancy.
2012-10-20 23:08:56 +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
Pieter Wuille 69fc8047a9 Compact serialization for scripts
Special serializers for script which detect common cases and encode
them much more efficiently. 3 special cases are defined:
* Pay to pubkey hash (encoded as 21 bytes)
* Pay to script hash (encoded as 21 bytes)
* Pay to pubkey starting with 0x02, 0x03 or 0x04 (encoded as 33 bytes)

Other scripts up to 121 bytes require 1 byte + script length. Above
that, scripts up to 16505 bytes require 2 bytes + script length.
2012-10-20 23:08:56 +02:00
Pieter Wuille 66b02c93e6 Move external block import to separate thread 2012-10-20 01:54:10 +02: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
Wladimir J. van der Laan e96a8c7d86 Merge pull request #1793 from Diapolo/fix_signed_unsigned_strprintf
fix signed/unsigned in strprintf and CNetAddr::GetByte()
2012-09-21 06:04:27 -07:00
Jeff Garzik ea0796bde3 Trim trailing whitespace for src/*.{h,cpp} 2012-09-18 15:07:58 -04:00
Philip Kaufmann 463a1cab43 fix signed/unsigned in strprintf and CNetAddr::GetByte()
- I checked every occurance of strprintf() in the code and used %u, where
  unsigned vars are used
- the change to GetByte() was made, as ip is an unsigned char
2012-09-12 21:30:47 +02: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
Gavin Andresen f35c6c4fb9 Refactor: move alert code from main to alert.cpp/h 2012-08-28 17:04:54 -04:00
xanatos 9eb7fc5842 Changed nprev->pprev
It should be pprev, because the next one is pnext, and it's printing the memory address of the CBlockIndex (so pSomething).
2012-08-28 23:25:52 +03: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
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
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
Luke Dashjr 3c726dd3c0 Bugfix: Use standard BTC unit in comments 2012-08-01 17:49:57 +00: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
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 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 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
Jeff Garzik 25d5c19522 RPC: add 'getrawmempool', listing all transaction ids in memory pool 2012-06-22 11:43:34 -04: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
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 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
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 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
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
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
Philip Kaufmann 5f9861953e fix RenameOver() and FileCommit() functions, to not generate compilation errors 2012-05-17 18:30:09 +02:00
Jeff Garzik d17ac27a72 Merge pull request #1316 from jgarzik/dead-code
Remove dead code: CTxDB::EraseBlockIndex(), CBlockIndex::EraseBlockFromDisk()
2012-05-17 08:47:54 -07:00
Jeff Garzik 768e5d52fb Add new utility functions FileCommit(), RenameOver() 2012-05-16 19:25:25 -04:00
Jeff Garzik a7d45c5a7a Remove dead code: CTxDB::EraseBlockIndex(), CBlockIndex::EraseBlockFromDisk() 2012-05-15 13:36:25 -04: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
Pieter Wuille 7f3ccb59da Split synchronization mechanisms from util.{h,cpp} 2012-05-11 18:13:51 +02: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 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
Jeff Garzik 24de922636 CDiskTxPos, CInPoint, COutPoint: cast null value (-1) to unsigned int
to eliminate signed/unsigned comparison warnings
2012-05-01 17:49:17 -04:00
Jeff Garzik 5aa0b23825 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-23 14:14:36 -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 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
Wladimir J. van der Laan cdcc319c2d change type of various bare chars to bool that are only used as bool (and never serialized) 2012-04-21 18:16:11 +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 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
Jeff Garzik 9eace6b113 Move CWalletDB code to new walletdb module.
In addition to standard code separation, this change opens the door
to fixing several include inter-dependencies.
2012-04-17 20:00:55 +02:00
Pieter Wuille ed6d0b5f85 Remove headers.h 2012-04-17 20:00:55 +02: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 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
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
Wladimir J. van der Laan 52d3a48128 VC2010 compile fixes 2012-04-03 20:22:41 +02:00
Gavin Andresen f3da2a88c9 Bump version to 0.6.0.99 for 0.6.1 merge window 2012-04-02 10:03:26 -04:00
Gavin Andresen f3f9da868e Bump version to 0.6.0rc6 2012-03-29 13:58:22 -04:00
Gavin Andresen 8d29329f93 Update version to 60005 (0.6.0rc5) 2012-03-26 15:42:06 -04:00
Pieter Wuille 6b8de05d0a Begin doxygen-compatible comments 2012-03-26 16:48:23 +02:00
Gregory Maxwell 44b69cf25e Bump CLIENT_VERSION for rc4 release 2012-03-16 15:08:57 -04:00
Gavin Andresen e318b99d99 Bump CLIENT_VERSION for rc3 release 2012-03-13 09:31:37 -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
Gavin Andresen 142e604184 DoS fix for mapOrphanTransactions 2012-02-29 11:46:46 -05:00
Gavin Andresen 972060ce0e bitcoind changes to stop storing settings in wallet.dat. 2012-02-26 23:21:33 +01:00
Gavin Andresen 0f8cb5db73 Fix issue #848 : broken mining on testnet 2012-02-16 11:37:54 -05:00
Gavin Andresen 882164196e Update all copyrights to 2012 2012-02-07 11:28:30 -05:00
Gavin Andresen 6bf4253a68 Increase client version to 0.6 2012-02-07 11:22:09 -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
Luke Dashjr 2bc4fd609c Bitcoin-Qt signmessage GUI (pull request #582) 2012-01-27 08:41:55 +01:00
Gavin Andresen b6a35d2d52 Merge pull request #773 from gavinandresen/p2shSigOpCount
Simplify counting of P2SH sigops to match BIP 16
2012-01-25 05:21:20 -08:00
Gavin Andresen 149f580c82 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-01-23 12:54:32 -05:00
Gavin Andresen 137d0685a4 Simplify counting of P2SH sigops to match BIP 16 (thanks to Matt Corallo for prompting this).
This also removes an un-needed sigops-per-byte check when accepting transactions to the memory pool (un-needed assuming only standard transactions are being accepted). And it only counts P2SH sigops after the switchover date.
2012-01-20 17:07:40 -05:00
Forrest Voight 52a3d2635c Separated COINBASE_FLAGS out into main.h and made RPC getmemorypool return it 2012-01-14 19:22:24 -05:00
Gavin Andresen 8d7849b6db Refactored ConnectInputs, so valid-transaction-checks are done before ECDSA-verifying signatures. 2012-01-13 10:22:24 -05:00
Gavin Andresen 922e8e2929 Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16). 2012-01-13 10:22:23 -05:00
Luke Dashjr 340f0876ea collect more info on tx pooling and block finding for getmininginfo 2012-01-12 19:47:39 -05:00
Gavin Andresen 8a53cb0b9d New RPC commands: getblockhash and getblock 2011-12-23 16:26:38 -05:00
Wladimir J. van der Laan bde280b9a4 Revert "Use standard C99 (and Qt) types for 64-bit integers"
This reverts commit 21d9f36781.
2011-12-21 22:33:19 +01:00
Luke Dashjr 21d9f36781 Use standard C99 (and Qt) types for 64-bit integers 2011-12-20 16:52:59 -05:00
Gavin Andresen 781c06c0f5 Merge pull request #677 from luke-jr/minfee_modes
API: GetMinFee modes
2011-12-20 13:09:18 -08:00
Gavin Andresen 595925592d Merge branch 'op_eval' 2011-12-20 14:43:31 -05:00
Gavin Andresen 26ce92b352 Use std::numeric_limits<> for typesafe INT_MAX/etc 2011-12-19 19:10:34 -05:00
Gavin Andresen 2a45a494b0 Use block times for 'hard' OP_EVAL switchover, and refactored EvalScript
so it takes a flag for how to interpret OP_EVAL.
Also increased IsStandard size of scriptSigs to 500 bytes, so
a 3-of-3 multisig transaction IsStandard.
2011-12-19 13:24:48 -05:00
Gavin Andresen e679ec969c OP_EVAL implementation
OP_EVAL is a new opcode that evaluates an item on the stack as a script.
It enables a new type of bitcoin address that needs an arbitrarily
complex script to redeem.
2011-12-19 12:40:19 -05:00
Gavin Andresen 99a289f531 Merge pull request #574 from sipa/dumpprivkey
Dumpprivkey
2011-12-19 07:27:25 -08:00
Gavin Andresen f8ded588a2 Implement BIP 14 : separate protocol version from client version 2011-12-19 10:24:23 -05:00
Pieter Wuille 30ab2c9c46 Preparations for key import/export 2011-12-17 21:49:48 +01:00
Luke Dashjr dbbf1d4a48 GetMinFee takes a mode parameter (GMF_{BLOCK,RELAY,SEND}) instead of fForRelay 2011-12-14 01:07:43 -05:00
Gavin Andresen 10fd7f6689 Orphan block fill-up-memory attack prevention 2011-12-01 13:53:38 -05:00
Gavin Andresen eb5fff9e16 Moved checkpoints out of main, to prep for using them to help prevent DoS attacks 2011-12-01 12:18:50 -05:00
Gavin Andresen 6853e627f1 Fix build on windows and mac
Replaced all occurrences of #if* __WXMSW__ with WIN32,
and all occurrences of __WXMAC_OSX__ with MAC_OSX, and made
sure those are defined appropriately in the makefile and bitcoin-qt.pro.
2011-10-07 11:02:21 -04:00
Forrest Voight 074d584a04 Added RPC call 'getmemorypool' that provides everything needed to construct a block with a custom generation transaction and submit a solution
getmemorypool [data]
If [data] is not specified, returns data needed to construct a block to work on:
  "version" : block version
  "previousblockhash" : hash of current highest block
  "transactions" : contents of non-coinbase transactions that should be included in the next block
  "coinbasevalue" : maximum allowable input to coinbase transaction, including the generation award and transaction fees
  "time" : timestamp appropriate for next block
  "bits" : compressed target of next block
If [data] is specified, tries to solve the block and returns true if it was successful.
2011-10-01 14:42:54 -04:00
Gavin Andresen 17e2c24645 Merge pull request #517 from gavinandresen/DoSprevention
Denial-of-service prevention
2011-09-26 06:06:16 -07:00
Gavin Andresen 3e52aaf212 Transaction/Block denial-of-service detection/response 2011-09-21 12:50:12 -04:00
Wladimir J. van der Laan 5dd7318db7 Merge branch 'master' of https://github.com/bitcoin/bitcoin 2011-09-16 06:55:47 +02:00
Wladimir J. van der Laan d33cc2b5e3 clarify function signature (GetNumBlocksOfPeers) and use number of 'frozen' blocks as initial value for number of peer blocks 2011-09-11 10:49:30 +02:00
Gavin Andresen 5a3dea451d Merge branch 'unique_coinbase' of git://gitorious.org/~Luke-Jr/bitcoin/luke-jr-bitcoin into unique_coinbase 2011-09-07 10:51:57 -04:00
Luke Dashjr 83f4cd156e Bugfix: Use timestamp in coinbase rather than "bits", needed to ensure coinbase txn is unique even if address is the same 2011-09-06 16:43:40 -04:00
Wladimir J. van der Laan c5aa1b139a update to work with new lock system, add protocol.* to build system 2011-09-02 18:02:22 +02:00
Giel van Schijndel 507fd9d15b Start moving protocol-specific code to protocol.[ch]pp
Move CMessageHeader from net.h to protocol.[ch]pp, with the
implementation in the .cpp compilation unit (compiling once is enough).

This commit does *not* and should not modify *any* code, it only moves
it from net.h and splits it across protocol.cpp and protocol.hpp.

Indentation changes aside the closest thing to a modification of code is
the addition of the 'TODO' comment (the execution of which requires code
modifications and thus doesn't belong in this commit).

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2011-08-19 07:24:38 +02:00
Giel van Schijndel 99860de3c9 Make some global variables less-global (static)
Explicitly make these global variables less-global to reduce the maximum
scope of this global state.

In my experience global variables tend to be a major source of bugs. As
such the less accessible they are the less likely they are to be the
source of a bug.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2011-08-19 07:24:37 +02:00
Matt Corallo b2120e223a Unify copyright notices.
To a variation on:
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2011 The Bitcoin developers
2011-08-09 13:32:52 +02:00
Pieter Wuille 03fbd79049 get rid of mapPubKeys
Make CKeyStore's interface work on uint160's instead of pubkeys, so
no separate global mapPubKeys is necessary anymore.
2011-07-17 12:07:59 +02:00
Jeff Garzik 0bad8e4237 Merge pull request #352 from TheBlueMatt/newenc
Wallet Private Key Encryption (on CWallet)
2011-07-12 19:10:12 -07:00
Matt Corallo 7414733bea Make an invalid addrIncoming so that old clients crash.
This prevents old clients from opening, and thus corrupting
or otherwise causing harm to encrypted wallets.
2011-07-13 02:11:25 +02:00
Wladimir J. van der Laan aa496b75c2 remove magic number: change threshold for nLockTime to constant 2011-07-09 10:11:28 +02:00
Gavin Andresen c774b16976 Merge branch 'totalblocksestimate1' of https://github.com/laanwj/bitcoin 2011-06-24 11:17:22 -04:00
Wladimir J. van der Laan eade213197 add GetTotalBlocksEstimate() function, move magic number to constant 2011-06-19 00:12:02 +02:00
Pieter Wuille 64c7ee7e6b CWallet class
* A new class CKeyStore manages private keys, and script.cpp depends on access to CKeyStore.
* A new class CWallet extends CKeyStore, and contains all former wallet-specific globals; CWallet depends on script.cpp, not the other way around.
* Wallet-specific functions in CTransaction/CTxIn/CTxOut (GetDebit, GetCredit, GetChange, IsMine, IsFromMe), are moved to CWallet, taking their former 'this' argument as an explicit parameter
* CWalletTx objects know which CWallet they belong to, for convenience, so they have their own direct (and caching) GetDebit/... functions.
* Some code was moved from CWalletDB to CWallet, such as handling of reserve keys.
* Main.cpp keeps a set of all 'registered' wallets, which should be informed about updates to the block chain, and does not have any notion about any 'main' wallet. Function in main.cpp that require a wallet (such as GenerateCoins), take an explicit CWallet* argument.
* The actual CWallet instance used by the application is defined in init.cpp as "CWallet* pwalletMain". rpc.cpp and ui.cpp use this variable.
* Functions in main.cpp and db.cpp that are not used by other modules are marked static.
* The code for handling the 'submitorder' message is removed, as it not really compatible with the idea that a node is independent from the wallet(s) connected to it, and obsolete anyway.
2011-06-15 11:05:55 +02:00
Pieter Wuille e89b9f6a2a move wallet code to separate file
This introduces two new source files, keystore.cpp and wallet.cpp with
corresponding headers. Code is moved from main and db, in a preparation
for a follow-up commit which introduces the classes CWallet and CKeyStore.
2011-06-15 11:05:55 +02:00
Jeff Garzik 19ea44208f Merge pull request #226 from jordanlewis/betterheaders
Optimize header dependencies; improve Makefile dependency graph
2011-06-14 02:05:57 -07:00
Pieter Wuille 76d660ebd3 Faster timeout when connecting
Use non-blocking connects, and a select() call to wait a predefined
time (5s by default, but configurable with -timeout) for either
success or failure. This allows much more connections to be tried
per time unit.

Based on a patch by phantomcircuit.
2011-06-12 00:29:05 +02:00
Jeff Garzik 6de1326ba4 Lower minimum relay TX fee to 0.0001 (from 0.0005) BTC. 2011-06-10 02:07:13 -04:00
Jeff Garzik 352b4ea5b9 Reduce minimum TX fee for new transactions, to 0.0005. 2011-06-05 14:28:14 -04:00
Jeff Garzik 7a234cdae5 Merge pull request #255 from sipa/rescanupdate
Update transactions already in the wallet when rescanning.
2011-06-05 07:30:47 -07:00
Pieter Wuille 2bfda1be11 Separate required fee for relaying and creation
Transactions created with the new minimal fee policy would not be
relayed by the network. Therefore, we separate the minimal fee that
is necessary to relay and to create, leaving the creation one at
the old amount, for now.
2011-05-26 00:54:58 +02:00
Pieter Wuille 1c528eeee9 Update transactions already in the wallet when rescanning.
When rescanning, if the scanned transaction is already in the wallet, it
is skipped. However, if someone sends a transaction, does not wait for
confirmation, switches wallets, waits for a block that contains his original
transaction, and switches wallets again, a rescan will leave his wallet
transaction (which has no merkle branch, so no confirmations) untouched.
2011-05-22 17:12:20 +02:00
Jordan Lewis 40c2614ef4 Only include net.h when we have to 2011-05-15 22:19:17 -05:00
Jordan Lewis 1512d5ce64 Only include db.h when we have to. 2011-05-15 22:19:16 -05:00
Wladimir J. van der Laan 223b6f1ba4 make bitcoin include files more modular 2011-05-15 12:04:20 +02:00
Jeff Garzik 2a2487514a Decrease minimum TX fee to 0.0005 BTC. 2011-05-11 16:50:09 -04:00
Jeff Garzik a630da6400 Replace CENT with new constant MIN_TX_FEE, where appropriate.
MIN_TX_FEE==CENT remains true (until next commit).
2011-05-11 16:48:51 -04:00
Jeff Garzik b17be7e14b Manual merge of jaromil's source tree reorg commit.
Conflicts:
	src/sha256.cpp
2011-05-09 14:00:14 -04:00
Jaromil 84c3fb07b0 directory re-organization (keeps the old build system)
there is no internal modification of any file in this commit

files are moved into directories according to established standards in
sourcecode distribution; these directories contain:

 src - Files that are used in constructing the executable binaries,
       but are not installed.

 doc - Files in HTML and text format that document usage, quirks of
       the implementation, and contributor checklists.

 locale - Files that contain human language translation of strings
          used in the program

 contrib - Files contributed from distributions or other third party
 	   implementing scripts and auxiliary programs
2011-04-23 12:10:25 +02:00
Renamed from main.h (Browse further)