Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Can't use method get_account_data #178

Closed
shinraki opened this issue May 24, 2018 · 7 comments
Closed

Can't use method get_account_data #178

shinraki opened this issue May 24, 2018 · 7 comments
Labels

Comments

@shinraki
Copy link

Hi everybody. I mistakenly tried to send more tokens than it was on the address and now I can't check the balance by calling of get_account_data method
I get the message

Traceback (most recent call last):
File "/lib/python3.6/site-packages/iota/commands/__init__.py", line 130, in __call__
  self.response = self._execute(self.request)
File "lib/python3.6/site-packages/iota/commands/extended/get_account_data.py", line 74, in _execute
  inclusion_states    = inclusion_states,
File "lib/python3.6/site-packages/iota/commands/extended/utils.py", line 125, in get_bundles_from_transaction_hashes
  gb_response = GetBundlesCommand(adapter)(transaction=txn.hash)
File "lib/python3.6/site-packages/iota/commands/__init__.py", line 130, in __call__
  self.response = self._execute(self.request)
File "lib/python3.6/site-packages/iota/commands/extended/get_bundles.py", line 49, in _execute
  'errors': validator.errors,
iota.adapter.BadApiResponse: Bundle failed validation (``exc.context`` has more info).

How can I solve the problem?

@todofixthis
Copy link
Contributor

Hey @shinraki sorry you're running into this issue.

Couple of thoughts:

  • Try capturing the exception context. This is a dict that PyOTA attaches to many exceptions that can provide additional information to help debug issues:
    from pprint import pprint
    
    try:
      gad_response = api.get_account_data()
    except Exception as e:
      context = getattr(e, "context", {})
      raise
    else:
      context = None
    
    pprint(context)
  • Try connecting to a different node; if the transaction is invalid, the node should not have propagated it, so you should not have any problems with other nodes.
  • If you can capture the hash for the invalid bundle (you can get it easily by capturing the exception context), try contacting the node maintainer and/or posting an issue on the IRI issue tracker — I would expect that a node should drop invalid transactions after long enough.

Let me know if you are able to make any progress on this. If not, I will try reaching out to some of the IRI maintainers to see if they have any other suggestions.

@shinraki
Copy link
Author

Hey @todofixthis Thank you for your answer!

I forgot to say that I'm using testnet.

I got context. It says 'Transaction 1 has invalid signature (using 2 fragments).' Also now I can get bundle hash.
I tried to connect to a public testnet node: https://testnet140.tangle.works/ instead of my own local, but it didn't help. I met the same issue.
Also I contacted the node maintainer from my team, but he don't know how to drop invalid transactions. Can you help and tell how to do it?
And as I noticed our local node won't drop invalid transactions by themself after approximately 2 weeks from time when I first met this problem.
I hope for feedback

@todofixthis
Copy link
Contributor

Hmm... that's curious; invalid signature. Could you post a link to the bundle on a Tangle explorer? I'm curious to see what happened.

In the meantime, I think you might be best off fetching the transactions manually. Have a look at the iota.commands.extended.utils.iter_used_addresses function. This generator will find all addresses that have transactions. You can then pipe them into the iota.commands.extended.utils.find_transaction_objects function (this will be converted into a proper API method soon) to retrieve the corresponding Transaction objects.

If you want to get the bundles, you can use the iota.commands.extended.utils.get_bundles_from_transaction_hashes function instead — basically reimplementing the GetBundles command, just without the validator (:

@shinraki
Copy link
Author

shinraki commented May 29, 2018

https://testnet.thetangle.org/bundle/UBZHVZEIVYDBDTGFAAEN9QTHFCNFPVDQKYCIBUH9LPKEZQKYXDB9ODMBGHQCTHD9VKXYTJQGUGGOJAKX9

I used the methods described by you and now I can receive incoming transactions and bundles from seed.

But I used the method get_account_data not only to get the incoming transactions, but also to get the seed balance. If I sum up the value of the received incoming transactions it won't be a seed balance since it doesn't take into account outgoing transactions. The same applies for the method get_inputs.

If I understand this correctly. Please correct me if I'm wrong. How can I get the seed balance by ignoring the method get_account_data?

@todofixthis
Copy link
Contributor

Interesting. There's only 1 input transaction in that bundle; most of the time there are 2 transactions per input (depends on the security level of the address, but it defaults to 2).

To get the account balance, you can use iter_used_addresses() in conjunction with Iota.get_balances().

@shinraki
Copy link
Author

Thank you very much for your recommendations! I hope in the future I will be able to safely use the method get_account_data :)

@todofixthis
Copy link
Contributor

Best of luck mate! Sorry for the trouble; I've logged #179 to propose a way to prevent this issue in the future.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants