microraiden.client package


microraiden.client.channel module

class microraiden.client.channel.Channel(core, sender, receiver, block, deposit=0, balance=0, state=<State.open: 1>, on_settle=<function Channel.<lambda>>)[source]

Bases: object

class State[source]

Bases: enum.Enum

An enumeration.

closed = 3
open = 1
settling = 2

Attempts to request close on a channel. An explicit balance can be given to override the locally stored balance signature. Blocks until a confirmation event is received or timeout.


Attempts to close the channel immediately by providing a hash of the channel’s balance proof signed by the receiver. This signature must correspond to the balance proof stored in the passed channel state.


Updates the given channel’s balance and balance signature with the new value. The signature is returned and stored in the channel state.

Return type:bool
Return type:bytes

Attempts to settle a channel that has passed its settlement period. If a channel cannot be settled yet, the call is ignored with a warning. Blocks until a confirmation event is received or timeout.


Attempts to increase the deposit in an existing channel. Block until confirmation.


microraiden.client.client module

class microraiden.client.client.Client(private_key=None, key_password_path=None, channel_manager_address=None, web3=None)[source]

Bases: object

__init__(private_key=None, key_password_path=None, channel_manager_address=None, web3=None)[source]
  • private_key (Optional[str]) –
  • key_password_path (Optional[str]) –
  • channel_manager_address (Optional[str]) –
  • web3 (Optional[Web3]) –
Return type:



Returns all open channels to the given receiver. If no receiver is specified, all open channels are returned.

Return type:List[Channel]
get_suitable_channel(receiver, value, initial_deposit=<function Client.<lambda>>, topup_deposit=<function Client.<lambda>>)[source]

Searches stored channels for one that can sustain the given transfer value. If none is found, a possibly open channel is topped up using the topup callable to determine its topup value. If both attempts fail, a new channel is created based on the initial deposit callable. Note: In the realistic case that only one channel is opened per (sender,receiver) pair, this method usually performs like this: 1. Directly return open channel if sufficiently funded. 2. Topup existing open channel if insufficiently funded. 3. Create new channel if no open channel exists. If topping up or creating fails, this method returns None. Channels are topped up just enough so that their remaining capacity equals topup_deposit(value).

Return type:Channel
open_channel(receiver_address, deposit)[source]

Open a channel with a receiver and deposit

Attempts to open a new channel to the receiver with the given deposit. Blocks until the creation transaction is found in a pending block or timeout is reached.

  • receiver_address (str) – the partner with whom the channel should be opened
  • deposit (int) – the initial deposit for the channel (Should be > 0)
Return type:



The opened channel, if successful. Otherwise None


Merges locally available channel information, including their current balance signatures, with channel information available on the blockchain to make up for local data loss. Naturally, balance signatures cannot be recovered from the blockchain.

microraiden.client.context module

class microraiden.client.context.Context(private_key, web3, channel_manager_address)[source]

Bases: object

microraiden.client.session module

class microraiden.client.session.Session(client=None, endpoint_url=None, retry_interval=5, initial_deposit=<function Session.<lambda>>, topup_deposit=<function Session.<lambda>>, close_channel_on_exit=False, **client_kwargs)[source]

Bases: requests.sessions.Session


Closes all adapters and as such the session

on_exit(method, url, response, **kwargs)[source]
on_http_error(method, url, response, **kwargs)[source]
Return type:bool
on_http_response(method, url, response, **kwargs)[source]

Called whenever server returns a reply. Return False to abort current request.

Return type:bool
on_init(method, url, **kwargs)[source]
on_insufficient_confirmations(method, url, response, **kwargs)[source]
Return type:bool
on_invalid_amount(method, url, response, **kwargs)[source]
Return type:bool
on_invalid_balance_proof(method, url, response, **kwargs)[source]
Return type:bool
on_invalid_contract_address(method, url, response, **kwargs)[source]
Return type:bool
on_nonexisting_channel(method, url, response, **kwargs)[source]
Return type:bool
on_payment_requested(method, url, response, **kwargs)[source]
Return type:bool
on_success(method, url, response, **kwargs)[source]
Return type:bool
request(method, url, **kwargs)[source]

Constructs a Request, prepares it and sends it. Returns Response object.

  • method (str) – method for the new Request object.
  • url (str) – URL for the new Request object.
  • params – (optional) Dictionary or bytes to be sent in the query string for the Request.
  • data – (optional) Dictionary, bytes, or file-like object to send in the body of the Request.
  • json – (optional) json to send in the body of the Request.
  • headers – (optional) Dictionary of HTTP Headers to send with the Request.
  • cookies – (optional) Dict or CookieJar object to send with the Request.
  • files – (optional) Dictionary of 'filename': file-like-objects for multipart encoding upload.
  • auth – (optional) Auth tuple or callable to enable Basic/Digest/Custom HTTP Auth.
  • timeout (float or tuple) – (optional) How long to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple.
  • allow_redirects (bool) – (optional) Set to True by default.
  • proxies – (optional) Dictionary mapping protocol or protocol and hostname to the URL of the proxy.
  • stream – (optional) whether to immediately download the response content. Defaults to False.
  • verify – (optional) Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to True.
  • cert – (optional) if String, path to ssl client cert file (.pem). If Tuple, (‘cert’, ‘key’) pair.
Return type:


Module contents