bitshares / python-bitshares

Fully featured client-side library for the BitShares Blockchain - written entirely in python.
http://docs.pybitshares.com/
MIT License
162 stars 168 forks source link

KeyError: 'operation_results' #229

Closed bitphage closed 5 years ago

bitphage commented 5 years ago

When calling Market.buy() / sell() with returnOrderId, the following error could happen:

Traceback (most recent call last):
  File "/home/vvk/devel/DEXBot-prod/dexbot/worker.py", line 125, in on_block
    self.workers[worker_name].ontick(data)
  File "/home/vvk/.local/share/virtualenvs/DEXBot-prod-N9mtHQyI/lib/python3.6/site-packages/Events-0.3-py3.6.egg/events/events.py", line 95, in __call__
    f(*a, **kw)
  File "/home/vvk/devel/DEXBot-prod/dexbot/strategies/staggered_orders.py", line 1928, in tick
    self.maintain_strategy()
  File "/home/vvk/devel/DEXBot-prod/dexbot/strategies/staggered_orders.py", line 206, in maintain_strategy
    self.replace_virtual_order_with_real(self.virtual_buy_orders[0])
  File "/home/vvk/devel/DEXBot-prod/dexbot/strategies/staggered_orders.py", line 562, in replace_virtual_order_with_real
    new_order = self.place_market_buy_order(quote_amount, price, returnOrderId=True)
  File "/home/vvk/devel/DEXBot-prod/dexbot/strategies/base.py", line 1119, in place_market_buy_order
    **kwargs
  File "/home/vvk/devel/DEXBot-prod/dexbot/strategies/base.py", line 1202, in retry_action
    return action(*args, **kwargs)
  File "/home/vvk/.local/share/virtualenvs/DEXBot-prod-N9mtHQyI/lib/python3.6/site-packages/bitshares-0.2.1-py3.6.egg/bitshares/market.py", line 463, in buy
    tx["orderid"] = tx["operation_results"][0][1]
KeyError: 'operation_results'

Probably need to add some handling when tx does not contain operation_results.

xeroc commented 5 years ago

I wonder why that would even happen ..