fix services.providers - blockcypher, blockchain_info
Telariust opened this issue · 0 comments
Hi, Richard! thx for this beautiful lib
some minor fix
#######################
pycoin/services/blockcypher.py
class BlockcypherProvider(object):
def __init__(self, api_key="", netcode=None):
need fix to
class BlockcypherProvider(object):
def __init__(self, netcode=None, api_key=""):
because other providers has
def __init__(self, netcode):
and default autocall as xxxProvider(flag_coin)
(only direct hand call xxxProvider(netcode=flag_coin) is work)
this creates a invalid token=apikey
url_append = "?unspentOnly=true&token=%s&includeScript=true" % self.api_key
..&token=BTC&..
and begets
HTTP Error 429: Too Many Requests
(when the free limit is not exhausted)
#######################
pycoin/services/blockchain_info.py
origin spendables_for_address() need fix to
def spendables_for_address(self, address):
"""
Return a list of Spendable objects for the
given bitcoin address.
"""
URL = self.api_domain + "/unspent?active=%s" % address
spendables = []
try:
r = json.loads(urlopen(URL).read().decode("utf8"))
except:
pass
else:
for u in r["unspent_outputs"]:
coin_value = u["value"]
script = h2b(u["script"])
previous_hash = h2b(u["tx_hash"])
previous_index = u["tx_output_n"]
spendables.append(Tx.Spendable(coin_value, script, previous_hash, previous_index))
return spendables
because blockchain.info has a feature return str('No free outputs to spend') instead of empty json
#######################
https://chain.so/api/ under Cloudflare = rip service
#######################
i recommend u add support this new providers
https://blockchair.com/api/docs
https://www.blockonomics.co/views/api.html