Add the username to the wallet if it is missing

The few users who had their mainData truncated lost the username property when mainData was recreated as an empty object.
When opening a wallet, set the username property in mainData if it is missing.

Fixes #594.