Improve wallet recovery algorithm #7289

Merged
merged 2 commits into from Feb 16, 2017