Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_unspents should return an empty list for valid addresses with no transactions #46

Open
Saturnix opened this issue Dec 29, 2015 · 5 comments

Comments

@Saturnix
Copy link

get_unspents("19SbDasdasdNEkwRqnBAv7Ewumy7XcCau9Wp4BH9")

Expected behavior:
result: [ ]

Actual behavior:
result: Exception('Invalid response from blockchain.info.')

Reson:
blockchain.info returns non-JSON response "No free outputs to spend" if the address is valid but with no unspents. The file "blockchain_info.py" (at lines 49 to 53) doesn't check for non-JSON responses but blatantly returns error if it cannot parse JSON content.

Proposed fix:
at line 50:
if r.content == "No free outputs to spend": return [ ]

@shea256
Copy link
Contributor

shea256 commented Dec 29, 2015

Thanks @Saturnix - would you like to submit a pull request?

@Saturnix
Copy link
Author

Hello @shea256, thanks for your interest and wonderful work.

Do you agree that get_unspents should return empty list in this case? Please consider the impact this might have and possible regressions: I have not done so. A "find usages" of get_unspents finds no other place where this is used, so we should be fine.

Yes: I'd like to do a pull request now, though I'm completely new to Git. Sorry in advance should I fail to do so adequately.

@shea256
Copy link
Contributor

shea256 commented Dec 30, 2015

Yes, I agree that this should be an empty list.

Separate issue, but I'd point out that your bitcoin address isn't valid.

And no worries - I'd try looking into how to do a pull request and if you can't figure it out, I can always make the change. But I find it's best if contributors make the changes themselves, for the community at least.

What you should do:

  1. fork the project on github
  2. open the command line and clone the project
  3. make changes and commit them
  4. push your changes to your fork
  5. go to github and submit a pull request from your fork to the origin

Saturnix pushed a commit to Saturnix/pybitcoin that referenced this issue Dec 30, 2015
@Saturnix
Copy link
Author

Done. I hope I did everything ok.

Separate issue, but I'd point out that your bitcoin address isn't valid.

You're right: thanks for pointing out. I generated that address with your class BitcoinPrivateKey. I'll figure out if I've done something wrong with it or if there is a bug in pybitcoin. I suspect the first case: I'll report back.

@Saturnix
Copy link
Author

My error. To do some tests I've added "asdasd" inside of the address to check how the library handles invalid addresses. So I've copied the call to get_unspents with the invalid address, instead of the correct one (which is "get_unspents("19SbDNEkwRqnBAv7Ewumy7XcCau9Wp4BH9")).

1AM in the morning, I need to get some sleep...

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

No branches or pull requests

2 participants