Bitcoin Forum
May 05, 2024, 07:48:13 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: how to get the balance of your address in bitcoinj  (Read 6431 times)
ILoveUBtc (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 0


View Profile
September 19, 2013, 09:51:16 AM
 #1

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.
1714938493
Hero Member
*
Offline Offline

Posts: 1714938493

View Profile Personal Message (Offline)

Ignore
1714938493
Reply with quote  #2

1714938493
Report to moderator
1714938493
Hero Member
*
Offline Offline

Posts: 1714938493

View Profile Personal Message (Offline)

Ignore
1714938493
Reply with quote  #2

1714938493
Report to moderator
1714938493
Hero Member
*
Offline Offline

Posts: 1714938493

View Profile Personal Message (Offline)

Ignore
1714938493
Reply with quote  #2

1714938493
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714938493
Hero Member
*
Offline Offline

Posts: 1714938493

View Profile Personal Message (Offline)

Ignore
1714938493
Reply with quote  #2

1714938493
Report to moderator
1714938493
Hero Member
*
Offline Offline

Posts: 1714938493

View Profile Personal Message (Offline)

Ignore
1714938493
Reply with quote  #2

1714938493
Report to moderator
Mike Hearn
Moderator
Legendary
*
Offline Offline

Activity: 1526
Merit: 1129


View Profile
September 19, 2013, 03:05:57 PM
 #2

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.
ILoveUBtc (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 0


View Profile
September 19, 2013, 04:42:43 PM
 #3

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?
Mike Hearn
Moderator
Legendary
*
Offline Offline

Activity: 1526
Merit: 1129


View Profile
September 20, 2013, 01:36:01 PM
 #4

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.
Amitabh S
Legendary
*
Offline Offline

Activity: 1001
Merit: 1003


View Profile
October 29, 2014, 07:21:02 AM
 #5

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?

Coinsecure referral ID: https://coinsecure.in/signup/refamit (use this link to signup)
garyramsey389
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
November 07, 2014, 02:02:32 PM
 #6

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

Mike Hearn
Moderator
Legendary
*
Offline Offline

Activity: 1526
Merit: 1129


View Profile
November 07, 2014, 05:06:36 PM
 #7

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