Samudda (OP)
Newbie
Offline
Activity: 11
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 09:47:05 AM |
|
I have a bitcoin address. How do I get it's balance and the amount of BTC it's ever sent and received? I don't want to use any third-party bitcoin services, I want to do it as directly as possible. How can I do that?
|
|
|
|
RustyNomad
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 11:14:50 AM |
|
You will have to use a third party or a wallet AFAIK.
Easiest is to go to blockchain.info and just paste the address in the search at the top. That will pull all the history from the block chain for you and will give you a summary of the transactions on that address.
|
|
|
|
deepceleron
Legendary
Offline
Activity: 1512
Merit: 1036
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 11:37:22 AM |
|
|
|
|
|
amaclin
Legendary
Offline
Activity: 1260
Merit: 1019
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 11:38:04 AM |
|
You should code something like this: long balance = 0; for ( int i = 0; !atEnd ( ); i++ ) { Block b = getBlock ( i ); for ( int j = 0; j < b.txCount ( ); j++ ) { Transaction tx = b.getTransaction ( j ); for ( int k = 0; k < tx.countOutputs ( ); k++ ) { Output out = tx.getOutput ( k ); if ( out.isMyIncoming ( ) ) balance += out.getAmount ( ); } for ( int k = 0; k < tx.countInputs ( ); k++ ) { Input in = tx.getInput ( k ); if ( in.isMyOutgoing ( ) ) balance -= in.getAmount ( ); } } }
|
|
|
|
andytoshi
Full Member
![*](https://bitcointalk.org/Themes/custom1/images/star.gif) ![*](https://bitcointalk.org/Themes/custom1/images/star.gif)
Offline
Activity: 179
Merit: 151
-
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 11:55:27 AM |
|
Addresses do not send funds. This is a dangerous misconception covered on the wiki.
|
|
|
|
Samudda (OP)
Newbie
Offline
Activity: 11
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 12:36:32 PM |
|
No third-party services! Why would I do that through a third-party service if I can do that without it? After all, how those third-party services do that? They use the standard way. So I want to find out what this way is and use it too. You should code something like this: long balance = 0; for ( int i = 0; !atEnd ( ); i++ ) ...... }
That doesn't make sense. If what language is this? How can I run it?
|
|
|
|
amaclin
Legendary
Offline
Activity: 1260
Merit: 1019
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 12:47:17 PM |
|
That doesn't make sense. If what language is this? How can I run it? Sorry. It is too difficult for me to explain things in good English. I mean that you should parse blockchain (.blk-files), take each block, parse it, take each transaction, parse inputs and outputs. Of course, my code is not "real code". You should write parser yourself or ask somebody to do it. May be it is also possible to find "exactly-what-you-want-program" in the Internet.
|
|
|
|
Samudda (OP)
Newbie
Offline
Activity: 11
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 01:27:21 PM |
|
service or software, what's the difference? The bottom line is that I don't want to use anything third-party. Thanks for the link but since I'm quite a newbie I'd like more through information.
|
|
|
|
|
Samudda (OP)
Newbie
Offline
Activity: 11
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 01:55:28 PM |
|
Third-party includes any website because protocol bitcoin doesn't have a central web site. Blockchain is also a third-party web site.
|
|
|
|
Samudda (OP)
Newbie
Offline
Activity: 11
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 02:08:20 PM |
|
You will have to use a third party or a wallet AFAIK.
Easiest is to go to blockchain.info and just paste the address in the search at the top. That will pull all the history from the block chain for you and will give you a summary of the transactions on that address.
Have to? You're wrong. blockchain.info obtains that information from somewhere, not from other web site.
|
|
|
|
deepceleron
Legendary
Offline
Activity: 1512
Merit: 1036
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 02:08:37 PM |
|
The question was already answered if attention was paid. Bitcoin won't do it without help. Get ABE open blockchain explorer and install it to work with your own bitcoin, then you can just type the addresses into your own web page once it is indexed.
|
|
|
|
Samudda (OP)
Newbie
Offline
Activity: 11
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 02:18:35 PM |
|
No, it wasn't unanswered.
"just type the addresses into your own web page once it is indexed." - I don't want to type an address. I want to create such a program myself. Is that more clear?
|
|
|
|
amaclin
Legendary
Offline
Activity: 1260
Merit: 1019
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 03:01:27 PM |
|
I want to create such a program myself. Is that more clear? What will be your programming language?
|
|
|
|
keeshux
Newbie
Offline
Activity: 26
Merit: 6
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 03:58:00 PM |
|
You'll be only able to get such information about an address if you have a full node history locally. Given that, the overall process is: - Parse blocks from files
- For each block, iterate through all transactions
- For each transaction, parse output scripts
- If the output script is of some standard form, you can get an address out of its bytes
- If the parsed address matches the one you're interested in, add the transaction to your "interesting" set
- From the relevant transactions you can finally infer all the stats you need, e.g. balance, sent/received..
This is just a generic slow algorithm because I don't know the structure of Bitcoin Core files. Some existing index would surely improve search efficiency (e.g. the UTXO index is enough for the balance), in fact web providers must have some internal index on addresses. I've seen many tools around that build fast databases from raw blocks, but I've never used them. If you don't have any local history, the only way I'm aware of is loading a Bloom filter matching your address and scan the whole blockchain. The peers will then send you relevant transactions for that address plus some unrelevant ones due to the probabilistc nature of the Bloom filter. Beware that you will be forced to do a full rescan for each new address you want to search.
|
|
|
|
amaclin
Legendary
Offline
Activity: 1260
Merit: 1019
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 04:08:54 PM |
|
This is just a generic slow algorithm because I don't know the structure of Bitcoin Core files. 1) It is not very slow, because you should not verify signatures (your bitcoind did it) 2) Bitcoin core files have very simple structure. Have a look here https://bitcointalk.org/index.php?topic=762445.msg8623440#msg8623440
|
|
|
|
keeshux
Newbie
Offline
Activity: 26
Merit: 6
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 04:17:22 PM |
|
Not intrinsically slow, probably slow when run on 20GB of unindexed data..
|
|
|
|
amaclin
Legendary
Offline
Activity: 1260
Merit: 1019
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 04:29:08 PM |
|
Not intrinsically slow, probably slow when run on 20GB of unindexed data.. something x2...x3 times slower than just copying 20gb of data
|
|
|
|
Buffer Overflow
Legendary
Offline
Activity: 1652
Merit: 1016
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 06:28:46 PM |
|
No, it wasn't unanswered.
"just type the addresses into your own web page once it is indexed." - I don't want to type an address. I want to create such a program myself. Is that more clear?
Then you need to have a full bitcoin node running locally. The program your planning to make will need to query the node's database to find the transactions your looking for. This has been done already. Unless your after some programming practise, why reinvent the wheel?
|
|
|
|
keeshux
Newbie
Offline
Activity: 26
Merit: 6
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
September 10, 2014, 06:50:26 PM |
|
Not intrinsically slow, probably slow when run on 20GB of unindexed data.. something x2...x3 times slower than just copying 20gb of data I would consider "slow" a database query that takes that much. ![Smiley](https://bitcointalk.org/Smileys/default/smiley.gif) That's why a nice indexed structure is a huge advantage and several tools certainly exist to build an efficient blockchain database and execute fast queries on top of it. Unless it's about practicing, as Buffer Overflow pointed out.
|
|
|
|
|