microraiden package

Submodules

microraiden.click_helpers module

Click option group that initializes the proxy. You can use this to setup your own app

Example:

from microraiden.click_helpers import main, pass_app

@main.command()
@click.option('--my-option', default=True)
@pass_app
def start(app, my_option):
    app.run()
    app.join()

if __name_ == "__main__":
    main()

microraiden.close_all_channels module

Utility module used to close all open channels of the channel manager.

Example:

$ python -m microraiden.close_all_channels --private-key ~/.keys/my_key.json
microraiden.close_all_channels.close_open_channels(private_key, state, channel_manager_contract, gas_price=None, wait=<function <lambda>>)[source]

Closes all open channels that belong to a receiver.

Parameters:
  • private_key (str) – receiver’s private key
  • state (ChannelManagerState) – channel manager state
  • channel_manager_contract (str) – address of the channel manager contract
  • gas_price (int, optional) – gas price you want to use (a network default will be used if not set)
  • wait (callable) – pause between checks for a succesfull transaction

microraiden.config module

This module contains network-specific defaults for different networks. You can change i.e. gas price, gas limits, or contract address here.

Example

Set global network defaults for ropsten:

from config import NETWORK_CFG
from constants import get_network_id

NETWORK_CFG.set_defaults(get_network_id('ropsten'))

Change global gas price:

from config import NETWORK_CFG

NETWORK_CFG.gas_price = 15 * denoms.gwei
class microraiden.config.NetworkRuntime[source]

Bases: object

set_defaults(network_id)[source]

Set global default settings for a given network id.

Parameters:network_id (int) – a network id to use.
microraiden.config.get_defaults(network_id)[source]

microraiden.constants module

This file contains configuration constants you probably don’t need to change

microraiden.constants.API_PATH = '/api/1'

str – api path prefix

microraiden.constants.CHANNEL_MANAGER_ABI_NAME = 'RaidenMicroTransferChannels'

str – name of the channel manager contract

microraiden.constants.CHANNEL_MANAGER_CONTRACT_VERSION = '0.2.0'

str – required version of the deployed contract at CHANNEL_MANAGER_ADDRESS. Proxy will refuse to start if the major or minor versions do not match.

microraiden.constants.CONTRACTS_ABI_JSON = 'data/contracts.json'

str – compiled contracts path

microraiden.constants.HTML_DIR = '/home/docs/checkouts/readthedocs.org/user_builds/microraiden/checkouts/latest/microraiden/webui'

str – webUI sources directory

microraiden.constants.JSLIB_DIR = '/home/docs/checkouts/readthedocs.org/user_builds/microraiden/checkouts/latest/microraiden/webui/js'

str – javascript directory

microraiden.constants.JSPREFIX_URL = '/js'

str – url prefix for jslib dir

microraiden.constants.MICRORAIDEN_DIR = '/home/docs/checkouts/readthedocs.org/user_builds/microraiden/checkouts/latest'

str – absolute path to module directory. Used to find path to the webUI sources

microraiden.constants.MICRORAIDEN_VERSION = '0.2.6'

str – version of Microraiden library

microraiden.constants.PROXY_BALANCE_LIMIT = 100000000

int – proxy will stop serving requests if receiver balance is below PROXY_BALANCE_LIMIT

microraiden.constants.TKN_DECIMALS = 1000000000000000000

int – decimals of the token. Any price that’s set for the proxy resources is multiplied by this.

microraiden.constants.TOKEN_ABI_NAME = 'CustomToken'

str – name of the token contract

microraiden.constants.WEB3_PROVIDER_DEFAULT = 'http://127.0.0.1:8545'

str – ethereum node RPC interface URL

microraiden.constants.get_network_id(network_name)[source]

Map canonical network name to its integer id.

Parameters:network_name (str) – network name
Returns:network id
Return type:int
microraiden.constants.read_version(path)[source]

microraiden.exceptions module

exception microraiden.exceptions.InsecureStateFile[source]

Bases: microraiden.exceptions.StateFileException

Permissions of the state file do not match (0600 is expected).

exception microraiden.exceptions.InsufficientConfirmations[source]

Bases: microraiden.exceptions.MicroRaidenException

uRaiden channel doesn’t have enough confirmations.

exception microraiden.exceptions.InvalidBalanceAmount[source]

Bases: microraiden.exceptions.MicroRaidenException

Raised if the payment contains lesser balance than the previous one.

exception microraiden.exceptions.InvalidBalanceProof[source]

Bases: microraiden.exceptions.MicroRaidenException

Balance proof data do not make sense.

exception microraiden.exceptions.InvalidContractVersion[source]

Bases: microraiden.exceptions.MicroRaidenException

Library is not compatible with the deployed contract version

exception microraiden.exceptions.MicroRaidenException[source]

Bases: Exception

Base exception for uRaiden

exception microraiden.exceptions.NetworkIdMismatch[source]

Bases: microraiden.exceptions.StateFileException

RPC endpoint and database have different network id.

exception microraiden.exceptions.NoBalanceProofReceived[source]

Bases: microraiden.exceptions.MicroRaidenException

Attempt to close channel with no registered payments.

exception microraiden.exceptions.NoOpenChannel[source]

Bases: microraiden.exceptions.MicroRaidenException

Attempt to use nonexisting channel.

exception microraiden.exceptions.StateContractAddrMismatch[source]

Bases: microraiden.exceptions.StateFileException

Stored state contract address doesn’t match.

exception microraiden.exceptions.StateFileException[source]

Bases: microraiden.exceptions.MicroRaidenException

Base exception class for state file (database) operations

exception microraiden.exceptions.StateFileLocked[source]

Bases: microraiden.exceptions.StateFileException

Another process is already using the database

exception microraiden.exceptions.StateReceiverAddrMismatch[source]

Bases: microraiden.exceptions.StateFileException

Stored state receiver address doesn’t match.

microraiden.header module

class microraiden.header.HTTPHeaders[source]

Bases: object

BALANCE = 'RDN-Balance'
BALANCE_SIGNATURE = 'RDN-Balance-Signature'
CONTRACT_ADDRESS = 'RDN-Contract-Address'
COST = 'RDN-Cost'
DESERIALIZE_DICT = None
GATEWAY_PATH = 'RDN-Gateway-Path'
INSUF_CONFS = 'RDN-Insufficient-Confirmations'
INVALID_AMOUNT = 'RDN-Invalid-Amount'
INVALID_PROOF = 'RDN-Invalid-Balance-Proof'
NONEXISTING_CHANNEL = 'RDN-Nonexisting-Channel'
OPEN_BLOCK = 'RDN-Open-Block'
PAYMENT = 'RDN-Payment'
PRICE = 'RDN-Price'
RECEIVER_ADDRESS = 'RDN-Receiver-Address'
SENDER_ADDRESS = 'RDN-Sender-Address'
SENDER_BALANCE = 'RDN-Sender-Balance'
SERIALIZE_DICT = None
TOKEN_ADDRESS = 'RDN-Token-Address'
classmethod as_dict()[source]
classmethod deserialize(headers=None)[source]
Return type:Munch
classmethod serialize(headers)[source]
Return type:Dict[str, str]

microraiden.make_helpers module

Helper functions to make initialization of the components simpler

Example:

proxy = make_paywalled_proxy(receiver_privkey, '/tmp/proxy.db')
microraiden.make_helpers.make_channel_manager(private_key, channel_manager_address, state_filename, web3)[source]
Parameters:
  • private_key (str) – receiver’s private key
  • channel_manager_address (str) – channel manager contract to use
  • state_filename (str) – path to the channel manager state database
  • web3 (Web3) – web3 provider
Returns:

intialized and synced channel manager

Return type:

ChannelManager

microraiden.make_helpers.make_channel_manager_contract(web3, channel_manager_address)[source]
Parameters:
  • web3 (Web3) – web3 provider
  • channel_manager_address (str) – channel manager contract to use
Returns:

contract wrapper class

Return type:

Contract

microraiden.make_helpers.make_paywalled_proxy(private_key, state_filename, contract_address=None, flask_app=None, web3=None)[source]
Parameters:
  • private_key (str) – receiver’s private key
  • state_filename (str) – path to the state DB. If database doesn’t exist, it’ll be created and initialized.
  • contract_address (str, optional) – address of the channel manager contract.
  • flask_app (optional) – make proxy use this flask app
  • web3 (Web3, optional) – do not create a new web3 provider, but use this param instead
Returns:

an initialized proxy. Do not forget to call run() to start serving requests.

Return type:

PaywalledProxy

microraiden.withdraw_tokens module

microraiden.withdraw_tokens.withdraw_from_channels(private_key, state, channel_manager_contract, minimum=1, gas_price=None, wait=<function <lambda>>)[source]

Module contents