Post
Topic
Board Bitcoin Technical Support
Re: How can I automatically add all Bitcoin addresses ever used to a MySQL database?
by
rabit
on 13/12/2013, 16:44:28 UTC
I wrote some time ago a bash script which analyzes all transactions in a block. You could just go through all blocks with
bitcoind getblockhash and start the script with the blockhash as a parameter (you would need to add some stuff to the script like the SQL stuff but maybe its anyway helpful).
Here is the relevant part of the bash script:

#!/bin/bash
#Search for transactions in block
#INPUT:Blockhash

txlist=$(bitcoind getblock $1)
txlist="${txlist%]*}"
txlist="${txlist#*[}"
txlist2=""
while [ "$txlist" != "$txlist2" ]; do
   txlist2=$txlist
   tx="${txlist%%,*}"
   tx="${tx#*'"'}"
   tx="${tx%'"'*}"
   txlist="${txlist#*,}"
   test=$(bitcoind gettransaction $tx 2> /dev/null)
   if [ "$test" != "" ]; then
      #Here you need to add code to get the relevant data from the transaction like output addresses
                #and add it to the SQL DB
   fi
done


EDIT: I just realized that gettransaction only works with transaction which you made yourself so for analyzing all transactions you would need to use something like
a=$(bitcoind getrawtransaction $tx)
b=$(bitcoind decoderawtransaction $a)