Revert "Revert "fix write to wallet during LoadWallet""

This reverts commit de30bdf674d951dc1d982c191964e193b81bd4b9.