Ejemplo n.º 1
0
async def setup_client():
    if CLIENT is not None:
        return CLIENT
    server = ServerInfo({
        "nickname": None,
        "hostname": "bitcoin.cluelessperson.com",
        "ip_addr": "172.92.140.254",
        "ports": ["s50002", "t50001"],
        "version": "1.2",
        "pruning_limit": 0,
        "seen_at": 1533670768.588772
    })

    client = StratumClient()

    await asyncio.wait_for(client.connect(server_info=server,
                                          proto_code='s',
                                          use_tor=False,
                                          disable_cert_verify=True),
                           timeout=5)

    await asyncio.wait_for(client.RPC('server.version', 'bitcoin-spv-merkle',
                                      '1.2'),
                           timeout=5)

    return client
Ejemplo n.º 2
0
    async def new_client(self, network: str) -> StratumClient:
        while True:
            server = self._get_server_info(network)
            try:

                client = StratumClient()

                await asyncio.wait_for(
                    client.connect(
                        server_info=server,
                        proto_code='s',
                        use_tor=False,
                        disable_cert_verify=True),
                    timeout=self._timeout_seconds)

                await asyncio.wait_for(
                    client.RPC(
                        'server.version',
                        self.user_agent,
                        self.protocol_version),
                    timeout=self._timeout_seconds)

                asyncio.ensure_future(self._keepalive(client, network))
                self._servers.append(str(server))
                return client

            except Exception as e:
                print('failed:', server)
                print(e, str(e))
                # fall back to top of loop and try a new server
                pass
Ejemplo n.º 3
0
def call_electrum(conn, method, *args):
    # call a method and format up the response nicely
    print("args")
    print(args)
    svr = ServerInfo("electrumx.tamami-foundation.org",
                     "electrumx.tamami-foundation.org",
                     ports=(("tcp" + str("50001")) if "50001" else "tcp"))
    conn = StratumClient()
    time.sleep(10)
    t = ''
    try:
        resp = conn.RPC(method, *args)
        time.sleep(10)
    except ElectrumErrorResponse as e:
        response, req = e.args
        t += "2-1"
        return t
    print("CALL_ELECTRUM REPONSE")
    print(resp)
    return resp