class OpenWalletDialog(PasswordDialog): """This dialog will let the user choose another wallet file if they don't remember their the password""" def __init__(self, app, path, callback): self.app = app self.callback = callback PasswordDialog.__init__( self, app, on_success=lambda pw: self.callback(pw, self.storage), on_failure=self.app.stop) self.init_storage_from_path(path) def select_file(self): dirname = os.path.dirname(self.app.electrum_config.get_wallet_path()) d = WalletDialog(dirname, self.init_storage_from_path, self.app.is_wallet_creation_disabled()) d.open() def init_storage_from_path(self, path): self.storage = WalletStorage(path) self.basename = self.storage.basename() if not self.storage.file_exists(): self.require_password = False self.message = _('Press Next to create') elif self.storage.is_encrypted(): if not self.storage.is_encrypted_with_user_pw(): raise Exception( "Kivy GUI does not support this type of encrypted wallet files." ) self.pw_check = self.storage.check_password if self.app.password and self.check_password(self.app.password): self.pw = self.app.password # must be set so that it is returned in callback self.require_password = False self.message = _('Press Next to open') else: self.require_password = True self.message = self.enter_pw_message else: # it is a bit wasteful load the wallet here and load it again in main_window, # but that is fine, because we are progressively enforcing storage encryption. db = WalletDB(self.storage.read(), manual_upgrades=False) wallet = Wallet(db, self.storage, config=self.app.electrum_config) self.require_password = wallet.has_password() self.pw_check = wallet.check_password self.message = self.enter_pw_message if self.require_password else _( 'Wallet not encrypted')
class OpenWalletDialog(PasswordDialog): def __init__(self, app, path, callback): self.app = app self.callback = callback PasswordDialog.__init__( self, app, on_success=lambda pw: self.callback(pw, self.storage), on_failure=self.app.stop) self.init_storage_from_path(path) def select_file(self): dirname = os.path.dirname(self.app.electrum_config.get_wallet_path()) d = WalletDialog(dirname, self.init_storage_from_path) d.open() def init_storage_from_path(self, path): self.storage = WalletStorage(path) self.basename = self.storage.basename() if not self.storage.file_exists(): self.require_password = False self.message = _('Press Next to create') elif self.storage.is_encrypted(): if not self.storage.is_encrypted_with_user_pw(): raise Exception( "Kivy GUI does not support this type of encrypted wallet files." ) self.require_password = True self.pw_check = self.storage.check_password self.message = self.enter_pw_message else: # it is a bit wasteful load the wallet here and load it again in main_window, # but that is fine, because we are progressively enforcing storage encryption. wallet = self.app.daemon.load_wallet(path, None) self.require_password = wallet.has_password() self.pw_check = wallet.check_password self.message = self.enter_pw_message if self.require_password else _( 'Wallet not encrypted')