MCPcopy
hub / github.com/raiden-network/raiden / channel_open

Method channel_open

raiden/api/python.py:374–516  ·  view source on GitHub ↗

Open a channel with the peer at `partner_address` with the given `token_address`.

(
        self,
        registry_address: TokenNetworkRegistryAddress,
        token_address: TokenAddress,
        partner_address: Address,
        settle_timeout: BlockTimeout = None,
        reveal_timeout: BlockTimeout = None,
        retry_timeout: NetworkTimeout = DEFAULT_RETRY_TIMEOUT,
    )

Source from the content-addressed store, hash-verified

372 return channel_identifier is not None
373
374 def channel_open(
375 self,
376 registry_address: TokenNetworkRegistryAddress,
377 token_address: TokenAddress,
378 partner_address: Address,
379 settle_timeout: BlockTimeout = None,
380 reveal_timeout: BlockTimeout = None,
381 retry_timeout: NetworkTimeout = DEFAULT_RETRY_TIMEOUT,
382 ) -> ChannelID:
383 """Open a channel with the peer at `partner_address`
384 with the given `token_address`.
385 """
386 if settle_timeout is None:
387 settle_timeout = self.raiden.config.settle_timeout
388
389 if reveal_timeout is None:
390 reveal_timeout = self.raiden.config.reveal_timeout
391
392 self._raise_for_invalid_channel_timeouts(settle_timeout, reveal_timeout)
393
394 if not is_binary_address(registry_address):
395 raise InvalidBinaryAddress(
396 "Expected binary address format for registry in channel open"
397 )
398
399 if not is_binary_address(token_address):
400 raise InvalidBinaryAddress("Expected binary address format for token in channel open")
401
402 if not is_binary_address(partner_address):
403 raise InvalidBinaryAddress(
404 "Expected binary address format for partner in channel open"
405 )
406
407 confirmed_block_identifier = views.get_confirmed_blockhash(self.raiden)
408 registry = self.raiden.proxy_manager.token_network_registry(
409 registry_address, block_identifier=confirmed_block_identifier
410 )
411
412 settlement_timeout_min = registry.settlement_timeout_min(
413 block_identifier=confirmed_block_identifier
414 )
415 settlement_timeout_max = registry.settlement_timeout_max(
416 block_identifier=confirmed_block_identifier
417 )
418
419 if settle_timeout < settlement_timeout_min:
420 raise InvalidSettleTimeout(
421 f"Settlement timeout should be at least {settlement_timeout_min}"
422 )
423
424 if settle_timeout > settlement_timeout_max:
425 raise InvalidSettleTimeout(
426 f"Settlement timeout exceeds max of {settlement_timeout_max}"
427 )
428
429 token_network_address = registry.get_token_network(
430 token_address=token_address, block_identifier=confirmed_block_identifier
431 )