Exemplo n.º 1
0
    def transfer_async(self, token_address, amount, target, identifier=None):
        # pylint: disable=too-many-arguments

        if not isinstance(amount, int):
            raise InvalidAmount('Amount not a number')

        if amount <= 0:
            raise InvalidAmount('Amount negative')

        if not isaddress(token_address) or token_address not in self.tokens:
            raise InvalidAddress('token address is not valid.')

        if not isaddress(target):
            raise InvalidAddress('target address is not valid.')

        graph = self.raiden.token_to_channelgraph[token_address]
        if not graph.has_path(self.raiden.address, target):
            raise NoPathError('No path to address found')

        log.debug('initiating transfer',
                  initiator=pex(self.raiden.address),
                  target=pex(target),
                  token=pex(token_address),
                  amount=amount,
                  identifier=identifier)

        async_result = self.raiden.mediated_transfer_async(
            token_address,
            amount,
            target,
            identifier,
        )
        return async_result
Exemplo n.º 2
0
    def transfer_async(self, token_address, amount, target, identifier=None):
        # pylint: disable=too-many-arguments

        if not isinstance(amount, (int, long)):
            raise InvalidAmount('Amount not a number')

        if amount <= 0:
            raise InvalidAmount('Amount negative')

        if not isaddress(token_address) or token_address not in self.tokens:
            raise InvalidAddress('token address is not valid.')

        if not isaddress(target):
            raise InvalidAddress('target address is not valid.')

        graph = self.raiden.channelgraphs[token_address]
        if not graph.has_path(self.raiden.address, target):
            raise NoPathError('No path to address found')

        async_result = self.raiden.transfer_async(
            token_address,
            amount,
            target,
            identifier=identifier,
        )
        return async_result