Move code from script to wallet

Continues #4754
please keep these alphabetized