Bitcoin Forum
April 20, 2024, 02:33:30 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Transaction block hash  (Read 1208 times)
vuce (OP)
Sr. Member
****
Offline Offline

Activity: 476
Merit: 250


View Profile
June 05, 2012, 02:12:41 PM
Last edit: June 05, 2012, 03:53:11 PM by vuce
 #1

I need to get the block hash of the block containing specified transaction. I have been parsing blockexplorer for this data, but it seems to be having some difficulties lately, so I'm looking for alternatives. Blockchain.info json api doesn't seem to have this information. Are there any other alternatives? Thanks in advance.
1713580410
Hero Member
*
Offline Offline

Posts: 1713580410

View Profile Personal Message (Offline)

Ignore
1713580410
Reply with quote  #2

1713580410
Report to moderator
1713580410
Hero Member
*
Offline Offline

Posts: 1713580410

View Profile Personal Message (Offline)

Ignore
1713580410
Reply with quote  #2

1713580410
Report to moderator
1713580410
Hero Member
*
Offline Offline

Posts: 1713580410

View Profile Personal Message (Offline)

Ignore
1713580410
Reply with quote  #2

1713580410
Report to moderator
Activity + Trust + Earned Merit == The Most Recognized Users on Bitcointalk
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713580410
Hero Member
*
Offline Offline

Posts: 1713580410

View Profile Personal Message (Offline)

Ignore
1713580410
Reply with quote  #2

1713580410
Report to moderator
1713580410
Hero Member
*
Offline Offline

Posts: 1713580410

View Profile Personal Message (Offline)

Ignore
1713580410
Reply with quote  #2

1713580410
Report to moderator
Stephen Gornick
Legendary
*
Offline Offline

Activity: 2506
Merit: 1010


View Profile
June 05, 2012, 09:38:26 PM
 #2

I need to get the block hash of the block containing specified transaction. I have been parsing blockexplorer for this data, but it seems to be having some difficulties lately, so I'm looking for alternatives. Blockchain.info json api doesn't seem to have this information. Are there any other alternatives? Thanks in advance.

Blockchain.info's API is written to be compatible with the BlockExplorer API.

What approach are you taking on BlockExplorer?

The API does give transactions for each block:
 - http://blockchain.info/rawblock/183164

Though how to figure out which block has a transaction, I'm not sure.

Unichange.me

            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █


vuce (OP)
Sr. Member
****
Offline Offline

Activity: 476
Merit: 250


View Profile
June 05, 2012, 10:38:57 PM
Last edit: June 06, 2012, 08:37:58 AM by vuce
 #3

I need to get the block hash of the block containing specified transaction. I have been parsing blockexplorer for this data, but it seems to be having some difficulties lately, so I'm looking for alternatives. Blockchain.info json api doesn't seem to have this information. Are there any other alternatives? Thanks in advance.

Blockchain.info's API is written to be compatible with the BlockExplorer API.

What approach are you taking on BlockExplorer?

The API does give transactions for each block:
 - http://blockchain.info/rawblock/183164

Though how to figure out which block has a transaction, I'm not sure.

yes, this is exactly what I need to do. I have a transaction hash and I need the block hash containing the transaction (so I can download that block later using bitcoinj, but that library has no way of downloading a transaction from given transaction hash). I am currently parsing the http://blockexplorer.com/tx/txhash page for "Appeared in block #" which in turn has a link containing it's hash. But since blockexplorer is stuck on block #182973 this approach is now useless (and it hasn't been working most of the time as of late anyway). I could use the same approach with blockchain (and I will if there are no better alternatives), but that would mean querying it twice per transaction since the block hash is not on the same page as block number.

A workaround would be somehow importing the raw transaction data from blockchain json api into the bitcoinj Transaction object, but that's quite a bit more difficult than parsing for a block hash...
Stephen Gornick
Legendary
*
Offline Offline

Activity: 2506
Merit: 1010


View Profile
June 06, 2012, 04:47:25 AM
 #4

I see.

If you can run your own bitcoind, Armory can layer on top and give you that info:
 - http://bitcointalk.org/index.php?topic=77650.msg865750#msg865750

Unichange.me

            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █


vuce (OP)
Sr. Member
****
Offline Offline

Activity: 476
Merit: 250


View Profile
June 06, 2012, 08:36:54 AM
 #5

I see.

If you can run your own bitcoind, Armory can layer on top and give you that info:
 - http://bitcointalk.org/index.php?topic=77650.msg865750#msg865750

That'd be an overkill, has to be contained inside a java library, so I guess I'll stick with the route I mentioned above. Thanks anyway.
Stephen Gornick
Legendary
*
Offline Offline

Activity: 2506
Merit: 1010


View Profile
June 06, 2012, 08:54:27 AM
 #6

That'd be an overkill, has to be contained inside a java library,

BitcoinJ can do it too.
 - http://code.google.com/p/bitcoinj/

Unichange.me

            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █


vuce (OP)
Sr. Member
****
Offline Offline

Activity: 476
Merit: 250


View Profile
June 06, 2012, 09:22:20 AM
Last edit: June 06, 2012, 12:26:20 PM by vuce
 #7

That'd be an overkill, has to be contained inside a java library,

BitcoinJ can do it too.
 - http://code.google.com/p/bitcoinj/

That is what I'm using but no, it can't. You can get a block from its hash, but you can't get a transaction from a transaction hash. Unless I've missed something, but I don't think I have.

edit: you can get transactions but only ones connected to your wallet - which makes sense as it tries to keep saved "blockchain" size at a minimum.
Pieter Wuille
Legendary
*
Offline Offline

Activity: 1072
Merit: 1174


View Profile WWW
June 06, 2012, 12:04:08 PM
 #8

Recent versions of bitcoind also report this information via the gettransaction RPC call.

I do Bitcoin stuff.
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!