pybitcointools icon indicating copy to clipboard operation
pybitcointools copied to clipboard

Timeout error on Dash and Doge while using unspent

Open x011 opened this issue 1 year ago • 4 comments

I'm getting the error below while using the unspent function on Dash and Doge. Any idea why? Is there a way to increase the timeout or change the blockchain provider for these two coins?

Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptos\coins_async\base.py", line 397, in unspent
    unspents = await self.client.unspent(value)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptos\electrumx_client\client.py", line 508, in unspent
    return await self.send_request("blockchain.scripthash.listunspent", scripthash)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptos\electrumx_client\client.py", line 389, in send_request
    await self._ensure_connected()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptos\electrumx_client\client.py", line 351, in _ensure_connected
    done, pending = await asyncio.wait([is_connected_task, self._connection_task],
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 384, in wait
    return await _wait(fs, timeout, return_when, loop)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 491, in _wait
    await waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\User\Desktop\wallets\py_bitcoinlib\btc_wallet.py", line 302, in <module>
    balance, balance_float = balance(wallet, network, args.testnet)
  File "C:\Users\User\Desktop\wallets\py_bitcoinlib\btc_wallet.py", line 198, in balance
    inputs = coin.unspent(wallet[network]['addr1'])
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptos\coins\base.py", line 152, in unspent
    return self._run_async("unspent", addr, merkle_proof=merkle_proof)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptos\coins\base.py", line 84, in _run_async
    return fut.result(timeout=self.timeout * 2)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 458, in result
    return self.__get_result()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 403, in __get_result
    raise self._exception
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\cryptos\coins\base.py", line 68, in run
    result = await asyncio.wait_for(coro, timeout=self.timeout)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

x011 avatar Jun 05 '23 02:06 x011

Unfortunately it seems there are no ElectrumX servers for these coins at the moment, although there were in the past. There was some silly dispute in the Dash community over the Dash version of ElectrumX. If you know of available ElectrumX servers it it is possible to provide them as input when initializing the Coin instance.

primal100 avatar Jun 29 '23 10:06 primal100

Here's how to provide the servers as input:

Create a servers.json file like this:

{
    "hostname_or_ip_address": {
        "pruning": "-",
        "t": "50001",
        "s": "50002",
        "version": "1.4"
    }
}

Once you have the .json file you can try this:

d = Doge(client_kwargs={'server_file': 'servers.json'})

You can also let me know any Doge ElectrumX servers you know about and I can update it in the file in this repository (cryptos/electrumx_client/servers/doge.json) so they will be in future releases.

primal100 avatar Jun 29 '23 10:06 primal100

Hi, Doge wallet provide some servers. Can they be used? if so, how could these values translate to the json format you sent before?

image

x011 avatar Jul 13 '23 01:07 x011

Should be ok now in v 2.0.9. Thanks for your assistance, @x011 .

python -m pip install --upgrade cryptos

primal100 avatar Jul 18 '23 15:07 primal100