Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Btceon on June 10, 2019, 11:54:11 AM



Title: How to check the balance of the list of 1 million Bitcoin Addresses?
Post by: Btceon on June 10, 2019, 11:54:11 AM
How to check the balance of the list of 1 million Bitcoin Addresses? Is there such a program?


Title: Re: How to check the balance of the list of 1 million Bitcoin Addresses?
Post by: NeuroticFish on June 10, 2019, 12:44:50 PM
How to check the balance of the list of 1 million Bitcoin Addresses? Is there such a program?

You'll clearly need bitcoin core or at least it's chain data.

Option 1.
There are programs like this one (Google result) (https://github.com/graymauser/btcposbal2csv) that parse the chain data and return more usable formats, from csv to proper database.
The one I've found returns the addresses with balance. You'll search the addresses there (and if not found then the balance is 0)

Option 2.
Play directly with bitcoin core with RPC calls.
ListUnspent (https://bitcoin.org/en/developer-reference#listunspent) will give you the list of unspent inputs for one or more addresses.
You'll have to compose from them the actual balance though.


Title: Re: How to check the balance of the list of 1 million Bitcoin Addresses?
Post by: aplistir on June 10, 2019, 05:44:41 PM
the fastest and easiest way to make unlimited searches without running a node, is to download the current list of all addresses with balances

And then do searches from that file.

filesize is only about 900MB.

The drawback is obviously that all the results you get are from the moment when the list was generated.
If you need to know the balances from this exact second then this is obviously not for you.

This thread has info on how to make or get a list of all addresses with balances.
https://bitcointalk.org/index.php?topic=267618.320


Title: Re: How to check the balance of the list of 1 million Bitcoin Addresses?
Post by: seoincorporation on June 11, 2019, 12:15:17 PM
How to check the balance of the list of 1 million Bitcoin Addresses? Is there such a program?

In what format you have those Addresses? As aplistir say, you can download the file about addys with balance and then compare it with your addys list, You could make an script for this... Lets supose you have your addys on a text file, first you have to download this https://balances.syndevio.com/ ( balances-bitcoin-20190611-0000 (673317892 bytes, 2019-06-11T00:20:22+00:00 - sample) )

Then a code llike:

Code:
for a in $(cat myAddyList.txt)
do
cat balances-bitcoin | grep $a >> final.txt
done

With this bash script you will generate a file with the addys and balance...


Title: Re: How to check the balance of the list of 1 million Bitcoin Addresses?
Post by: bob123 on June 12, 2019, 07:37:26 AM
Then a code llike:

Code:
for a in $(cat myAddyList.txt)
do
cat balances-bitcoin | grep $a >> final.txt
done

With this bash script you will generate a file with the addys and balance...


This is extremely inefficient and probably will take quite some time.

The fastest approach would be some sort of a perl script. But since the there aren't too many entries in bitcoin-balances, a simple grep would be 'ok', i think:

Code:
grep -f -F myAddyList.txt balances-bitcoin > final.txt


This already is way faster than your bash script, however it is still far away from being really efficient.


Title: Re: How to check the balance of the list of 1 million Bitcoin Addresses?
Post by: starmyc on June 17, 2019, 08:37:11 AM
Hello,

I would rather personally use a 3rd party key/value database in order to manipulate small data set like this, like redis.
A way to do it would be:

First, import database (& go take a coffee, as it will take a few minutes):

Code:
$ awk -F ';'  '{print "SET " $1 " " $2 }' < balances-bitcoin-20190617-0000-foryjL2u  | redis-cli >/dev/null

Check database import by cheching number of keys:

Code:
$ wc -l ~mycroft/balances-bitcoin-20190617-0000-foryjL2u
25330187 /home/mycroft/balances-bitcoin-20190617-0000-foryjL2u

$ redis-cli dbsize
(integer) 25330187

Then, retrieve all wanted balances & build a k/v export set (where "randomset" is the list of addresses searched in database):

Code:
$ awk '{print "GET " $1 }' < randomset  | redis-cli | tr -d \" > randomset.balances

$ paste randomset randomset.balances
1FMbcnYvvccZ6hR324cFRpn1QX9TCkqtAe      800000001092
1C7u4Zqu6ZZRsiKsFMYVDvNLfCwsGrbeTq      800000001092
155fzsEBHy9Ri2bMQ8uuuR3tv1YzcDywd4      191404456773
1BzK87zuqidZn489Wb2oLSktrjKrX7TLKe      200000174647
16BBBjvAArL3zdb1Fh1isr2w2hX7K1K4Gm      800000001092

Not found value would show (nil), which would make easy to know they are not appearing in database.


Title: Re: How to check the balance of the list of 1 million Bitcoin Addresses?
Post by: crofrihosl on September 15, 2019, 11:44:29 PM
is there an alternative script for windows  ???

Code:
some script > myAddyList.txt > balances-bitcoin > final.txt


Title: Re: How to check the balance of the list of 1 million Bitcoin Addresses?
Post by: bob123 on September 16, 2019, 06:34:17 PM
is there an alternative script for windows  ???

Code:
some script > myAddyList.txt > balances-bitcoin > final.txt


Sure, just take my example from above:

Code:
grep -f -F myAddyList.txt balances-bitcoin > final.txt

and make a Select-string[1] statement out of it for powershell.



[1] https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/select-string?view=powershell-6 (https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/select-string?view=powershell-6)


Title: Re: How to check the balance of the list of 1 million Bitcoin Addresses?
Post by: crofrihosl on September 16, 2019, 09:49:27 PM
for a second i say WHAT in windows!!!

i put some addresses in myAddyList.txt dir: C:\Users\x

Code:
PS C:\Users\x> findstr.exe -f -F myAddyList.txt balances-bitcoin > final.txt
i get this error
Code:
FINDSTR: Cannot open balances-bitcoin



Title: Re: How to check the balance of the list of 1 million Bitcoin Addresses?
Post by: bob123 on September 17, 2019, 05:01:54 PM
for a second i say WHAT in windows!!!

i put some addresses in myAddyList.txt dir: C:\Users\x

Code:
PS C:\Users\x> findstr.exe -f -F myAddyList.txt balances-bitcoin > final.txt
i get this error
Code:
FINDSTR: Cannot open balances-bitcoin


Does the textfile balances-bitcoin exist? Did you download it ?
Please read the thread from the beginning if you didn't download it yet.

Also, you need to adjust the syntax. Windows does not take parameters with a "-" but with a "/"
You can find a lot of explanations of findstr online, to properly adjust your syntax.