def unlock_keyring(self, password: str, character_configuration: CharacterConfiguration, unlock_wallet: bool = True): if not self.quiet: self.emit(message='Decrypting NuCypher keyring...', color='yellow') if character_configuration.dev_mode: return True # Dev accounts are always unlocked # NuCypher try: character_configuration.attach_keyring() character_configuration.keyring.unlock( password=password) # Takes ~3 seconds, ~1GB Ram except CryptoError: raise character_configuration.keyring.AuthenticationFailed # Ethereum Client # TODO : Integrate with Powers API if not character_configuration.federated_only and unlock_wallet: self.emit(message='Decrypting Ethereum Node Keyring...', color='yellow') character_configuration.blockchain.client.unlock_account( address=character_configuration.checksum_address, password=password)
def destroy_configuration(emitter: StdoutEmitter, character_config: CharacterConfiguration, force: bool = False) -> None: """Destroy a character configuration and report rhe result with an emitter.""" if not force: confirm_destroy_configuration(config=character_config) character_config.destroy() emitter.message(SUCCESSFUL_DESTRUCTION, color='green') character_config.log.debug(SUCCESSFUL_DESTRUCTION)
def temp_config_root(temp_dir_path): """ User is responsible for closing the file given at the path. """ default_node_config = CharacterConfiguration(dev_mode=True, config_root=temp_dir_path, download_registry=False) yield default_node_config.config_root default_node_config.cleanup()
def unlock_nucypher_keyring(emitter, password: str, character_configuration: CharacterConfiguration): emitter.message('Decrypting NuCypher keyring...', color='yellow') if character_configuration.dev_mode: return True # Dev accounts are always unlocked # NuCypher try: character_configuration.attach_keyring() character_configuration.keyring.unlock(password=password) # Takes ~3 seconds, ~1GB Ram except CryptoError: raise character_configuration.keyring.AuthenticationFailed
def unlock_nucypher_keyring(emitter: StdoutEmitter, password: str, character_configuration: CharacterConfiguration) -> bool: """Unlocks a nucypher keyring and attaches it to the supplied configuration if successful.""" emitter.message(DECRYPTING_CHARACTER_KEYRING.format(name=character_configuration.NAME.capitalize()), color='yellow') # precondition if character_configuration.dev_mode: return True # Dev accounts are always unlocked # unlock try: character_configuration.attach_keyring() character_configuration.keyring.unlock(password=password) # Takes ~3 seconds, ~1GB Ram except CryptoError: raise NucypherKeyring.AuthenticationFailed else: return True
def forget(emitter: StdoutEmitter, configuration: CharacterConfiguration) -> None: """Forget all known nodes via storage""" click.confirm(CONFIRM_FORGET_NODES, abort=True) configuration.forget_nodes() emitter.message(SUCCESSFUL_FORGET_NODES, color='red')