From 09b019cad15253575289137f778c8c7078c9bdd6 Mon Sep 17 00:00:00 2001 From: Saturnix Date: Wed, 30 Dec 2015 00:59:22 +0100 Subject: [PATCH] Proper management of empty addresses. Fixes #46 --- pybitcoin/services/blockchain_info.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pybitcoin/services/blockchain_info.py b/pybitcoin/services/blockchain_info.py index c99b149..093283d 100644 --- a/pybitcoin/services/blockchain_info.py +++ b/pybitcoin/services/blockchain_info.py @@ -47,6 +47,12 @@ def get_unspents(address, blockchain_client=BlockchainInfoClient()): url = url + "&api_code=" + auth[0] r = requests.get(url, auth=auth) + + if r.content == "No free outputs to spend": + return [] + elif r.content == "Invalid Bitcoin Address": + raise Exception('Invalid Bitcoin address') + try: unspents = r.json()["unspent_outputs"] except ValueError, e: