Move wallet/dispatch functions from main.cpp to wallet.cpp

After these changes, all code in main.cpp is associated with maintenance of the public blockchain, with one notable exception:
* callbacks such as EraseFromWallets(), SyncWithWallets(), PrintWallets(), ResendWalletTransactions() which call out from the public blockchain engine into the wallet code

This change builds upon, and therefore includes and requires, req #2867.