Port wallet.cpp to new main, update config and environment.