Bitcoin Forum
June 23, 2024, 03:46:01 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to get the information about a bitcoin address without 3rd-pard services?  (Read 1439 times)
Samudda (OP)
Newbie
*
Offline Offline

Activity: 11
Merit: 0


View Profile
September 10, 2014, 09:47:05 AM
 #1

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

Activity: 336
Merit: 250



View Profile WWW
September 10, 2014, 11:14:50 AM
 #2

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 Offline

Activity: 1512
Merit: 1032



View Profile WWW
September 10, 2014, 11:37:22 AM
 #3

http://bitcoin.stackexchange.com/questions/10090/how-to-get-an-addresss-balance-with-the-bitcoin-client

If you don't want to use a third-party service, you can use third-party software on your own Bitcoin:
https://en.bitcoin.it/wiki/Abe
https://insight.bitpay.com/

amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
September 10, 2014, 11:38:04 AM
 #4

You should code something like this:

Code:
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
***
Offline Offline

Activity: 179
Merit: 151

-


View Profile
September 10, 2014, 11:55:27 AM
 #5

Addresses do not send funds. This is a dangerous misconception covered on the wiki.
Samudda (OP)
Newbie
*
Offline Offline

Activity: 11
Merit: 0


View Profile
September 10, 2014, 12:36:32 PM
 #6

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:

Code:
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 Offline

Activity: 1260
Merit: 1019


View Profile
September 10, 2014, 12:47:17 PM
 #7

Quote
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 Offline

Activity: 11
Merit: 0


View Profile
September 10, 2014, 01:27:21 PM
 #8


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

Activity: 560
Merit: 506


I prefer Zakir over Muhammed when mentioning me!


View Profile WWW
September 10, 2014, 01:50:22 PM
 #9

You can get some API for for transactions of an address here : https://blockchain.info/api/blockchain_api . Do 'third party' includes blockexplorer and wallets?

  ~~MZ~~

Samudda (OP)
Newbie
*
Offline Offline

Activity: 11
Merit: 0


View Profile
September 10, 2014, 01:55:28 PM
 #10

You can get some API for for transactions of an address here : https://blockchain.info/api/blockchain_api . Do 'third party' includes blockexplorer and wallets?

  ~~MZ~~

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 Offline

Activity: 11
Merit: 0


View Profile
September 10, 2014, 02:08:20 PM
 #11

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 Offline

Activity: 1512
Merit: 1032



View Profile WWW
September 10, 2014, 02:08:37 PM
 #12

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 Offline

Activity: 11
Merit: 0


View Profile
September 10, 2014, 02:18:35 PM
 #13

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 Offline

Activity: 1260
Merit: 1019


View Profile
September 10, 2014, 03:01:27 PM
 #14

Quote
I want to create such a program myself. Is that more clear?

What will be your programming language?
keeshux
Newbie
*
Offline Offline

Activity: 26
Merit: 6


View Profile WWW
September 10, 2014, 03:58:00 PM
 #15

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 Offline

Activity: 1260
Merit: 1019


View Profile
September 10, 2014, 04:08:54 PM
 #16

Quote
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 Offline

Activity: 26
Merit: 6


View Profile WWW
September 10, 2014, 04:17:22 PM
 #17

Quote
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


Not intrinsically slow, probably slow when run on 20GB of unindexed data..
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
September 10, 2014, 04:29:08 PM
 #18

Quote
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 Offline

Activity: 1652
Merit: 1015



View Profile
September 10, 2014, 06:28:46 PM
 #19

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 Offline

Activity: 26
Merit: 6


View Profile WWW
September 10, 2014, 06:50:26 PM
 #20

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