# Buggy code
def load_token_balance(self):
    self.request_mgr = TriblerRequestManager()
    self.request_mgr.perform_request(
        "trustchain/statistics", self.received_token_balance, capture_errors=False
    )


# Traceback (TypeError)
ERROR   1538645830.67              rest_manager:53   (RESTRequest)  [Failure instance: Traceback: <type 'exceptions.TypeError'>: 'NoneType' object is not iterable
/home/sandip/.local/lib/python2.7/site-packages/twisted/protocols/basic.py:572:dataReceived
/home/sandip/.local/lib/python2.7/site-packages/twisted/web/http.py:2099:lineReceived
/home/sandip/.local/lib/python2.7/site-packages/twisted/web/http.py:2190:allContentReceived
/home/sandip/.local/lib/python2.7/site-packages/twisted/web/http.py:917:requestReceived
--- <exception caught here> ---
/home/sandip/.local/lib/python2.7/site-packages/twisted/web/server.py:198:process
/home/sandip/.local/lib/python2.7/site-packages/twisted/web/server.py:258:render
/home/sandip/.local/lib/python2.7/site-packages/twisted/web/resource.py:250:render
/home/sandip/tudelft/tribler/Tribler/Core/Modules/restapi/trustchain_endpoint.py:85:render_GET
/home/sandip/tudelft/tribler/Tribler/pyipv8/ipv8/util.py:49:helper
/home/sandip/tudelft/tribler/Tribler/pyipv8/ipv8/util.py:61:blockingCallFromThread
/home/sandip/tudelft/tribler/Tribler/Core/Modules/wallet/tc_wallet.py:172:get_statistics
/home/sandip/tudelft/tribler/Tribler/pyipv8/ipv8/attestation/trustchain/database.py:156:get_latest
/home/sandip/tudelft/tribler/Tribler/pyipv8/ipv8/attestation/trustchain/database.py:78:_get
]
Traceback (most recent call last):
File "/home/sandip/.local/lib/python2.7/site-packages/twisted/web/server.py", line 198, in process
self.render(resrc)
File "/home/sandip/.local/lib/python2.7/site-packages/twisted/web/server.py", line 258, in render
body = resrc.render(self)
File "/home/sandip/.local/lib/python2.7/site-packages/twisted/web/resource.py", line 250, in render
return m(request)
File "/home/sandip/tudelft/tribler/Tribler/Core/Modules/restapi/trustchain_endpoint.py", line 85, in render_GET
return json.dumps({'statistics': self.session.lm.wallets['MB'].get_statistics()})
File "/home/sandip/tudelft/tribler/Tribler/pyipv8/ipv8/util.py", line 49, in helper
return blockingCallFromThread(reactor, func, *args, **kargs)
File "/home/sandip/tudelft/tribler/Tribler/pyipv8/ipv8/util.py", line 61, in blockingCallFromThread
return f(*args, **kwargs)
File "/home/sandip/tudelft/tribler/Tribler/Core/Modules/wallet/tc_wallet.py", line 172, in get_statistics
latest_block = self.trustchain.persistence.get_latest(public_key, block_type='tribler_bandwidth')
File "/home/sandip/tudelft/tribler/Tribler/pyipv8/ipv8/attestation/trustchain/database.py", line 156, in get_latest
(database_blob(public_key), block_type, database_blob(public_key), block_type))
File "/home/sandip/tudelft/tribler/Tribler/pyipv8/ipv8/attestation/trustchain/database.py", line 78, in _get
db_result = list(self.execute(self.get_sql_header() + query, params, fetch_all=False))
TypeError: 'NoneType' object is not iterable

# Fixed code
def load_token_balance(self):
    self.request_mgr = TriblerRequestManager()
    self.request_mgr.perform_request(
        "trustchain/statistics",
        self.received_trustchain_statistics,
        capture_errors=False,
    )