backport PR10095 https://github.com/bitcoin/bitcoin/pull/10095/files
f885b67 refactor: Make rest.cpp dependency on *toJSON in blockchain.cpp explicit (Wladimir J. van der Laan)
8d8f28d refactor: Move RPCNotifyBlockChange out of rpc/server.h (Wladimir J. van der Laan)
e6dcfee refactor: Move GetDifficulty out of rpc/server.h (Wladimir J. van der Laan)
Made slightly awkward due to semiduplicated effort / out of order
backports; some tiny cleanup changes made too.
(Also supersedes PR9612, which added that comment in front of GetDifficulty.)
Depends on D3013