Avoid a segfault on getblock if it can't read a block from disk.
Clean up RPCs that are disabled in safe-mode.

This removes some inconsistencies in what worked and didn't work in
 safemode. Now only RPCs involved in getting balances or sending
 funds are disabled.

Previously you could mine but not submit blocks— but we may need more
 blocks to resolve a fork that triggered safe mode in the first place,
 and the non-submission was not reliable since some miners submit
 blocks via multiple means. There were also a number of random commands
 disabled that had nothing to do with the blockchain like verifymessage.

Thanks to earlz for pointing out that there were some moderately cheap
 ways to maliciously trigger safe mode, which brought attention to
 the fact that safemode wasn't used in a very intelligent way.
Merge pull request #4501

954d2e7 Avoid a segfault on getblock if it can't read a block from disk. (Ruben Dario Ponticelli)
Merge pull request #4507

b60be6b Clean up RPCs that are disabled in safe-mode. (Gregory Maxwell)
`getrawchangeaddress` should fail when keypool exhausted

An user on IRC reported an issue where `getrawchangeaddress`
keeps returning a single address when the keypool is exhausted.
In my opinion this is strange behaviour.

- Change CReserveKey to fail when running out of keys in the keypool.
- Make `getrawchangeaddress` return RPC_WALLET_KEYPOOL_RAN_OUT when
  unable to create an address.
- Add a Python RPC test for checking the keypool behaviour in combination
  with encrypted wallets.
Merge pull request #4347

6c37f7f `getrawchangeaddress` should fail when keypool exhausted (Wladimir J. van der Laan)
replace ComputeMinWork with CheckMinWork
Remove redundant pblock->nNonce = 0
Move UpdateTime to pow
Move CBlockIndex::GetBlockWork() to pow::GetLengthIncrement(nBits)
Simplify and rename CheckWork to ProcessBlockFound
Encapsulate proof of work generation in pow
Encapsulate CBlockHeader fields for pow checks
Encapsulate CBlockHeader fields for pow updates
Create ProofOfWork class