-
Notifications
You must be signed in to change notification settings - Fork 117
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
Comments
Thanks @Saturnix - would you like to submit a pull request? |
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. |
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:
|
Done. I hope I did everything ok.
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. |
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... |
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 [ ]
The text was updated successfully, but these errors were encountered: