kyuupichan / electrumx

Alternative implementation of spesmilo/electrum-server
Other
725 stars 733 forks source link

TypeError when doing blockchain.transaction.get #502

Closed cipig closed 6 years ago

cipig commented 6 years ago

i see this error in the logs from time to time... doesn't seem to affect operation though

ERROR:ElectrumX:[27751] exception raised processing request: RPCRequest('blockchain.transaction.get', ['bcab4f00967a38004e4e50a92d82e44cda65d7035d4e03a6e951af8c91e24933', None], 3)
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/aiorpcX-0.5.6-py3.6.egg/aiorpcx/rpc.py", line 376, in _response_message
    result = task.result()
  File "/usr/local/lib/python3.6/dist-packages/aiorpcX-0.5.6-py3.6.egg/aiorpcx/rpc.py", line 470, in _process_request
    return await rpc_call()
  File "/usr/local/lib/python3.6/dist-packages/electrumx-ElectrumX.1.4.4p2-py3.6.egg/server/controller.py", line 855, in transaction_get
    return await self.daemon_request('getrawtransaction', tx_hash, verbose)
  File "/usr/local/lib/python3.6/dist-packages/electrumx-ElectrumX.1.4.4p2-py3.6.egg/server/controller.py", line 672, in daemon_request
    return await getattr(self.daemon, method)(*args)
  File "/usr/local/lib/python3.6/dist-packages/electrumx-ElectrumX.1.4.4p2-py3.6.egg/server/daemon.py", line 278, in getrawtransaction
    (hex_hash, int(verbose)))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
kyuupichan commented 6 years ago

What is passing None? That's the problem, but I should handle it better

kyuupichan commented 6 years ago

I'm about to push a fix; if this persists please let me know which coin you are using and what the client application is passing.

cipig commented 6 years ago

Unfortunately the problem is still there. The coin is KMD and the application is BarterDEX, a decentralized exchange. The problem is that BarterDEX asks the electrum-servers about transactions that are not necessarily already existent, so it could well be that the txid from the error message is not known to the electrum server. BarterDEX is doing this during a swap, when it waits for the other party to do some expected transactions before it continues with the atomic swap.

cipig commented 6 years ago

Oh, sorry, i looked wrong... it was an other coin, where i didn't updated the code... so, nevermind, my fault...

kyuupichan commented 6 years ago

Well the lack of validation was a problem, now fixed, but it seems to me that the client (whatever it is) is where the real problem is here.

cipig commented 6 years ago

Hmmm, the fix made it worser...

Here is an example: komodo-cli getrawtransaction "9fab67666ec927263b3e776320bbc0b6f71ddfceabb434d938012a3cc072e99d" shows 0100000001792a612fa27ad1ba9f2a5c31198d384c90694db748ea40437c35a1ab1b611188000000006b4830450221008933318400436417f8b97e74b7374574fc965de2580c884dc7b192d0979fcdb402203c6ac6de15dd4d5bdababd514e6e669de249a7fefc184beed91406291e250fbb0121026da2fc632afabbb1b86d04a9a012db25eca74db38ba2eccd88552f27f4c0b245ffffffff028abf9b0f0000000017a914d062e5aa554041d87d5423f10e3f21bb9580ebaa875f36e929000000001976a914ed56f2feb905938b45d2e009ec14add0e7d0157288ac22ac325b

but (echo '{ "id": 1, "method": "blockchain.transaction.get", "params": ["9fab67666ec927263b3e776320bbc0b6f71ddfceabb434d938012a3cc072e99d"] }'; sleep 0.5) | ncat electrum2.cipig.net 10001 shows {"jsonrpc": "2.0", "error": {"code": 2, "message": "daemon error: {'code': -1, 'message': 'JSON value is not an integer as expected'}"}, "id": 1}

kyuupichan commented 6 years ago

Can you confirm all is good with https://github.com/kyuupichan/electrumx/commit/70f8d7c4b95011d02628bba0d0773c362824b1f4