osx: show testnet icon in dock as early as possible

A green testnet splashscreen with a normal, orange dock icon looks strange and can confuse users.

Signed-off-by: Jonas Schnelli <jonas.schnelli@include7.ch>

Conflicts:
	src/qt/bitcoin.cpp
remove GetBoolArg() fDefault parameter defaulting to false

- explicitly set the default of all GetBoolArg() calls
- rework getarg_test.cpp and util_tests.cpp to cover this change
- some indentation fixes
- move macdockiconhandler.h include in bitcoin.cpp to the "our headers"
  section

Conflicts:
	src/init.cpp
	src/main.cpp
	src/qt/bitcoin.cpp
	src/qt/splashscreen.cpp
	src/rpcmining.cpp
	src/util.cpp
More bestblock records in wallets

Write bestblock records in wallets:
* Every 20160 blocks synced, no matter what (before: none during IBD)
* Every 144 blocks after IBD (before: for every block, slow)
* When creating a new wallet
* At shutdown

This should result in far fewer spurious rescans.

Conflicts:
	src/init.cpp
	src/main.cpp
Fix crash-at-shutdown if exiting before initializing wallet

Conflicts:
	src/init.cpp
don't pass wallet to CreateNewBlock()
Clean up mining CReserveKey to prevent crash at shutdown

Fixes issue#2687

Conflicts:
	src/rpcmining.cpp
Move pMiningKey init out of StartRPCThreads

This commit decouples the pMiningKey initialization and shutdown from the RPC
threads.

`getwork` and `getblocktemplate` rely on pMiningKey, and can also be ran
from the debug window in the UI even when the RPC server is not running.

Solves issue #2706.

Conflicts:
	src/rpcmining.cpp
Exit cleanly if AppInit2 returns false

Bitcoin-Qt could core dump if application initialization failed in certain ways.

I double-fixed this:
1) qt/bitcoin.cpp now shuts down core threads cleanly if AppInit2 returns false
2) init.cpp now exits before StartNode() if strErrors is set (no reason to StartNode if we're just going to exit immediately anyway).

Tested by triggering all of the various ways AppInit2 can fail, either by passing bogus command-line arguments or just recompiling tweaked code to simulate failure.

This is a partial fix for #2480
Support absence of wallet (pwalletMain==NULL) in several locations,
notably RPC.

Conflicts:
	src/bitcoinrpc.cpp
	src/init.cpp
	src/rpcmining.cpp
	src/rpcwallet.cpp
RPC validateaddress: test pwalletMain for NULL (no-wallet mode)

Conflicts:
	src/rpcwallet.cpp