Author

Topic: How can I automatically add all Bitcoin addresses ever used to a MySQL database? (Read 1076 times)

legendary
Activity: 1400
Merit: 1005
Thanks for the bash rabit, I'll consider it..!

Thanks, that makes sense.  I was hoping to not have to deal with JSON-RPC because I am so unfamiliar with it, but perhaps it is time to force myself to learn more about it.

Hey you can always parse the raw blockchain files Smiley. I have some Perl code for that if you're interested.
Oooh, nice!  Wink
legendary
Activity: 1974
Merit: 1029
Thanks, that makes sense.  I was hoping to not have to deal with JSON-RPC because I am so unfamiliar with it, but perhaps it is time to force myself to learn more about it.

Hey you can always parse the raw blockchain files Smiley. I have some Perl code for that if you're interested.
member
Activity: 62
Merit: 10
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)
legendary
Activity: 1400
Merit: 1005
My problem comes in getting the data from bitcoin-qt (or another source) in the first place.

I'd like to set up some sort of cron job that looks for new addresses in the latest blocks coming through, and adds said addresses to the MySQL DB after 6 confirmations.  What's the best way to accomplish this?

I'd do a getblock and for each transaction in it, do a decoderawtransaction and iterate the vouts in it.
Thanks, that makes sense.  I was hoping to not have to deal with JSON-RPC because I am so unfamiliar with it, but perhaps it is time to force myself to learn more about it.
legendary
Activity: 1974
Merit: 1029
My problem comes in getting the data from bitcoin-qt (or another source) in the first place.

I'd like to set up some sort of cron job that looks for new addresses in the latest blocks coming through, and adds said addresses to the MySQL DB after 6 confirmations.  What's the best way to accomplish this?

I'd do a getblock and for each transaction in it, do a decoderawtransaction and iterate the vouts in it.
legendary
Activity: 1400
Merit: 1005
How can I automatically add all Bitcoin addresses ever used to a MySQL database in realtime?

I need to move firstbits.net away from using blockchain.info's API, since the firstbits no longer appear to be working at blockchain.info and haven't been for some time.  I'm no expert programmer, but I know enough about PHP and MySQL querying to get the website job done.  My problem comes in getting the data from bitcoin-qt (or another source) in the first place.

I'd like to set up some sort of cron job that looks for new addresses in the latest blocks coming through, and adds said addresses to the MySQL DB after 6 confirmations.  What's the best way to accomplish this?
Jump to: