build: Fix OSX build when using Homebrew and qt5

Qt5 is bottled, so configure won't find it without some help. Use
brew to find out its prefix.

Also, qt5 added the host_bins variable to pkg-config, use it.
Refactor -alertnotify code

Refactor common -alertnotify code into static CAlert::Notify method.
Make -proxy set all network types, avoiding a connect leak.

Previously -proxy was not setting the proxy for IsLimited networks, so
 if you set your configuration to be onlynet=tor you wouldn't get an
 IPv4 proxy set.

The payment protocol gets its proxy configuration from the IPv4 proxy,
 and so it would experience a connection leak.

This addresses issue #5355 and also clears up a cosmetic bug where
 getinfo proxy output shows nothing when onlynet=tor is set.

Conflicts:
	src/init.cpp

Rebased-From: 3c777141349ad82d679a278df0619968af53c23
Github-Issue: #5358
Limit the number of new addressses to accumulate

Rebased-From: 12a49cac0a561ada277e93549cae26a3123a6023
Disable SSLv3 (in favor of TLS) for the RPC client and server.

TLS is subject to downgrade attacks when SSLv3 is available, and
 SSLv3 has vulnerabilities.

The popular solution is to disable SSLv3. On the web this breaks
 some tiny number of very old clients. While Bitcoin RPC shouldn't
 be exposed to the open Internet, it also shouldn't be exposed to
 really old SSL implementations, so it shouldn't be a major issue
 for us to disable SSLv3.

There is more information on the downgrade attacks and disabling
 SSLv3 at https://disablessl3.com/ .

Rebased-From: 683dc4009b2b01699e672f8150c28e2ebe0aae19
addrman: Do not propagate obviously poor addresses onto the network
Add an option to allow users to disable relaying/mining data carrier transactions
set shutdown title to main window title

- this ensures we don't show Bitcoin-Qt as that is still our
  internal application name
- fixes #4427

Rebased-from: 33c62c9c0b25998beb361e6f42e1fd0beebcf05b
Use async name resolving to improve net thread responsiveness

In the LookupIntern(), things changed are:

  1. Call getaddrinfo_a() instead of getaddrinfo() if available, the former is a sync version of the latter;
  2. Try using inet_pton()/inet_addr() to convert the input text to a network addr structure at first, if success the extra name resolving thread inside getaddrinfo_a() could be avoided;
  3.  An interruption point added in the waiting loop for return from getaddrinfo_a(), which completes the improve for thread responsiveness.

A easy way to see the effect is to kick off a 'bitcoind stop' immediately after 'bitcoind -daemon', before the change it would take several, or even tens of, minutes on a bad network situation to wait for the running bitcoind to exit, now it costs only seconds.

Signed-off-by: Huang Le <4tarhl@gmail.com>

Rebased-from: caf6150e9785da408f1e603ae70eae25b5202d98
Fix the build for windows

Problem introduced in caf6150. Thanks to @drak for noticing. Fixes #4473.

Rebased-from: afe380ef0f1c70185fc7c50e1a75e589ff3382dd
gitian: remove unneeded option after last commit

Rebased-from: a7ec027311ae4b14d3ea4225a875caa5a83151bb
build: fix broken boost chrono check on some platforms

If clock_gettime is implemented outside of libc (librt in this case), configure
would fail when testing boost. Since clock_gettime is not present on all OSs,
boost only uses it when it can. Check for it in librt and add it to LIBS if
found, but don't fail if it's not (since boost won't be expecting it in this
case).

Also, reverse the link order as necessary for static libs.

Note that it's possible that there are other similar cases for boost, which may
be handled the same way.

Rebased-from: 460b32d7b1a2014dd490b15a360d062847f8efe9
Ping automatically every 2 minutes (unconditionally)

... instead of after 30 minutes of no sending, for latency measurement
and keep-alive. Also, disconnect if no reply arrives within 20 minutes,
instead of 90 of inactivity (for peers supporting the 'pong' message).

Rebased-from: f1920e86063d0ed008c6028d8223b0e21889bf75
Add comment regarding experimental-use service bits

As per mailing list discussion.

Rebased-from: 38405ac1411ce73f6945f296980d559e2949027f
Add nLocalServices info to RPC getinfo

Also show full 64 bits of services. Previously service bits >32 that
were advertised just didn't show up at all.

Rebased-from: 99ddc6cb706e825e54da244a10d4d6389fc5eaae
[Qt] Prevent balloon-spam after rescan

Rebased-from: acd432b5b38464ef3ecb87f80b1bbebe9d7c2022 #4530
[Qt] Fix Transaction details shows wrong To:

Rebased-from: b90711cabffa8bf83ddee98cfc179c0aef5732ef
bitcoin-cli, rpcclient: prefer EXIT_FAILURE cstdlib constant

A more complex construction via abs() yields the same end result.

Rebased-From: 34ff109
Rebased-By: Wladimir J. van der Laan <laanwj@gmail.com>

Rebased-from: 0cafb630254c6459ea02f6fc47e1c37bb81a1238
RPC client: Simplify command line string-to-JSON-value conversion code

By default, all command line parameters are converted into JSON string
values.  There is no need to manually specify the incoming type.

A binary decision "parse as string or JSON?" is all that's necessary.

Convert to a simple class, initialized at runtime startup, which offers
a quick lookup to answer "parse as JSON?" conversion question.

Future parameter conversions need only to indicate the method name
and zero-based index of the parameter needing JSON parsing.

Conflicts:
	src/rpcclient.cpp

Rebased-from: e35b37b1b8252c3d3f66001ba1efccd263307add
remove -tor compatibility code (only allow -onion)

- exit, if -tor option is found and give error to user

Rebased-from: 1c750dbd40e23be1f17cf74cd73041a1050dc98d #4130