+func (w *Wallet) checkWalletInfo() error {
+ if w.Status.Version != currentVersion {
+ return errWalletVersionMismatch
+ } else if !w.Chain.BlockExist(&w.Status.BestHash) {
+ return errBestBlockNotFoundInCore
+ }
+
+ return nil
+}
+
+//LoadWalletInfo return stored wallet info and nil,
+//if error, return initial wallet info and err
+func (w *Wallet) LoadWalletInfo() error {
+ walletStatus, err := w.Store.GetWalletInfo()
+ if walletStatus == nil && err != ErrGetWalletStatusInfo {
+ return err
+ }
+
+ if walletStatus != nil {
+ w.Status = *walletStatus
+ err = w.checkWalletInfo()
+ if err == nil {
+ return nil
+ }
+
+ log.WithFields(log.Fields{"module": logModule}).Warn(err.Error())
+ w.Store.DeleteWalletTransactions()
+ w.Store.DeleteWalletUTXOs()
+ }
+
+ w.Status.Version = currentVersion
+ w.Status.WorkHash = bc.Hash{}
+ block, err := w.Chain.GetBlockByHeight(0)