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

fix services.providers - blockcypher, blockchain_info #362

Open
Telariust opened this issue Mar 20, 2020 · 0 comments
Open

fix services.providers - blockcypher, blockchain_info #362

Telariust opened this issue Mar 20, 2020 · 0 comments

Comments

@Telariust
Copy link

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

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

1 participant