コード例 #1
0
ファイル: rpcd.py プロジェクト: ruvex/ElectrumX
    async def send_request(self, request_self, method, params, rid):
        async with ClientSession('localhost', RPC_PORT) as session:
            try:
                response = await session.send_request(method, params, timeout=60)
            except Exception as e:
                response = e

        return create_rpc(response, rid)
コード例 #2
0
 async def send_request():
     # aiorpcX makes this so easy...
     async with ClientSession('localhost', port) as session:
         result = await session.send_request(method, params, timeout=15)
         if method in ('groups', 'peers', 'sessions'):
             lines_func = getattr(Controller, f'{method}_text_lines')
             for line in lines_func(result):
                 print(line)
         else:
             print(json.dumps(result, indent=4, sort_keys=True))
コード例 #3
0
async def get_tx_history(address):
    async with ClientSession(electrumx_host, electrumx_port) as session:
        if address.find("bc1") == 0:
            scripthash = bech32_to_scripthash(address)
            await session.send_request("server.version", ["demo", "1.1"],
                                       timeout=60)
            response = await session.send_request(
                "blockchain.scripthash.get_history", [scripthash], timeout=60)
            return response
        else:
            return await session.send_request("blockchain.address.get_history",
                                              [address],
                                              timeout=60)
コード例 #4
0
    async def send_request(self, request_self, method, params, rid):
        client_port = port
        if method in ["getinfo"]:
            client_port = rpc_port

        async with ClientSession('localhost', client_port) as session:
            try:
                response = await session.send_request(method,
                                                      params,
                                                      timeout=60)
            except Exception as e:
                response = e

        request_self._set_response()
        request_self.wfile.write(
            json.dumps(create_rpc(response, rid)).encode('utf-8'))
コード例 #5
0
ファイル: electrumx_session.py プロジェクト: profx5/CPG
def create_electrumx_session(app):
    connection = JSONRPCConnection(JSONRPCv2)
    electrum_config = app.config.electrum

    return ClientSession(host=electrum_config.host, port=electrum_config.port, connection=connection)