Beispiel #1
0
def run(private_key: str,
        state_file_path: str = os.path.join(click.get_app_dir('microraiden'),
                                            'echo_server.db'),
        channel_manager: ChannelManager = None,
        join_thread: bool = True):
    dirname = os.path.dirname(state_file_path)
    if dirname:
        os.makedirs(dirname, exist_ok=True)

    # set up a paywalled proxy
    # arguments are:
    #  - private key to use for receiving funds
    #  - file for storing state information (balance proofs)
    if channel_manager is None:
        web3 = Web3(HTTPProvider(WEB3_PROVIDER_DEFAULT))
        NETWORK_CFG.set_defaults(int(web3.version.network))
        channel_manager = make_channel_manager(
            private_key, NETWORK_CFG.CHANNEL_MANAGER_ADDRESS, state_file_path,
            web3)
    app = PaywalledProxy(channel_manager)

    # Add resource defined by regex and with a fixed price of 1 token.
    app.add_paywalled_resource(StaticPriceResource,
                               "/echofix/<string:param>",
                               price=5)
    # Resource with a price determined by the second parameter.
    app.add_paywalled_resource(DynamicPriceResource, "/echodyn/<int:param>")

    # Start the app. proxy is a WSGI greenlet, so you must join it properly.
    app.run(debug=True)

    if join_thread:
        app.join()
    else:
        return app
Beispiel #2
0
def run(
        private_key: str,
        rpc_provider: str,
        state_file_path: str = os.path.join('./channel.db'),
        channel_manager: ChannelManager = None,
        join_thread: bool = True,
):
    dirname = os.path.dirname(state_file_path)
    if dirname:
        os.makedirs(dirname, exist_ok=True)

    if channel_manager is None:
        web3 = Web3(HTTPProvider(rpc_provider))
        NETWORK_CFG.set_defaults(int(web3.version.network))
        channel_manager = make_channel_manager(
            private_key, NETWORK_CFG.CHANNEL_MANAGER_ADDRESS, state_file_path,
            web3)
    app = PaywalledProxy(channel_manager)

    app.run(host="0.0.0.0", port=5000, debug=True)

    if join_thread:
        app.join()
    else:
        return app
Beispiel #3
0
def run(private_key: str,
        state_file_path: str = os.path.join(click.get_app_dir('microraiden'),
                                            'stream.db'),
        channel_manager: ChannelManager = None,
        join_thread: bool = True):
    dirname = os.path.dirname(state_file_path)

    if dirname:
        os.makedirs(dirname, exist_ok=True)

    if channel_manager is None:
        web3 = Web3(HTTPProvider(WEB3_PROVIDER_DEFAULT))
        NETWORK_CFG.set_defaults(int(web3.version.network))
        channel_manager = make_channel_manager(
            private_key, NETWORK_CFG.CHANNEL_MANAGER_ADDRESS, state_file_path,
            web3)

    app = PaywalledProxy(channel_manager)

    app.add_paywalled_resource(StreamResource,
                               "/stream/<string:param>",
                               price=1 * TKN_DECIMALS)

    app.run(host="localhost", port=5000, debug=True)

    if join_thread:
        app.join()
    else:
        return app
Beispiel #4
0
    def __init__(self,
                 private_key: str,
                 web3: Web3,
                 state_file_path: str,
                 dbot_data: dict,
                 middleware: None = None
                 ) -> None:

        self.name = dbot_data['info']['name']
        self.domain = dbot_data['info']['domain']
        self.address = Web3.toChecksumAddress(dbot_data['info']['addr'])
        self.endpoints = dbot_data['endpoints']
        self.api_host = dbot_data['info']['api_host']
        self.protocol = dbot_data['info']['protocol']
        # TODO middleware should be attribute which can be update runtime
        self.middleware = middleware
        self.enable = True

        self.channel_manager = make_channel_manager(
            self.address,
            private_key,
            NETWORK_CFG.channel_manager_address,
            state_file_path,
            web3
        )
        self.paywall = Paywall(self.channel_manager)
        self.channel_list = ChannelManagementListChannels(self.channel_manager)
        self.channel_detail = ChannelManagementChannelInfo(self.channel_manager)
Beispiel #5
0
def main():
    web3 = Web3(HTTPProvider(config['web3path']))
    NETWORK_CFG.set_defaults(int(web3.version.network))
    private_key = get_private_key('./dragonstone-rinkeby')
    log.info('This private key %s', private_key)
    log.info('This address %s', privkey_to_addr(private_key))
    channel_manager = make_channel_manager(private_key, config['manager'],
                                           './db/echo_server.db', web3,
                                           'localhost', 6001)

    run(private_key=private_key, channel_manager=channel_manager)
Beispiel #6
0

receiver_key = '0xdd880da44adb44c91005bc7d51d877627ebfc3a45f67ec7f1be926939af79808'
receiver_address = '0x09226F56C5699E2d87700179507cf25FA2F79F6b'

sender_key = '0x1e8b64bcdbaa6cc995e2f325318ba48d58847e0af229670e0fdbd827033c8de0'
sender_address = '0xA7Ac54048B81041dbD527B603175C17473CE2d95'

#cm_address = '0x45fe9a68af651cc5c0fb2c3afc24bb7205eb7e27'
#cm_address = '0xa18bdF0EdEDc0a43C70D00230AbB691b71D9dcC4'
#cm_address = '0x0f83dc382D4B0880b5e06430F49B0d12dD6fE744'
cm_address = '0xB69c353cbA3be3f33910C7c5fFA54C228bde8934'
#fname = "./test1.data"
#fname = "/home/ilya/.config/microraiden/0x45fe9a68_0x09226F56.db"
fname = "/home/ilya/.config/microraiden/0xB69c353c_0x09226F56.db"
cm = make_channel_manager(receiver_key, cm_address, fname, w3)
#client = Client(receiver_key, receiver_key, cm_address, w3);
client = Client(sender_key, sender_key, cm_address, w3)
#ch = open_channel(cm, client, receiver_address)
#ch = client.get_open_channels(receiver_address);
#ch = client.channels;
ch = cm.channels
#ch = client.get_suitable_channel(receiver_address, 1);
#ch = client.get_open_channels(sender_address);
print("ch: ", ch)
block_num = 2006163
id = ('0xA7Ac54048B81041dbD527B603175C17473CE2d95', block_num)
ccc = {
    'sender': '0xA7Ac54048B81041dbD527B603175C17473CE2d95',
    'block': block_num
}