How to list non-zero wallet addresses and balances in Python?

4 replies 391 views
greg.wolfMember
Posts: 4 · Reputation: 50
#1Jan 9, 2020, 06:25 AM
I’m trying to figure out how to list all non-zero wallet addresses and their balances from the blockchain using Python. Would love to include extra info like last transactions if possible. Seems like a common project, similar to those old rich list websites. I’ve got my Bitcoin Core synced with RPC on, but hitting a wall here. Any ideas?
3 Reply Quote Share
mr_apeNewbie
Posts: 170 · Reputation: 35
#2Jan 9, 2020, 11:48 AM
Addresses, not wallets. Just sayin'. And I really doubt using RPC is efficient for this. If your node is synced, why not just read the data directly from the disk? Also, be careful with your code. Using >= in some places can mess things up. Standard script lengths are fixed, like P2PKH is 25 bytes. Anything else might be non-standard or worse.
0 Reply Quote Share
gang2015Member
Posts: 269 · Reputation: 62
#3Jan 11, 2020, 10:07 PM
For real-time updates, have you looked into running an Electrum server? They have an address index, and you can either access the database or use Electrum’s protocol. Just a thought. Makes it easier, I think.
2 Reply Quote Share
greg.wolfMember
Posts: 4 · Reputation: 50
#4Jan 12, 2020, 12:39 AM
Wow, thanks! That’s what I needed. Kinda bummed I couldn’t crack it myself, though. Definitely gonna dig more into it.
1 Reply Quote Share
orbit1337Senior Member
Posts: 161 · Reputation: 941
#5Jan 12, 2020, 03:06 AM
I’ve seen tools for exporting UTXO lists, but never used them myself. There's bitcoin-utxo-dump, for example. Use it at your own risk, and do your research first.
2 Reply Quote Share

Related topics