async def notify_keyring_migration_completed(self, request: Dict[str, Any]) -> Dict[str, Any]: success: bool = False error: Optional[str] = None key: Optional[str] = request.get("key", None) if type(key) is not str: return {"success": False, "error": "missing key"} Keychain.handle_migration_completed() try: if Keychain.master_passphrase_is_valid(key, force_reload=True): Keychain.set_cached_master_passphrase(key) success = True # Inform the GUI of keyring status changes self.keyring_status_changed(await self.keyring_status(), "wallet_ui") else: error = "bad passphrase" except Exception as e: tb = traceback.format_exc() self.log.error(f"Keyring passphrase validation failed: {e} {tb}") error = "validation exception" response: Dict[str, Any] = {"success": success, "error": error} return response
async def unlock_keyring(self, request: Dict[str, Any]) -> Dict[str, Any]: success: bool = False error: Optional[str] = None key: Optional[str] = request.get("key", None) if type(key) is not str: return {"success": False, "error": "missing key"} try: if Keychain.master_passphrase_is_valid(key, force_reload=True): Keychain.set_cached_master_passphrase(key) success = True # Inform the GUI of keyring status changes self.keyring_status_changed(await self.keyring_status(), "wallet_ui") else: error = "bad passphrase" except Exception as e: tb = traceback.format_exc() self.log.error(f"Keyring passphrase validation failed: {e} {tb}") error = "validation exception" if success and self.run_check_keys_on_unlock: try: self.log.info("Running check_keys now that the keyring is unlocked") check_keys(self.root_path) self.run_check_keys_on_unlock = False except Exception as e: tb = traceback.format_exc() self.log.error(f"check_keys failed after unlocking keyring: {e} {tb}") response: Dict[str, Any] = {"success": success, "error": error} return response
def cache_passphrase(passphrase: str) -> None: Keychain.set_cached_master_passphrase(passphrase)