coblox / bobtimus

an autobot that automatically handles swaps as Bob
Apache License 2.0
1 stars 1 forks source link

Refreshing bitcoin UTXO sometimes times out and we receive a ESOCKETTIMEOUT exception #84

Closed bonomat closed 5 years ago

bonomat commented 5 years ago

We should investigate why updating the UTXO set times out randomly.

#033[39mFailed to refresh UTXO: ESOCKETTIMEDOUT"

related to these lines: https://github.com/coblox/bobtimus/blob/af6ff678f9555561e86a9540ae8bd4dcf9d067c1/src/index.ts#L23-L30

and https://github.com/coblox/bobtimus/blob/af6ff678f9555561e86a9540ae8bd4dcf9d067c1/src/wallets/bitcoin.ts#L150-L177

Additional information:

bonomat commented 5 years ago

Learnings:

Currently, we just hold on to the initial request that triggers the scan. bitcoind provides a way of checking for the status of the scan and later extract the result, however we don't know how to do that exactly. Check bitcoind documentation.

I could not find the mentioned option. One can start the request and later get the status, however, this does not resolve our timeout issue. The initial call still needs to run and wait for the results.

e.g.:

bitcoin-cli -testnet scantxoutset start '[{"desc":"combo(tpubD91aWShJqtFfoq76ngAtuVzSenQRUc3QEsfKHwxvTHtKQUtB7B3DwXthq6F2SGvmQNu3oWB9zxp1M4h8jsLxKc8pfpQASTQ9k6Sg3uiFpro)", "range":100}]' &
[1] 23775

bitcoin-cli -testnet scantxoutset status '[{"desc":"combo(tpubD91aWShJqtFfoq76ngAtuVzSenQRUc3QEsfKHwxvTHtKQUtB7B3DwXthq6F2SGvmQNu3oWB9zxp1M4h8jsLxKc8pfpQASTQ9k6Sg3uiFpro)", "range":100}]' &

{
  "progress": 35
}
...
{
  "success": true,
  "searched_items": 22485662,
  "unspents": [
  ],
  "total_amount": 0.00000000
}

It looks like we can't configure the timeout atm. Could be worth ditching the library we are using because it doesn't add much value.

This was wrong, we can indeed change the timeout for the client.

Proposed solution:

Just update the timeout to a higher one, default is 30 seconds.

D4nte commented 5 years ago

I could not find the mentioned option. One can start the request and later get the status, however, this does not resolve our timeout issue. The initial call still needs to run and wait for the results.

You found the mentioned option, it's the status.