Commit graph

60 commits

Author SHA1 Message Date
Pieter Wuille 53cb1a49e7 Use erase instead of rewrite to remove old addr entries 2012-03-26 20:22:38 +02:00
Gavin Andresen 958fe01c32 Merge branch 'checklevel' of https://github.com/sipa/bitcoin 2012-03-22 12:18:56 -04:00
Gavin Andresen e12d131734 Merge pull request #975 from sipa/versioncheck
Check minversion before loading the rest of the wallet
2012-03-22 09:18:11 -07:00
Gavin Andresen a6b4a11385 Merge branch 'addrman' of https://github.com/sipa/bitcoin 2012-03-22 09:19:01 -04:00
Pieter Wuille ef12c2184d Check minversion before loading the rest of the wallet
When a 0.6 wallet with compressed pubkeys is created, it writes a
minversion record to prevent older clients from reading it. If the 0.5
loading it sees a key record before seeing the minversion record however,
it will fail with DB_CORRUPT instead of DB_TOO_NEW.
2012-03-22 04:59:59 +01:00
Pieter Wuille 4538e45c46 Add -checklevel and improve -checkblocks
-checkblocks now takes a numeric argument: the number of blocks that must
be verified at the end of the chain. Default is 2500, and 0 means all
blocks.

-checklevel specifies how thorough the verification must be:
0: only check whether the block exists on disk
1: verify block validity (default)
2: verify transaction index validity
3: check transaction hashes
4: check whether spent txouts were spent within the main chain
5: check whether all prevouts are marked spent
6: check whether spent txouts were spent by a valid transaction that consumes them
2012-03-22 03:19:23 +01:00
Pieter Wuille 89516bd4e0 Speed up block downloading 2012-03-21 01:32:00 +01:00
Luke Dashjr 3cc0624932 Print more diagnostic info for the various DB_CORRUPT conditions 2012-03-12 14:01:15 -04:00
Gavin Andresen 972060ce0e bitcoind changes to stop storing settings in wallet.dat. 2012-02-26 23:21:33 +01:00
Pieter Wuille 4a10d4c6dc Fix addrProxy setting
Before 0.6 addrProxy was a CAddress, but netbase changed it to CService.
Retain compatibility by wrapping/unwrapping with a CAddress when saving
or loading.

This commit retains compatibility with 0.6.0rc1 (which wrote the setting
as a CService) by trying to parse twice.
2012-02-25 21:13:34 +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
Pieter Wuille 0b807a417f Add SetMinVersion to CWallet 2012-02-18 15:42:29 +01:00
sje397 4efbda3f25 Added 'Backup Wallet' menu option
- icon from the LGPL Nuvola set (like the tick) - http://www.icon-king.com/projects/nuvola/
- include 'boost/version.hpp' in db.cpp so that the overwrite version of copy can be used
- catch exceptions in BackupWallet (e.g. filesystem_error thrown when trying to overwrite without the overwrite flag set)
- include db.h in walletmodel.cpp for BackupWallet function
- updated doc/assets-attribution.txt and contrib/debian/copyright with copyright info for new icon
2012-02-15 23:29:59 +11:00
Gavin Andresen 882164196e Update all copyrights to 2012 2012-02-07 11:28:30 -05:00
Gavin Andresen 9d952d17bb Look for flushwallet/listen/irc/dnsseed/upnp instead of noflushwallet/etc. And switch default for irc to 0. 2012-02-07 09:14:31 -05:00
Pieter Wuille 91f43a33f8 Full checking of all loaded keys 2012-01-26 19:26:43 +01:00
Pieter Wuille b25cc627a3 Check consistency of private keys
Reported by onlineproof on IRC: Bitcoin does not verify whether private
keys and public keys correspond, when loading a wallet.
2012-01-25 03:05:16 +01:00
Gavin Andresen 922e8e2929 Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16). 2012-01-13 10:22:23 -05:00
Pieter Wuille 11529c6e4f Compressed pubkeys
This patch enabled compressed pubkeys when -compressedpubkeys is passed.
These are 33 bytes instead of 65, and require only marginally more CPU
power when verifying. Compressed pubkeys have a different corresponding
address, so it is determined at generation. When -compressedpubkeys is
given, all newly generated addresses will use a compressed key, while
older/other addresses keep using normal keys. Unpatched clients will
relay and verify these transactions.
2012-01-09 15:18:19 +01: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 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 4c6e22953e Make CWalletTx::pwallet private 2011-12-17 21:49:47 +01:00
Pieter Wuille f53c5ede73 close old db when rewriting 2011-11-20 11:17:41 -05:00
Gavin Andresen b2d3b2d65d Never remove database files on shutdown, it caused unreadable wallets on some testers' machines. 2011-11-20 10:39:01 -05:00
Gavin Andresen 1c15f88653 Only remove database log files on shutdown after wallet encryption/rewrite 2011-11-17 14:21:32 -05:00
Gavin Andresen c4de918478 Tweak handling of boost filesystem versions 2011-11-15 14:30:24 -05:00
Gavin Andresen 8d0923109d Fix crash-on-osx-on-shutdown bug. And cleanup CDB handling in Rewrite. 2011-11-15 14:30:24 -05:00
Gavin Andresen 709c1b267f Fix boost filesystem incompatibility problem 2011-11-15 09:47:29 -05:00
Gavin Andresen d764d9161e Obsolete keypool and make sure database removes log files on shutdown. 2011-11-15 09:30:16 -05:00
Pieter Wuille 9e9869d0fe Resilvering 2011-11-14 09:59:22 -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
Nils Schneider 74567f7ef1 remove code that reads addr.txt in LoadAddreses() 2011-10-01 22:27:02 +02:00
Gavin Andresen 565c4771b6 Remove wxWidgets
Makefiles now build bitcoind only.
qmake/make in top-level directory is used to build Bitcoin QT
Deleted almost all #ifdef GUI from the code (left one possibly controversial one)
Deleted xpm/ files.
2011-09-26 10:04:04 -04:00
Gavin Andresen 6cc4a62c0e Fix rpc-hanging deadlocks
Collapsed multiple wallet mutexes to a single cs_wallet, to avoid deadlocks with wallet methods that acquired locks in different order.
Also change master RPC call handler to acquire cs_main and cs_wallet locks before executing RPC calls; requiring each RPC call to acquire the right set of locks in the right order was too error-prone.
2011-08-31 12:55:16 -04:00
Gavin Andresen 498a2c9b16 Merge pull request #458 from TheBlueMatt/copyright
Unify copyright notices.
2011-08-11 10:34:29 -07:00
Venkatesh Srinivas 7c3002bf27 Qualify make_tuple with boost:: namespace.
db.cpp has a number of uses of make_tuple and has 'using namespace
std' and 'using namespace boost'. Without qualifying make_tuple,
std::make_tuple is preferred, which is incorrect. This patch qualifies
make_tuple.

Signed-off-by: Jeff Garzik <jgarzik@exmulti.com>
2011-08-10 22:40:10 -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
Jeff Garzik a139ed74f2 CAddrDB::LoadAddresses: properly initialize CAddress
Fixes issue #424
2011-07-26 15:15:55 -04:00
Matt Corallo 3a10d1c493 Fix bad return values in LoadWallet. 2011-07-14 18:15:50 +02:00
Giel van Schijndel 858cebed7d fix warning: unused variable 'X' [-Wunused-variable]
Remove several unused variables.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2011-07-13 05:10:15 +02:00
Jeff Garzik 0fa89d8e81 Merge pull request #381 from TheBlueMatt/nminversion
Add minversion to wallet.
2011-07-12 19:34:30 -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
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
Pieter Wuille acd6501610 Prepare codebase for Encrypted Keys. 2011-07-08 15:46:47 +02:00
Matt Corallo 7ec552676c Add minversion to wallet. 2011-07-05 18:36:01 +02:00
Shane Wegner 926e14b362 Fix missing includes needed for Boost 1.46. 2011-06-19 15:12:31 -07:00