Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: crazydownloaded on May 04, 2013, 06:54:01 PM



Title: Get balance of *coin addresses
Post by: crazydownloaded on May 04, 2013, 06:54:01 PM
Hello,
I'd like to do a multicurrency dashboard. BY multicurrency, I mean really the more altcoins possible.
My problem is to be able to check the balance of a user given address.
I understood it's not possible to get the balance of any address using only the "bitcoind like" program, so I'd like to index blockchains/transactions in a SQL database, so I can do the "getbalance" work myself.
My problem is : how could I get "real time" blocks and transactions to put them in the database preferentially using the bitcoind software provided with each altcoin?
Did someone already addressed this issue?

Ideally I'd like something like (todo ?) a webservice like blochain.info that works every altcoin.

Any help greatly appreciated.
Thanks.


Title: Re: Get balance of *coin addresses
Post by: Revalin on May 04, 2013, 07:01:37 PM
You may like: bitcoind -blocknotify=<cmd>


Title: Re: Get balance of *coin addresses
Post by: crazydownloaded on May 04, 2013, 07:27:48 PM
Yes, this seems to be great!
What I don't understand, is how do I get the list of transactions included in the block (listsinceblock returns an empty transaction array, which seems odd, right?).
Then I guess I could use massive "gettransaction" calls to reconstitute the graph of the transactions.


Title: Re: Get balance of *coin addresses
Post by: bukaj on May 04, 2013, 10:33:35 PM
Yes, this seems to be great!
What I don't understand, is how do I get the list of transactions included in the block (listsinceblock returns an empty transaction array, which seems odd, right?).
Then I guess I could use massive "gettransaction" calls to reconstitute the graph of the transactions.

listsinceblock return transactions concerning addresses in your wallet. The same goes for gettransaction. Try getblock.


Title: Re: Get balance of *coin addresses
Post by: crazydownloaded on May 05, 2013, 06:51:15 AM
OK, getblock does the job to list transactions included in the wallet. But how can I get the details for each of those transactions?
You are right, gettransaction/getrawtransaction are only for the transactions concerning the wallet, despite the man page not saying it (https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list).
I see no way to get the details of a given transaction through bitcoind...


Title: Re: Get balance of *coin addresses
Post by: bukaj on May 05, 2013, 09:35:18 AM
I'm not sure about that, but I think you have to run bitcoind with -txindex option set.


Title: Re: Get balance of *coin addresses
Post by: crazydownloaded on May 05, 2013, 09:55:25 AM
dammit, bitcoind documentation sucks!
even with -txindex=1 -reindex=1 :
gettransaction 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b (the first transaction ever in bitcoin history): Invalid or non-wallet transaction id!
getrawtransaction on it fails too

gettransaction fails on any non wallet transaction
on other transactions I tested, getrawtransaction works fine, but need another call to decoderawtransaction to get the readable data (basically what getransaction would do in a single call).
I guess this could do the job however.

Other problem: how to handle blockchains (temporary) forks? (like the one in march)? How to be notified by the bitcoind that the history has changed since block xxx?


Title: Re: Get balance of *coin addresses
Post by: bukaj on May 05, 2013, 02:25:21 PM
I got similar problem: https://bitcointalk.org/index.php?topic=195816.0 (https://bitcointalk.org/index.php?topic=195816.0)


Title: Re: Get balance of *coin addresses
Post by: crazydownloaded on May 05, 2013, 03:59:37 PM
Yep :/
I'm currently importing the whole blockchain to a mongodb database so I can easily query it (currently only at block 5000).
I don't know how I will deal with blockchain rewrites (maybe by occasionaly deleting/reimporting last weeks blocks and transactions for example).
My concern now is how will I get the balance of a say address by querying the transactions... I would hate having caches in this situation, because of the "moving" past.
I guess I will query all "vout" transactions to the address, then query for all "vin" transactions referencing a previously returned "vout" transaction, right?