get_balance() method is broken
lorrod opened this issue · 3 comments
Get balance wallet method raises an error.
Traceback (most recent call last):
File "/src/errors/handle.py", line 24, in wrapper
ad = func(*args, **kwargs)
File "/src/api/handle.py", line 160, in on_fetched_resource
document[BALANCE_FIELD] = my_wallet.get_balance()
File "/src/payment/ton.py", line 78, in get_balance
nano_balance = self.wallet.get_balance()
File "/usr/local/lib/python3.8/site-packages/ton-0.14-py3.8.egg/ton/sync.py", line 18, in syncified
return loop.run_until_complete(coro)
File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/usr/local/lib/python3.8/site-packages/ton-0.14-py3.8.egg/ton/models/contract.py", line 31, in get_balance
return int((await self.get_state()).balance) # in nanocoins
AttributeError: 'TLObject' object has no attribute 'balance'
This issue was caused by 500 response from liteservers (TIMEOUT).
I have tried most of them from newton config with no luck.
It was fixed by changing default config on class initialisation to https://ton.org/global-config.json
Get balance wallet method raises an error.
Traceback (most recent call last): File "/src/errors/handle.py", line 24, in wrapper ad = func(*args, **kwargs) File "/src/api/handle.py", line 160, in on_fetched_resource document[BALANCE_FIELD] = my_wallet.get_balance() File "/src/payment/ton.py", line 78, in get_balance nano_balance = self.wallet.get_balance() File "/usr/local/lib/python3.8/site-packages/ton-0.14-py3.8.egg/ton/sync.py", line 18, in syncified return loop.run_until_complete(coro) File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete return future.result() File "/usr/local/lib/python3.8/site-packages/ton-0.14-py3.8.egg/ton/models/contract.py", line 31, in get_balance return int((await self.get_state()).balance) # in nanocoins AttributeError: 'TLObject' object has no attribute 'balance'
First, you should run TonlibClient.set_verbosity_level(5)
to see what's going on inside libtonlibjson. I don't plan to automatic handle the errors that break it.
This issue was caused by 500 response from liteservers (TIMEOUT). I have tried most of them from newton config with no luck.
It was fixed by changing default config on class initialisation to https://ton.org/global-config.json
But, most likely, the problem here is not inside libtonlibjson. At the moment, the first of the liteservers available in the config is used by default. It can often work poorly and you need to use another liteserver. To do this, you need to specify ls_index=2
when initializing TonlibClient. In the future, I plan to make a query controller for absolute stability, but so far so.