Refactor keytime/metadata and wallet encryption bugfix

Refactor keytime:
* Key metadata is kept in a CWallet::mapKeyMetadata (std::map<CKeyId,CKeyMetadata>).
* When generating a new key, time is put in that map, and new key is written.
* AddKeyPubKey and AddCryptedKey do not take a creation time argument, but instead
  pull it from that map, if it exists there.

Bugfix:
* AddKeyPubKey and AddCryptedKey in CWallet didn't override the CKeyStore
  definition anymore. This is fixed, as they no longed need the nCreationTime
  argument now.

Also a few related other changes:
* Metadata can be overwritten.
* Only GenerateNewKey calls GetTime(), as it's the only place where we know for
  sure a key was not constructed earlier.
* When the nTimeFirstKey is known to be inaccurate, it is set to the value 1
  (instead of 0, which would mean unknown).
* Use CPubKey instead of std::vector<unsigned char> where possible.
Add ExtractAffectedKeys to script

This function finds all keys affected by a particular output script,
supporting everything ExtractDestinations supports (pay-to-pubkey,
pay-to-pubkeyhash, multisig) and recurses into subscripts (P2SH).
Add GetKeyBirthTimes to wallet

Compute safe lower bounds on the birth times of all wallet keys. For
pool keys or keys with metadata, the actually stored birth time is
used. For all others, the birth times are inferred from the wallet
transactions.
Add dumpwallet and importwallet RPCs

dumpwallet: produce a dump of all keys in a wallet, in a format
compatible with Bitcoin Wallet for Android and Multibit.

importwallet: import such a dump

Conflicts:
	src/bitcoinrpc.cpp
Log reason for non-standard transaction rejection

Conflicts:
	src/main.cpp
init.cpp: fix chainparams.h double include.

Noticed by Diapolo.
fix makefiles and init.cpp after chainparams merge

- add missing chainparams.o to some makefiles
- remove a double-include of chainparams.h in init.cpp
Add HMAC-SHA512 to hash
Generalize version bytes

Conflicts:
	src/chainparams.cpp
Moved CBlock::WriteToDisk out of CBlock to inline function WriteBlockToDisk in main.h
Moved WriteBlockToDisk implementation from main.h to main.cpp
Moved CBlock::ReadFromDisk out of CBlock to functions ReadBlockFromDisk in main.h

Conflicts:
	src/main.h
Leftover from 05df3fc68d68e87415ed9e534db3ea3160dc3092 merge
Moved ReadBlockFromDisk implementation to main.cpp

Conflicts:
	src/main.h
Pulled DisconnectBlock out of CBlock.
Pulled ConnectBlock out of CBlock.
Pulled AddToBlockIndex out of CBlock.
Pulled CheckBlock out of CBlock.

Conflicts:
	src/main.cpp
Pulled AcceptBlock out of CBlock.

Conflicts:
	src/main.cpp
Moved CBlock from main.h to core.h

Conflicts:
	src/main.h