Bitcoin Forum
December 03, 2016, 12:28:46 AM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Transaction block hash  (Read 1013 times)
vuce
Sr. Member
****
Offline Offline

Activity: 476


View Profile
June 05, 2012, 02:12:41 PM
 #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.
1480724926
Hero Member
*
Offline Offline

Posts: 1480724926

View Profile Personal Message (Offline)

Ignore
1480724926
Reply with quote  #2

1480724926
Report to moderator
1480724926
Hero Member
*
Offline Offline

Posts: 1480724926

View Profile Personal Message (Offline)

Ignore
1480724926
Reply with quote  #2

1480724926
Report to moderator
1480724926
Hero Member
*
Offline Offline

Posts: 1480724926

View Profile Personal Message (Offline)

Ignore
1480724926
Reply with quote  #2

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

Posts: 1480724926

View Profile Personal Message (Offline)

Ignore
1480724926
Reply with quote  #2

1480724926
Report to moderator
1480724926
Hero Member
*
Offline Offline

Posts: 1480724926

View Profile Personal Message (Offline)

Ignore
1480724926
Reply with quote  #2

1480724926
Report to moderator
Stephen Gornick
Legendary
*
Offline Offline

Activity: 1988



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.

vuce
Sr. Member
****
Offline Offline

Activity: 476


View Profile
June 05, 2012, 10:38:57 PM
 #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: 1988



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

vuce
Sr. Member
****
Offline Offline

Activity: 476


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: 1988



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/

vuce
Sr. Member
****
Offline Offline

Activity: 476


View Profile
June 06, 2012, 09:22:20 AM
 #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: 1036


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

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

aka sipa, core dev team

Tips and donations: 1KwDYMJMS4xq3ZEWYfdBRwYG2fHwhZsipa
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!