monero-ecosystem / monero-python

A comprehensive Python module for handling Monero cryptocurrency
BSD 3-Clause "New" or "Revised" License
247 stars 80 forks source link

Fix output_indices bug #94

Closed jeffro256 closed 3 years ago

jeffro256 commented 3 years ago

When I wrote the output code, I made the assumption that if a transaction was not in the transaction pool then its "output_indices" atrribute would be present. However, upon further testing I found that for transactions with 0 outputs, such as at height 202612, the Monero daemon returns a JSON object with no "output_indices" attribute. This PR should keep a KeyError from occurring.

jeffro256 commented 3 years ago

The question is: should the output_indices attribute of Transaction be None to reflect the JSON, or [] to make more sense for the user, in the case that a transaction is in the blockchain but has no output indices? If we wanted to do the latter, I could push one more commit to add that change.

emesik commented 3 years ago

I'm merging this but having a unit test with the example transaction you mentioned would be wonderful. How about that? :)

OOtta commented 2 years ago

I am experiencing errors with the block 202612, probably the same fix should be applied here https://github.com/monero-ecosystem/monero-python/blob/d24044a5e713fcda24e9d681515a4140bbe33d4a/monero/backends/jsonrpc/daemon.py#L1601

emesik commented 2 years ago

@OOtta Could you check with the latest master, please?

OOtta commented 2 years ago

@emesik works good now, thanks.