How to check balance of multiple Bitcoin addresses [Guide and code]

18 replies 346 views
bull2011Member
Posts: 69 · Reputation: 223
#1Aug 31, 2025, 11:35 AM
A pretty popular question you see around here is: "I've got thousands of bitcoin addresses. How do I check their balances?" I guess this is something people who are into hacking brainwallets or messing with BrainFlayer might ask (check it out on GitHub). Seriously, what other reasons could there be for wanting to check the balances of so many addresses? Not a rhetorical question I'd love to hear other uses! Let me share a method that I sometimes use for this. First off, a politically correct response would be to install a full bitcoin node, get the entire blockchain downloaded, add an Insight server that you can quickly query via API, and then write a script to interact with it. But let’s be real. Most people are too lazy to set all that up or just don’t have the technical know-how. So I’m gonna show you a quick and dirty workaround that doesn’t require any installations or downloads just a Linux machine will do. To start, we need to find other people’s Insight servers that are exposed on the internet and can respond to API calls. An easy way to find these is to use Shodan with this search term: "port:3001 insight bitcoin" If you have a registered Shodan account (they offer free ones too so go sign up), you should be able to find around 35 servers. Just keep in mind that not all of them will be functional. A few will be false positives, while others will actually work.
4 Reply Quote Share
Posts: 24 · Reputation: 124
#2Aug 31, 2025, 12:09 PM
Someone checking "many" addresses would likely be checking mostly "empty" addresses, that is addresses that have no transactions, or that have no unspent inputs. if you have a .csv file with 10,000 addresses it might not be terribly difficult to filter which ones have transactions/unspent inputs, however, this will not scale if you have many millions of addresses. The output on your terminal might cause your computer to run out of memory, but even if the terminal output was removed, looking through a .csv file with millions of lines you don't care about takes up resources unnecessarily, and doing so can require intermediary technical knowledge. I would suggest that output only be recorded if there are transactions, or if the balance is above zero. A business with many customers who either deposit coin, or who pay for their items with coin would have the need to check many addresses on an ongoing basis.
2 Reply Quote Share
im_apeHero Member
Posts: 629 · Reputation: 3824
#3Aug 31, 2025, 03:35 PM
a business does this in reverse, meaning when their mempool receives a new transaction they check the output of that against their list of output-scripts-to-watch which is a sorted and a much smaller list. then if that single transaction had any outputs that matched they raise the respective balance update event of the respective account. the number of txs they receive in their mempool isn't that huge to cause any problems either. what OP is trying to do/teach still mainly concerns those who are trying to steal other people's money even if they are wasting their time.
4 Reply Quote Share
Posts: 24 · Reputation: 124
#4Sep 1, 2025, 12:00 AM
You are assuming the business doesn’t ever experience downtime. You are also assuming there are not any edge cases in which the business might not detect the transaction. The OPs script would also help a business audit their holdings to confirm they have coin they believe they have. I do agree that the intended end user for the OPs script is probably people trying to steal others’ money despite the above. Using others’ insight servers is also questionable. The problem of looking up the balance of many addresses is an interesting engineering problem. I would also prefer it be highlighted that people try to steal brain wallets and that there are “easy to understand” guides on doing so. This should make people think twice before using a brain wallet of their own, and hopefully will lead to less theft from brain wallets over the long term.
2 Reply Quote Share
Posts: 4 · Reputation: 106
#5Sep 1, 2025, 12:23 AM
Why not just (wait 24h and) download the file from https://gz.blockchair.com/bitcoin/addresses/ then use any text editor or write a simple script to work on local data. At least you will not annoy servers with many calls.
0 Reply Quote Share
bull2011Member
Posts: 69 · Reputation: 223
#6Sep 1, 2025, 06:30 AM
I didn't know this one existed, many thanks! EDIT: Aha, so it is capped to 10 KB/s, so that it takes about 21 hours to download the file. Smart business model.
2 Reply Quote Share
Posts: 24 · Reputation: 124
#7Sep 1, 2025, 12:13 PM
I think he answered that question:
6 Reply Quote Share
Posts: 24 · Reputation: 124
#8Sep 1, 2025, 04:06 PM
As discussed above, if using the script in the OP, you are most likely searching for thousands (or more likely millions/billions) of addresses, and a public block explorer is going to rate limit your searches.
4 Reply Quote Share
hash_bossLegendary
Posts: 1166 · Reputation: 5261
#9Sep 1, 2025, 06:41 PM
I realize that fact, but it doesn't change there's ethical problem of using private Bitcoin explorer with sloppy security / without owner's permission. P.S. this is my last reply to prevent further off-topic / topic derailing
2 Reply Quote Share
hodlgangMember
Posts: 41 · Reputation: 241
#10Sep 1, 2025, 07:41 PM
would it not be faster to get the API key for blockchain.com and run a python script? I have such tools and it outputs all balances with tx numbers
1 Reply Quote Share
bull2011Member
Posts: 69 · Reputation: 223
#11Sep 2, 2025, 12:52 AM
If you, or anyone else for that matter, is interested in a copy - without download speed limits - I put a copy of the latest version here: https://www.mediafire.com/file/v30lydmiljcx42w/blockchair_bitcoin_addresses_latest.tsv.gz/file
0 Reply Quote Share
omega_bearFull Member
Posts: 116 · Reputation: 780
#12Sep 2, 2025, 03:10 PM
Can someone modify this code for getting public addresses too ?
5 Reply Quote Share
omega_bearFull Member
Posts: 116 · Reputation: 780
#13Sep 2, 2025, 05:41 PM
Hello I mean Public Key's. Can you modyfy your code pease ?
3 Reply Quote Share
degen_apeMember
Posts: 28 · Reputation: 231
#14Sep 4, 2025, 11:51 PM
I've tested a very fast search method before, and it works great: 1. Use the link above to get all funded Bitcoin addresses 2. Make a list of all addresses you want to check 3. Sort the lists and remove accidental duplicates 4. Add both lists together, sort them again, and find all duplicates All you need for this is Linux commands "sort" and "uniq". It scales very well, checking millions of addresses takes a few seconds and you can search as much as fits your computer's memory. LoyceV post the code! If you want to check for all addresses that have ever been funded before, you'll just need to find a list for that. The main drawback is that you won't catch addresses that have been funded in the past hours if you don't update your list real-time.
3 Reply Quote Share
bull2011Member
Posts: 69 · Reputation: 223
#15Sep 5, 2025, 02:51 AM
This is the best option if you're only interested in the current balance. For various reasons, I'm more interested in transaction history - e.g. "even if the balance is 0, has this public address ever occured on the blockchain?" - and for that you need more input than only Blockchair's list of public addresses that have a positive balance "now".
3 Reply Quote Share
humbleledgerLegendary
Posts: 1027 · Reputation: 6554
#16Sep 5, 2025, 07:33 AM
This works (on Linux) to display addresses that exist in both lists: Option 1 takes 6 seconds on my old laptop, checking 300,000 addresses against 30 million addresses with balance. Blockchair also has all outputs, but at 10 kB/s it's going to take a while. If you can get all addresses ever used from your own version of Bitcoin Core, you're good to go.
2 Reply Quote Share
bull2011Member
Posts: 69 · Reputation: 223
#17Sep 6, 2025, 03:03 PM
Yup. Downloading Bitcoin Core, letting it sync and run a blockparser will do the job. It's not fast and easy; in fact, most if not all block parsers I've tried require almost insane hardware and a decent amount of patience. And some bash skills (such as yours) to produce lists. Provided you have a full node up and running (i.e. a folder containing .blk files), which block parser would you recommend today? I updated my own list of "all used public addresses ever" about a year ago, which gave me a list of around 500 million addresses, and it took some blood, sweat and tears (and curse words). Also, I was never 't able to extract bech32 addresses (bc1...). Since I haven't looked into recent development in the field, I'm interested in knowing which one on github one should go for today. Many thanks.
0 Reply Quote Share
humbleledgerLegendary
Posts: 1027 · Reputation: 6554
#18Sep 6, 2025, 03:13 PM
Actually, I started with this: But splitting it up reduces CPU load when using it more than once. I often end up with dozens of pipes on a line. It's very convenient for testing, after each new pipe I instantly see the result and either adjust it or add the next one. If anyone's interested, I can set up a mirror for the latest version of both of those, for instance with weekly updates (a bit like I did for Bitcoin block data) and download speeds that aren't stuck in the '90s. Update: I'll start downloading gz.blockchair.com/bitcoin/outputs/. It'll take about 5 months. After that, I can share daily updates with decent download speed. Update:
1 Reply Quote Share
nickaltMember
Posts: 32 · Reputation: 129
#19Sep 7, 2025, 02:54 PM
I am interested in following your method, but the SHODAN part isnt very clear About your comment: The first thing we need to do is find other people's Insight servers that are fully exposed to the internet and respond to API-calls. A simple way of locating some of these is by searching Shodan (https://www.shodan.io/) using this phrase: "port:3001 insight bitcoin" I registered, but I found that I could install and run SHODAN CLI form my linux machine.... in any case, I can not find the correct command line in SHODAN to get the resultant IP addresses... I used: shodan "port:3001 insight bitcoin" but returned an error. Would you mind being a little more specific how you perform that search? Do you use the CLI from your linux machine ar do you search in the actual SHODAN website? Many thanks.
4 Reply Quote Share

Related topics