parameters: (wltPath, wlt, mode=RECOVERMODE.Full, DoNotMove=False, 
                Passphrase=None, Progress=emptyFunc)
docstring: return code:
     0 - no wallet errors found, nothing to fix
     1 - errors found, wallet fixed
     str - errors found, couldnt fix wallet, returning the error as a str
docstring_summary: return code:
     0 - no wallet errors found, nothing to fix
     1 - errors found, wallet fixed
     str - errors found, couldnt fix wallet, returning the error as a str
docstring_tokens: return code : 0 - no wallet errors found nothing to fix 1 - errors found wallet fixed str - errors found couldnt fix wallet returning the error as a str
function: def FixWallet(wltPath, wlt, mode=RECOVERMODE.Full, DoNotMove=False, 
                Passphrase=None, Progress=emptyFunc):
     
     '''
     return code:
     0 - no wallet errors found, nothing to fix
     1 - errors found, wallet fixed
     str - errors found, couldnt fix wallet, returning the error as a str
     '''
     fixer = PyBtcWalletRecovery()
     frt = fixer.ProcessWallet(wltPath, wlt, Passphrase, mode, Progress=Progress)
  
     # Shorten a bunch of statements
     datestr = RightNowStr('%Y-%m-%d-%H%M')
     if wlt:
        homedir = os.path.dirname(wlt.walletPath)
        wltID   = wlt.uniqueIDB58
     else:
        homedir = os.path.dirname(wltPath)
        wltID   = fixer.UID
     
        
     if frt == 0:
        Progress(fixer.UIreport + fixer.EndLog) 
        return 0, 0, fixer
                   
     elif frt == 1 or (isinstance(frt, dict) and frt['nErrors'] != 0):
        Progress(fixer.UIreport)
        
        if DoNotMove:
           Progress(fixer.UIreport + fixer.EndLog)
           return 1, 0, fixer
        else:   
           #move the old wallets and log files to another folder
           corruptFolder = os.path.join(homedir, wltID, datestr)
           if not os.path.exists(corruptFolder):
              os.makedirs(corruptFolder)
  
           logsToCopy = ['armorylog.txt', 'armorycpplog.txt', 'multipliers.txt']
           wltCopyName = 'armory_%s_ORIGINAL_%s.wallet' % (wltID, '_WatchOnly')
           wltLogName  = 'armory_%s_LOGFILE_%s.log' % \
                                   (wltID, '_WatchOnly' if fixer.WO else '')
     
           corruptWltPath = os.path.join(corruptFolder, wltCopyName)
           recoverLogPath = os.path.join(corruptFolder, wltLogName)
              
           try:
     
              if not fixer.WO:
                 #wallet has private keys, make a WO version and delete it
                 wlt.forkOnlineWallet(corruptWltPath, wlt.labelName, 
                                      wlt.labelDescr)
                 os.remove(wlt.walletPath)
              else:
                 os.rename(wlt.walletPath, corruptWltPath)
     
                    
              if os.path.exists(fixer.LogPath):
                 os.rename(fixer.LogPath, os.path.join(corruptFolder, 
                                                          wltLogName))
                 
              if os.path.exists(fixer.newwalletPath):
                 os.rename(fixer.newwalletPath, wlt.walletPath)
                 
              #remove backups
              origBackup = getSuffixedPath(wlt.walletPath, 'backup')
              if os.path.exists(origBackup):
                 os.remove(origBackup)
     
              newBackup = getSuffixedPath(fixer.newwalletPath, 'backup')
              if os.path.exists(newBackup):
                 os.remove(newBackup)
                 
              # Copy all the relevant log files
              for fn in logsToCopy:
                 fullpath = os.path.join(homedir, fn)
                 if os.path.exists(fullpath):
                    shutil.copy(fullpath,  corruptFolder)
                 else:
                    LOGERROR('Expected log file was not copied: %s', fn)
     
                 
              fixer.EndLog = ("""
                    <br><b>Wallet analysis and restoration complete.</b><br>
                    The inconsistent wallet and log files were moved to:
                    <br>%s/<br><br>""") % corruptFolder
                                   
              Progress(fixer.UIreport + fixer.EndLog)
              return 1, corruptFolder, fixer
        
           except Exception as e:
              #failed to move files around, most likely a credential error
              LOGEXCEPT(str(e))
              errStr = '<br><b>An error occurred moving wallet files:</b> %s' % e
              Progress(fixer.UIreport + errStr)
              
              return -1, fixer.UIreport + errStr, fixer
     else:
        Progress(fixer.UIreport + fixer.EndLog)
        return -1, fixer.UIreport + fixer.EndLog, fixer
function_tokens: def FixWallet ( wltPath , wlt , mode = RECOVERMODE . Full , DoNotMove = False , Passphrase = None , Progress = emptyFunc ) : fixer = PyBtcWalletRecovery ( ) frt = fixer . ProcessWallet ( wltPath , wlt , Passphrase , mode , Progress = Progress ) # Shorten a bunch of statements datestr = RightNowStr ( '%Y-%m-%d-%H%M' ) if wlt : homedir = os . path . dirname ( wlt . walletPath ) wltID = wlt . uniqueIDB58 else : homedir = os . path . dirname ( wltPath ) wltID = fixer . UID if frt == 0 : Progress ( fixer . UIreport + fixer . EndLog ) return 0 , 0 , fixer elif frt == 1 or ( isinstance ( frt , dict ) and frt [ 'nErrors' ] != 0 ) : Progress ( fixer . UIreport ) if DoNotMove : Progress ( fixer . UIreport + fixer . EndLog ) return 1 , 0 , fixer else : #move the old wallets and log files to another folder corruptFolder = os . path . join ( homedir , wltID , datestr ) if not os . path . exists ( corruptFolder ) : os . makedirs ( corruptFolder ) logsToCopy = [ 'armorylog.txt' , 'armorycpplog.txt' , 'multipliers.txt' ] wltCopyName = 'armory_%s_ORIGINAL_%s.wallet' % ( wltID , '_WatchOnly' ) wltLogName = 'armory_%s_LOGFILE_%s.log' % ( wltID , '_WatchOnly' if fixer . WO else '' ) corruptWltPath = os . path . join ( corruptFolder , wltCopyName ) recoverLogPath = os . path . join ( corruptFolder , wltLogName ) try : if not fixer . WO : #wallet has private keys, make a WO version and delete it wlt . forkOnlineWallet ( corruptWltPath , wlt . labelName , wlt . labelDescr ) os . remove ( wlt . walletPath ) else : os . rename ( wlt . walletPath , corruptWltPath ) if os . path . exists ( fixer . LogPath ) : os . rename ( fixer . LogPath , os . path . join ( corruptFolder , wltLogName ) ) if os . path . exists ( fixer . newwalletPath ) : os . rename ( fixer . newwalletPath , wlt . walletPath ) #remove backups origBackup = getSuffixedPath ( wlt . walletPath , 'backup' ) if os . path . exists ( origBackup ) : os . remove ( origBackup ) newBackup = getSuffixedPath ( fixer . newwalletPath , 'backup' ) if os . path . exists ( newBackup ) : os . remove ( newBackup ) # Copy all the relevant log files for fn in logsToCopy : fullpath = os . path . join ( homedir , fn ) if os . path . exists ( fullpath ) : shutil . copy ( fullpath , corruptFolder ) else : LOGERROR ( 'Expected log file was not copied: %s' , fn ) fixer . EndLog = ( """
                    <br><b>Wallet analysis and restoration complete.</b><br>
                    The inconsistent wallet and log files were moved to:
                    <br>%s/<br><br>""" ) % corruptFolder Progress ( fixer . UIreport + fixer . EndLog ) return 1 , corruptFolder , fixer except Exception as e : #failed to move files around, most likely a credential error LOGEXCEPT ( str ( e ) ) errStr = '<br><b>An error occurred moving wallet files:</b> %s' % e Progress ( fixer . UIreport + errStr ) return - 1 , fixer . UIreport + errStr , fixer else : Progress ( fixer . UIreport + fixer . EndLog ) return - 1 , fixer . UIreport + fixer . EndLog , fixer