add GetRandBytes() as wrapper for RAND_bytes()

- add a small wrapper in util around RAND_bytes() and replace with
  GetRandBytes() in the code to log errors from calling RAND_bytes()
- remove OpenSSL header rand.h where no longer needed
move rand functions from util to new random.h/.cpp
make RandAddSeed() use OPENSSL_cleanse()

- removes the cstring include and is also used in RandAddSeedPerfmon()
Introduce whitelisted peers.

This adds a -whitelist option to specify subnet ranges from which peers
that connect are whitelisted. In addition, there is a -whitebind option
which works like -bind, except peers connecting to it are also
whitelisted (allowing a separate listen port for trusted connections).

Being whitelisted has two effects (for now):
* They are immune to DoS disconnection/banning.
* Transactions they broadcast (which are valid) are always relayed,
  even if they were already in the mempool. This means that a node
  can function as a gateway for a local network, and that rebroadcasts
  from the local network will work as expected.

Whitelisting replaces the magic exemption localhost had for DoS
disconnection (local addresses are still never banned, though), which
implied hidden service connects (from a localhost Tor node) were
incorrectly immune to DoS disconnection as well. This old
behaviour is removed for that reason, but can be restored using
-whitelist=127.0.0.1 or -whitelist=::1 can be specified. -whitebind
is safer to use in case non-trusted localhost connections are expected
(like hidden services).
getblocktemplate: longpolling support
Add test for getblocktemplate longpolling
Do not flush the cache after every block outside of IBD
-datadir is now allowed in config files
Clarify that redeemScript is often optional
[Qt] Fix segfault when launched with -disablewallet
[Qt] Fix No such slot UnitDisplayStatusBarControl::onDisplayUnitsClicked
Fix Watchonly: cs_main lock not held
Set -discover=0 in regtest framework

The regtest framework is local, so often there is no need to
discover our external IP.  Setting -discover=0 in util.py works
around shutdown hang caused by GetExternalIP waiting in recv().
Merge pull request #4519

e3496da [Qt] Fix No such slot UnitDisplayStatusBarControl::onDisplayUnitsClicked (Cozz Lovan)
Merge pull request #4510

6b407e4 -datadir is now allowed in config files (Zak Wilcox)
Merge pull request #4503

b45a6e8 Add test for getblocktemplate longpolling (Wladimir J. van der Laan)
ff6a7af getblocktemplate: longpolling support (Luke Dashjr)
Merge pull request #4520

39cc492 Fix Watchonly: cs_main lock not held (Cozz Lovan)
Merge pull request #4378

dc942e6 Introduce whitelisted peers. (Pieter Wuille)
qt: Ignore showNormalIfMinimized in initialization or shutdown

Also get rid of ui_interface flag NOSHOWGUI. It's up to the GUI to
decide this.

Fixes #4360.
Merge pull request #4518

76fd7b8 [Qt] Fix segfault when launched with -disablewallet (Cozz Lovan)