Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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