Bitcoin Forum
November 15, 2024, 03:35:47 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Get balance of *coin addresses  (Read 947 times)
crazydownloaded (OP)
Full Member
***
Offline Offline

Activity: 148
Merit: 100

Crazy!


View Profile
May 04, 2013, 06:54:01 PM
 #1

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.

Est. February 2012
Revalin
Hero Member
*****
Offline Offline

Activity: 728
Merit: 500


165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g


View Profile
May 04, 2013, 07:01:37 PM
 #2

You may like: bitcoind -blocknotify=<cmd>

      War is God's way of teaching Americans geography.  --Ambrose Bierce
Bitcoin is the Devil's way of teaching geeks economics.  --Revalin 165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g
crazydownloaded (OP)
Full Member
***
Offline Offline

Activity: 148
Merit: 100

Crazy!


View Profile
May 04, 2013, 07:27:48 PM
 #3

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.

Est. February 2012
bukaj
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile
May 04, 2013, 10:33:35 PM
 #4

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.
crazydownloaded (OP)
Full Member
***
Offline Offline

Activity: 148
Merit: 100

Crazy!


View Profile
May 05, 2013, 06:51:15 AM
 #5

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...

Est. February 2012
bukaj
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile
May 05, 2013, 09:35:18 AM
 #6

I'm not sure about that, but I think you have to run bitcoind with -txindex option set.
crazydownloaded (OP)
Full Member
***
Offline Offline

Activity: 148
Merit: 100

Crazy!


View Profile
May 05, 2013, 09:55:25 AM
 #7

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?

Est. February 2012
bukaj
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile
May 05, 2013, 02:25:21 PM
 #8

I got similar problem: https://bitcointalk.org/index.php?topic=195816.0
crazydownloaded (OP)
Full Member
***
Offline Offline

Activity: 148
Merit: 100

Crazy!


View Profile
May 05, 2013, 03:59:37 PM
Last edit: May 05, 2013, 04:16:03 PM by crazydownloaded
 #9

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?

Est. February 2012
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!