コード例 #1
0
ファイル: messages.py プロジェクト: maciekf/raiden
 def __init__(self, msg_or_echo, *args):
     if isinstance(msg_or_echo, SignedMessage):
         self.echo = msg_or_echo.hash
     else:
         assert ishash(msg_or_echo)
         self.echo = msg_or_echo
     super(BaseError, self).__init__(*args)
コード例 #2
0
ファイル: messages.py プロジェクト: compumatrix/raiden
 def __init__(self, msg_or_echo, *args):
     if isinstance(msg_or_echo, SignedMessage):
         self.echo = msg_or_echo.hash
     else:
         assert ishash(msg_or_echo)
         self.echo = msg_or_echo
     super(BaseError, self).__init__(*args)
コード例 #3
0
    def __init__(self, amount, expiration, hashlock):
        if amount < 0:
            raise ValueError('amount {} needs to be positive'.format(amount))

        if amount > 2**256:
            raise ValueError('amount {} is too large'.format(amount))

        assert ishash(hashlock)
        self.amount = amount
        self.expiration = expiration
        self.hashlock = hashlock
        self._asstring = None
コード例 #4
0
ファイル: messages.py プロジェクト: cubedro/raiden
    def __init__(self, amount, expiration, hashlock):
        if amount < 0:
            raise ValueError('amount {} needs to be positive'.format(amount))

        if amount > 2 ** 256:
            raise ValueError('amount {} is too large'.format(amount))

        assert ishash(hashlock)
        self.amount = amount
        self.expiration = expiration
        self.hashlock = hashlock
        self._asstring = None
コード例 #5
0
ファイル: messages.py プロジェクト: maciekf/raiden
    def __init__(self, amount, expiration, hashlock):
        # guarantee that `amount` can be serialized using the available bytes
        # in the fixed length format
        if amount < 0:
            raise ValueError('amount {} needs to be positive'.format(amount))

        if amount > 2**256:
            raise ValueError('amount {} is too large'.format(amount))

        assert ishash(hashlock)
        self.amount = amount
        self.expiration = expiration
        self.hashlock = hashlock
        self._asbytes = None
コード例 #6
0
ファイル: messages.py プロジェクト: raiden-network/raiden
    def __init__(self, amount, expiration, hashlock):
        # guarantee that `amount` can be serialized using the available bytes
        # in the fixed length format
        if amount < 0:
            raise ValueError('amount {} needs to be positive'.format(amount))

        if amount > 2 ** 256:
            raise ValueError('amount {} is too large'.format(amount))

        assert ishash(hashlock)
        self.amount = amount
        self.expiration = expiration
        self.hashlock = hashlock
        self._asbytes = None
コード例 #7
0
ファイル: transfers.py プロジェクト: Kaitou786/raiden
    def __post_init__(self):
        # guarantee that `amount` can be serialized using the available bytes
        # in the fixed length format
        if self.amount < 0:
            raise ValueError(f"amount {self.amount} needs to be positive")

        if self.amount > UINT256_MAX:
            raise ValueError(f"amount {self.amount} is too large")

        if self.expiration < 0:
            raise ValueError(f"expiration {self.expiration} needs to be positive")

        if self.expiration > UINT256_MAX:
            raise ValueError(f"expiration {self.expiration} is too large")

        if not ishash(self.secrethash):
            raise ValueError("secrethash {self.secrethash} is not a valid hash")
コード例 #8
0
ファイル: messages.py プロジェクト: nhatchimai111/raiden
    def __init__(self, amount: TokenAmount, expiration: BlockExpiration, secrethash: SecretHash):
        # guarantee that `amount` can be serialized using the available bytes
        # in the fixed length format
        if amount < 0:
            raise ValueError('amount {} needs to be positive'.format(amount))

        if amount >= 2 ** 256:
            raise ValueError('amount {} is too large'.format(amount))

        if expiration < 0:
            raise ValueError('expiration {} needs to be positive'.format(amount))

        if expiration >= 2 ** 256:
            raise ValueError('expiration {} is too large'.format(amount))

        assert ishash(secrethash)
        self.amount = amount
        self.expiration = expiration
        self.secrethash = secrethash
コード例 #9
0
ファイル: messages.py プロジェクト: AlphaX-IBS/raiden
    def __init__(self, amount: TokenAmount, expiration: BlockExpiration, secrethash: SecretHash):
        # guarantee that `amount` can be serialized using the available bytes
        # in the fixed length format
        if amount < 0:
            raise ValueError('amount {} needs to be positive'.format(amount))

        if amount >= 2 ** 256:
            raise ValueError('amount {} is too large'.format(amount))

        if expiration < 0:
            raise ValueError('expiration {} needs to be positive'.format(amount))

        if expiration >= 2 ** 256:
            raise ValueError('expiration {} is too large'.format(amount))

        assert ishash(secrethash)
        self.amount = amount
        self.expiration = expiration
        self.secrethash = secrethash
コード例 #10
0
    def payment_channel(
            self,
            token_network_address: Address,
            channel_id: ChannelID,
    ) -> PaymentChannel:

        if not is_binary_address(token_network_address):
            raise ValueError('address must be a valid address')
        if not ishash(channel_id):
            raise ValueError('identifier must be a hash')

        dict_key = (token_network_address, channel_id)

        if dict_key not in self.identifier_to_payment_channel:
            token_network = self.token_network(token_network_address)

            self.identifier_to_payment_channel[dict_key] = PaymentChannel(
                token_network=token_network,
                channel_identifier=channel_id,
            )

        return self.identifier_to_payment_channel[dict_key]
コード例 #11
0
ファイル: blockchain_service.py プロジェクト: anmolshl/raiden
    def payment_channel(
        self,
        token_network_address: Address,
        channel_id: ChannelID,
    ) -> PaymentChannel:

        if not is_binary_address(token_network_address):
            raise ValueError('address must be a valid address')
        if not ishash(channel_id):
            raise ValueError('identifier must be a hash')

        dict_key = (token_network_address, channel_id)

        if dict_key not in self.identifier_to_payment_channel:
            token_network = self.token_network(token_network_address)

            self.identifier_to_payment_channel[dict_key] = PaymentChannel(
                token_network=token_network,
                channel_identifier=channel_id,
            )

        return self.identifier_to_payment_channel[dict_key]