bibajz / bitcoin-python-async-rpc

Minimal Bitcoin JSON-RPC Python asynchronous client
MIT License
33 stars 12 forks source link

getnetworkhashps() throws error #12

Closed sawyerru closed 2 years ago

sawyerru commented 2 years ago

Hello, I'm having an issue collecting the network hash rate. I've used this repo to collect transaction and network information before, but I'm having issues with the getnetworkhashps() function.

It's throwing this error:

decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]

SCRIPT:

# needed to connect to btc node
btc_rpc_connection = AuthServiceProxy("http://%s:%s@%s"%(RPC_BTC_USER, RPC_BTC_PASS, BTC_NODE))
x = btc_rpc_connection.getnetworkhashps()
print(x)

Any help would be great. Thanks

sawyerru commented 2 years ago

Closing.

Updated with:

async def main():
    async with BitcoinRPC(f"http://{BTC_NODE}", RPC_BTC_USER, RPC_BTC_PASS) as rpc:
        y = await rpc.getnetworkhashps(height=100)
        print(y)