Commit Graph

35 Commits

Author SHA1 Message Date
Gavin Andresen 498a2c9b16 Merge pull request #458 from TheBlueMatt/copyright
Unify copyright notices.
2011-08-11 10:34:29 -07:00
Gavin Andresen c648b589be Merge pull request #459 from jgarzik/char-msgstart
Use 'unsigned char' rather than 'char' for pchMessageStart.
2011-08-10 20:01:37 -07:00
Venkatesh Srinivas 25133bd74b Use 'unsigned char' rather than 'char' for pchMessageStart.
Regarding https://bitcointalk.org/index.php?topic=28022.0

main.cpp has: "char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 };"
Per discussion on the thread linked, leaving the signedness of
pchMessageStart is unsafe for values > 0x80. This patch specifies
'unsigned char' in main.cpp and net.h.

Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
2011-08-10 22:42:43 -04: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
Matt Corallo 33208fb557 Check for duplicate txins in CheckTransaction. 2011-07-31 14:20:10 +02:00
Jeff Garzik a9ba47101a Merge pull request #403 from sipa/cbitcoinaddress
keys indexed by address + introduced CBitcoinaddress
2011-07-24 15:38:38 -07:00
Matt Corallo 643160f6e7 Actually use mapAlreadyAskedFor.
Previously, mapAlreadyAskedFor was read from, but never added to.
The original intent was to use mapAlreadyAskedFor to keep track
of the time an item was requested and "Each retry is 2 minutes
after the last".
This implements that intent.
2011-07-21 22:06:20 +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
Patrick Varilly 8c41469140 Single DB transaction for all addresses in a message
Cuts disk activity at startup immensely
2011-07-14 03:29:07 +02:00
Giel van Schijndel ecf1c79aad fix warnings: expression result unused [-Wunused-value]
In the assert()s take advantage of the fact that string constants
("string") are effectively of type 'const char []', which when used in
an expression yield a non-NULL pointer.

An assertion that should always fail can thus be formulated as:
  assert(!"fail);

An assertion where a text message should be added to the expression can
be written as such:
  assert("message" && expression);

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2011-07-13 05:07:44 +02: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
Matt Corallo 4e87d341f7 Add wallet privkey encryption.
This commit adds support for ckeys, or enCrypted private keys, to the wallet.
All keys are stored in memory in their encrypted form and thus the passphrase
is required from the user to spend coins, or to create new addresses.

Keys are encrypted with AES-256-CBC using OpenSSL's EVP library. The key is
calculated via EVP_BytesToKey using SHA512 with (by default) 25000 rounds and
a random salt.

By default, the user's wallet remains unencrypted until they call the RPC
command encryptwallet <passphrase> or, from the GUI menu, Options->
Encrypt Wallet.

When the user is attempting to call RPC functions which require the password
to unlock the wallet, an error will be returned unless they call
walletpassphrase <passphrase> <time to keep key in memory> first.

A keypoolrefill command has been added which tops up the users keypool
(requiring the passphrase via walletpassphrase first).
keypoolsize has been added to the output of getinfo to show the user the
number of keys left before they need to specify their passphrase (and call
keypoolrefill).

Note that walletpassphrase will automatically fill keypool in a separate
thread which it spawns when the passphrase is set. This could cause some
delays in other threads waiting for locks on the wallet passphrase, including
one which could cause the passphrase to be stored longer than expected,
however it will not allow the passphrase to be used longer than expected as
ThreadCleanWalletPassphrase will attempt to get a lock on the key as soon
as the specified lock time has arrived.

When the keypool runs out (and wallet is locked) GetOrReuseKeyFromPool
returns vchDefaultKey, meaning miners may start to generate many blocks to
vchDefaultKey instead of a new key each time.

A walletpassphrasechange <oldpassphrase> <newpassphrase> has been added to
allow the user to change their password via RPC.

Whenever keying material (unencrypted private keys, the user's passphrase,
the wallet's AES key) is stored unencrypted in memory, any reasonable attempt
is made to mlock/VirtualLock that memory before storing the keying material.
This is not true in several (commented) cases where mlock/VirtualLocking the
memory is not possible.

Although encryption of private keys in memory can be very useful on desktop
systems (as some small amount of protection against stupid viruses), on an
RPC server, the password is entered fairly insecurely. Thus, the only main
advantage encryption has for RPC servers is for RPC servers that do not spend
coins, except in rare cases, eg. a webserver of a merchant which only receives
payment except for cases of manual intervention.

Thanks to jgarzik for the original patch and sipa, gmaxwell and many others
for all their input.

Conflicts:

	src/wallet.cpp
2011-07-13 02:11:25 +02:00
Gavin Andresen d547a44332 Block-chain lock-in at 134444 2011-07-03 11:20:39 -04:00
Pieter Wuille 4973174534 Limit response to getblocks to half of output buffer size
Introduce SendBufferSize() and ReceiveBufferSize(), and limit
the blocks sent as response to the "getblocks" message to
half of the active send buffer size.
2011-07-01 09:39:44 +02:00
Gavin Andresen c774b16976 Merge branch 'totalblocksestimate1' of https://github.com/laanwj/bitcoin 2011-06-24 11:17:22 -04:00
Shane Wegner 926e14b362 Fix missing includes needed for Boost 1.46. 2011-06-19 15:12:31 -07: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
Jeff Garzik 09d1484b22 Merge pull request #264 from sipa/mintxfeefix
Fix for small change outputs
2011-06-05 07:32:58 -07: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 12a1256c1d bugfix: accept free transactions 2011-05-28 16:43:49 +02: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 ca253d5911 Fix for small change outputs
With the separation of CENT and MIN_TX_FEE, it is now reasonable
to create change outputs between 0.01 and 0.0005, as these are
spendable according to the policy, even though they require a fee
to be paid.

Also, when enough fee was already present, everything can go into
a change output, without further increasing the fee.
2011-05-25 21:30:14 +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 31f2931281 Only include certain boost headers if necessary. 2011-05-17 18:58:47 -05:00
Jordan Lewis edd309e537 Only include init.h when we have to 2011-05-15 22:23:37 -05: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
Daniel Holbert 5d1d69453a Add #ifdef USE_UPNP around usage of fUseUPnP to fix build failure. 2011-05-12 23:30:27 +02: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