Get Bitcoin Wallet balance with Python

0

On a tutorial in Youtube it uses pybitcointools. Upon searching it's github repository, I have found that it was not maintained anymore. Are there any alternative to this library which can get wallet balance?

Thank you.

CodeJammer

Posted 2018-09-26T12:47:26.870

Reputation: 3

i assume you want to create a wallet for bitcoin, here the lib for that: https://github.com/1200wd/bitcoinlib

Zombie 2018-09-26T15:21:44.380

Try this one https://github.com/mcdallas/cryptotools

Mike D 2018-09-26T23:13:37.480

Answers

0

Assuming you have a Bitcoin node to execute RPC calls against (i.e. you're running bitcoind with the RPC turned on), you can do this rather simply with pyjsonrpc:

#!/usr/bin/env python
from pyjsonrpc import ServiceProxy

bitcoin = ServiceProxy("http://127.0.0.1:8332")  # this is your bitcoind node and RPC port
bitcoin.username = 'testuser'  # rpcuser
bitcoin.password = 'testpass'  # rpcpassword
print(bitcoin.getbalance())

Motoma

Posted 2018-09-26T12:47:26.870

Reputation: 161

Thank you @Motoma. I am not aware if I have run any local RPC node unless pybitcointools is running it on the background. My intent is to have a personalized payment gateway and be able to track balances of multiple wallet addresses.CodeJammer 2018-09-27T23:20:53.277

@CodeJammer In that case, you'll need to run a local Bitcoin node in addition to the script above. Doing that is probably beyond the scope of this question, but Bitcoin Core or Bcoin are two such options for running a local node.Motoma 2018-09-28T12:36:53.733