Write bestblock records in wallets:
- Every 20160 blocks synced, no matter what (before: none during IBD)
- Every 144 blocks after IBD (before: for every block, slow)
- When creating a new wallet (new)
- At shutdown (new)
This should result in far fewer spurious rescans.
To correct all previously missed rescans, we should probably also once change the bestblock record name (suggested by gmaxwell), to force a single rescan once for every wallet. As this is likely to be annoying for almost all, and most that have missed funds in the past have already done a full rescan already, this is perhaps controversial and not included in this pullreq.
Should close #2676 (but I haven't tested that).