Commit graph

34 commits

Author SHA1 Message Date
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
Wladimir J. van der Laan 11cd416525 fix warnings: unused variable 'XX' [-Wunused-variable] 2012-04-15 13:40:14 +02:00
Gavin Andresen 882164196e Update all copyrights to 2012 2012-02-07 11:28:30 -05:00
Gavin Andresen 39f0d96860 Make transactions with extra data in their scriptSig's non-standard. 2012-01-19 13:30:54 -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
Gavin Andresen d11a58a2d3 Remove not-used-anywhere scriptPrereq from SignSignature() 2012-01-13 10:20:42 -05:00
coderrr 6ec76ca09e make sure IsMine only returns true when we own all keys 2012-01-03 06:24:52 +07:00
Wladimir J. van der Laan 89772f932a Fix OP_EVAL recursion depth counting 2011-12-27 10:02:28 +01:00
Gavin Andresen 2e17ac83c6 Fix broken ExtractAddress (refactored, made callers check for addresses in keystore if they care) 2011-12-22 15:57:31 -05:00
Gavin Andresen 9e470585b3 Update bitcoin address numbers for latest luke-jr/sipa scheme 2011-12-19 13:24:51 -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 a0871afb2b Interpret OP_EVAL as OP_NOP until Feb 1, 2012 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 bf798734db Support 3 new multisignature IsStandard transactions
Initial support for (a and b), (a or b), and 2-of-3 escrow
transactions (where a, b, and c are keys).
2011-12-19 12:40:19 -05:00
Gavin Andresen 7e55c1ab65 Collapse no-op ExtractAddress/ExtractAddressInner 2011-12-19 12:39:47 -05:00
Wladimir J. van der Laan 7a15d4ff67 Merge branch 'master' of https://github.com/bitcoin/bitcoin
Conflicts:
	src/main.cpp
2011-09-02 17:35:30 +02: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
Wladimir J. van der Laan b90c9ecb13 Merge branch 'master' of https://github.com/bitcoin/bitcoin 2011-08-16 10:28:24 +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
Wladimir J. van der Laan b5b1d1a66b Merge branch 'master' of https://github.com/bitcoin/bitcoin
Conflicts:
	src/script.cpp
2011-07-27 21:44:55 +02:00
Pieter Wuille b63241d451 Bugfix: don't overuse limited ExtractAddress
ExtractAddress was called with the keystore as argument in RPC and
UI, limiting results to own keys. This caused empty "address"
fields.
2011-07-26 19:41:47 +02:00
Wladimir J. van der Laan 491ad6db50 Merge remote branch 'upstream/master'
Conflicts:
	src/bitcoinrpc.cpp
2011-07-26 16:47:23 +02:00
Pieter Wuille cb61b8dc4c split off CBase58Data from CBitcoinAddress
Split off features unrelated to addresses from CBitcoinAddress to
CBase58Data, so they can be reused.
2011-07-17 12:09:17 +02:00
Pieter Wuille 2ffba736e9 Use CBitcoinAddress instead of string/uint160
Instead of conversion functions between pubkey/uint160/address in
base58.h, have a fully fledged class CBitcoinAddress (CAddress was
already taken) to represent addresses.
2011-07-17 12:09:14 +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
Giel van Schijndel 225f222c9f fix warning: X enumeration values not handled in switch [-Wswitch-enum]
Add default cases to opcode switches to assert that they should never
occur.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2011-07-13 05:10:15 +02:00
Pieter Wuille 0efda1a79e Do not use obsolete CPrivKey for passing keys around 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
Pieter Wuille 98705aa51c Bugfixes walletclass
Some problems found by ius:
* compiler complains with no return after critical section block
* CKeyStore::GetPrivKey(key) was undefined for unknown key
* missing return statement in GetChange()
2011-06-20 20:07:28 +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
Wladimir J. van der Laan 223b6f1ba4 make bitcoin include files more modular 2011-05-15 12:04:20 +02: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 script.cpp (Browse further)