Move code from script to wallet

Continues #4754
Instead of putting these #ifdefs, I'd prefer to move these to a wallet-specific test cpp (e.g. wallet_tests.cpp or create a new one)