Author

Topic: how to get the balance of your address in bitcoinj (Read 6450 times)

legendary
Activity: 1526
Merit: 1134
the utxo are just the unspent outputs if I am not mistaken.

How much would this take to store and index in a DB?
I think we need to store something like (address, txHash, vout, value) indexed by address. Would that consume too much resources?

This thread is old - since the question was asked bitcoinj got a PostgreSQL based block store that can calculated indexes over the UTXO set. By setting it up you can do address balance queries fast. There's an open pull req to add a similar store for MySQL too.
newbie
Activity: 9
Merit: 0
I want to develop some apps with java .

But when  I  try to get the balance for a special btc address  from my local  blockchain(local database) .

I don't know how to load the database(may be you call the storedblock class).

I have download the official database and it seems don't work.

As i have checked the old topics in this bbs ,there is a requirement of special database . named    *******.blockchain.

I want to ask ,where to download that type of blockchain.

Thank you very much.

Keep it up and hope you can find what you need ... Wink

legendary
Activity: 1001
Merit: 1005
the utxo are just the unspent outputs if I am not mistaken.

How much would this take to store and index in a DB?
I think we need to store something like (address, txHash, vout, value) indexed by address. Would that consume too much resources?
legendary
Activity: 1526
Merit: 1134
If you look at the H2FullPrunedBlockStore class here:

http://plan99.net/~mike/bitcoinj/0.10/

then this calculates the same database (the utxo set) that Bitcoin-Qt does. Internally it uses an embedded SQL database. By adding an index to that database you could then query the balance of any address immediately, however, the additional index would be quite intensive to calculate (syncing would take a long time). H2 is not a very fast database. And as I said, you'd need to modify the code.
newbie
Activity: 14
Merit: 0
Bitcoinj is not designed for building block explorers or web wallets where that kind of query is common, it's intended for building p2p apps that use local wallets. So that's why you can't figure out how to do it. You could extend the fully verifying store to build the extra indexes and some people have done exactly that, but they never contributed their code upstream.


Oh thank you very much , I wasted a lot of time keep trying .

And now I know ,with bitcoinJ,  I have no way to conveniently check the balance of a giving "bitcoin address".

It only works like Bitcoin-Qt for personal usage. not for public  search.


My question is there is a store class  named DiskStoredBlock.  what is this  stand for ?  doesn't that work for whole database?and any examples for the usage of this class?
legendary
Activity: 1526
Merit: 1134
Bitcoinj is not designed for building block explorers or web wallets where that kind of query is common, it's intended for building p2p apps that use local wallets. So that's why you can't figure out how to do it. You could extend the fully verifying store to build the extra indexes and some people have done exactly that, but they never contributed their code upstream.
newbie
Activity: 14
Merit: 0
I want to develop some apps with java .

But when  I  try to get the balance for a special btc address  from my local  blockchain(local database) .

I don't know how to load the database(may be you call the storedblock class).

I have download the official database and it seems don't work.

As i have checked the old topics in this bbs ,there is a requirement of special database . named    *******.blockchain.

I want to ask ,where to download that type of blockchain.

Thank you very much.
Jump to: