Bitcoin Forum
May 02, 2024, 09:12:22 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: TxHash to BlockHash using API  (Read 1165 times)
upal (OP)
Full Member
***
Offline Offline

Activity: 165
Merit: 102


View Profile
December 29, 2013, 04:17:14 PM
 #1

Can anyone plz point out a way to derive the BlockHash from TxHash using API ?
1714684342
Hero Member
*
Offline Offline

Posts: 1714684342

View Profile Personal Message (Offline)

Ignore
1714684342
Reply with quote  #2

1714684342
Report to moderator
Whoever mines the block which ends up containing your transaction will get its fee.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714684342
Hero Member
*
Offline Offline

Posts: 1714684342

View Profile Personal Message (Offline)

Ignore
1714684342
Reply with quote  #2

1714684342
Report to moderator
upal (OP)
Full Member
***
Offline Offline

Activity: 165
Merit: 102


View Profile
January 02, 2014, 09:08:15 PM
 #2

...any help ?
upal (OP)
Full Member
***
Offline Offline

Activity: 165
Merit: 102


View Profile
January 03, 2014, 10:14:19 AM
 #3

Lets assume I am studying the following...

https://blockchain.info/rawtx/5602487e624ee14193f646e29a9ac203335bc962b30155b66d142ab15f79018c

Code:
{"block_height":277586,"time":1388338452,"inputs":[{"prev_out":{"n":0,"value":1683888660,"addr":"14RfKeVn9PrG4CLuyzJYUXiFdqyd7Amjp5","tx_index":102576735,"type":0}}],"vout_sz":2,"relayed_by":"178.194.214.181","hash":"5602487e624ee14193f646e29a9ac203335bc962b30155b66d142ab15f79018c","vin_sz":1,"tx_index":105080382,"ver":1,"out":[{"n":0,"value":1483888660,"addr":"1FxmczX5yUXn6GAZBCJy2Uc25NgzpQNEtM","tx_index":105080382,"spent":false,"type":0},{"n":1,"value":200000000,"addr":"1NbX8RDmNJ2J36LBTBgTU6bwcqdX7Udv2M","tx_index":105080382,"spent":true,"type":0}],"size":225}

I have "block_height":277586

Now, how do I find out the block_hash of this ?

still looking for a solution...
deepceleron
Legendary
*
Offline Offline

Activity: 1512
Merit: 1028



View Profile WWW
January 04, 2014, 12:49:01 AM
 #4

The first question is - what are you trying to do? The questions you ask likely do not solve the problem or answer the question you may have.

If this is your own transaction in Bitcoin-Qt, you can get information about the block it was included in with the console command:

gettransaction 5602487e624ee14193f646e29a9ac203335bc962b30155b66d142ab15f79018c

{
"amount" : 0.10000000,
"fee" : -0.0001000,
"confirmations" : 3592,
"blockhash" : "00000000000000040e4c97bace0df699cabdf5ef68dce31ed62a07fdcb576e6b",
"blockindex" : 22,
"blocktime" : 1387048657,
"txid" : "5602487e624ee14193f646e29a9ac203335bc962b30155b66d142ab15f79018c",
"time" : 1387048401,
"timereceived" : 1387048401, ...

(fake example information above)


If it is an unspent transaction, you can get the transaction itself, but not information about the blockchain:

getrawtransaction 5602487e624ee14193f646e29a9ac203335bc962b30155b66d142ab15f79018c

010000000112e3e4d6554d49d58bb2ebea92cf503c478f3f4c9ac67089644521a7ef41da6000000 0006a47304402207b66a4d39a5e37e501afa84b6499e47928ef2e38bcc09ff079aa9ac08025ddd3 0220378843c39ec76d5f587e3d055a0df0422e66c7e0f6567d38537f59e67938ec8901210217231 bb72798cb5d42b77b8dec1831adf52cdc5a02d23684dd4827c28197a65effffffff021458725800 0000001976a914a41de2dfd3a06aa6ff11e6ff77cd7241df805b0788ac00c2eb0b000000001976a 914ece1ef04103991b1d1241209a37f5d6b84b906fd88ac00000000


Bitcoin does not store a database with more information than it needs to operate, you need to use other tools or a modified Bitcoin to make general queries about other's old transaction information.

You can just put the transaction hash in the front page search box of blockchain.info if you want to find out what block it was included in.
upal (OP)
Full Member
***
Offline Offline

Activity: 165
Merit: 102


View Profile
January 04, 2014, 10:11:38 AM
 #5

The first question is - what are you trying to do? The questions you ask likely do not solve the problem or answer the question you may have.

If this is your own transaction in Bitcoin-Qt, you can get information about the block it was included in with the console command:

gettransaction 5602487e624ee14193f646e29a9ac203335bc962b30155b66d142ab15f79018c

{
"amount" : 0.10000000,
"fee" : -0.0001000,
"confirmations" : 3592,
"blockhash" : "00000000000000040e4c97bace0df699cabdf5ef68dce31ed62a07fdcb576e6b",
"blockindex" : 22,
"blocktime" : 1387048657,
"txid" : "5602487e624ee14193f646e29a9ac203335bc962b30155b66d142ab15f79018c",
"time" : 1387048401,
"timereceived" : 1387048401, ...

(fake example information above)


If it is an unspent transaction, you can get the transaction itself, but not information about the blockchain:

getrawtransaction 5602487e624ee14193f646e29a9ac203335bc962b30155b66d142ab15f79018c

010000000112e3e4d6554d49d58bb2ebea92cf503c478f3f4c9ac67089644521a7ef41da6000000 0006a47304402207b66a4d39a5e37e501afa84b6499e47928ef2e38bcc09ff079aa9ac08025ddd3 0220378843c39ec76d5f587e3d055a0df0422e66c7e0f6567d38537f59e67938ec8901210217231 bb72798cb5d42b77b8dec1831adf52cdc5a02d23684dd4827c28197a65effffffff021458725800 0000001976a914a41de2dfd3a06aa6ff11e6ff77cd7241df805b0788ac00c2eb0b000000001976a 914ece1ef04103991b1d1241209a37f5d6b84b906fd88ac00000000


Bitcoin does not store a database with more information than it needs to operate, you need to use other tools or a modified Bitcoin to make general queries about other's old transaction information.

You can just put the transaction hash in the front page search box of blockchain.info if you want to find out what block it was included in.

First of all thank you so much for taking your time to explain my query.

What am I trying to do ?

I am trying to get the no. of confirmations of any transaction through web api. I asked the question here => https://bitcointalk.org/index.php?topic=385733.0 and it was almost answered by DeathAndTaxes except the method to find out block hash from tx hash. Block Hash was required to ensure that the transaction in question is still in the main chain, as u'll find in the thread I mentioned.

As you have mentioned above, if I were looking into my own transaction, I could get it using gettransaction  through my own Bitcoin-QT. But, as I am writing a web app, I want to query a third party service like blockchain.info or blockexplorer.com, because with the current resource I have, I cant afford to run a Bitcoin-QT on my server.

As I have mentioned above, from rawtx on blockchain.info I even get the block height, but not the block hash. I used to find blockhash by querying blockexplorer.com through like the following...

http://blockexplorer.com/q/getblockhash/277586

But, for some unknown reason, it is now throwing Error !!!

Neways, my basic question remains the same. I need to find out the block hash from a given transaction through web api.
sidazhang
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
January 06, 2014, 06:19:45 AM
 #6

The first question is - what are you trying to do? The questions you ask likely do not solve the problem or answer the question you may have.

If this is your own transaction in Bitcoin-Qt, you can get information about the block it was included in with the console command:

gettransaction 5602487e624ee14193f646e29a9ac203335bc962b30155b66d142ab15f79018c

{
"amount" : 0.10000000,
"fee" : -0.0001000,
"confirmations" : 3592,
"blockhash" : "00000000000000040e4c97bace0df699cabdf5ef68dce31ed62a07fdcb576e6b",
"blockindex" : 22,
"blocktime" : 1387048657,
"txid" : "5602487e624ee14193f646e29a9ac203335bc962b30155b66d142ab15f79018c",
"time" : 1387048401,
"timereceived" : 1387048401, ...

(fake example information above)


If it is an unspent transaction, you can get the transaction itself, but not information about the blockchain:

getrawtransaction 5602487e624ee14193f646e29a9ac203335bc962b30155b66d142ab15f79018c

010000000112e3e4d6554d49d58bb2ebea92cf503c478f3f4c9ac67089644521a7ef41da6000000 0006a47304402207b66a4d39a5e37e501afa84b6499e47928ef2e38bcc09ff079aa9ac08025ddd3 0220378843c39ec76d5f587e3d055a0df0422e66c7e0f6567d38537f59e67938ec8901210217231 bb72798cb5d42b77b8dec1831adf52cdc5a02d23684dd4827c28197a65effffffff021458725800 0000001976a914a41de2dfd3a06aa6ff11e6ff77cd7241df805b0788ac00c2eb0b000000001976a 914ece1ef04103991b1d1241209a37f5d6b84b906fd88ac00000000


Bitcoin does not store a database with more information than it needs to operate, you need to use other tools or a modified Bitcoin to make general queries about other's old transaction information.

You can just put the transaction hash in the front page search box of blockchain.info if you want to find out what block it was included in.

First of all thank you so much for taking your time to explain my query.

What am I trying to do ?

I am trying to get the no. of confirmations of any transaction through web api. I asked the question here => https://bitcointalk.org/index.php?topic=385733.0 and it was almost answered by DeathAndTaxes except the method to find out block hash from tx hash. Block Hash was required to ensure that the transaction in question is still in the main chain, as u'll find in the thread I mentioned.

As you have mentioned above, if I were looking into my own transaction, I could get it using gettransaction  through my own Bitcoin-QT. But, as I am writing a web app, I want to query a third party service like blockchain.info or blockexplorer.com, because with the current resource I have, I cant afford to run a Bitcoin-QT on my server.

As I have mentioned above, from rawtx on blockchain.info I even get the block height, but not the block hash. I used to find blockhash by querying blockexplorer.com through like the following...

http://blockexplorer.com/q/getblockhash/277586

But, for some unknown reason, it is now throwing Error !!!

Neways, my basic question remains the same. I need to find out the block hash from a given transaction through web api.

Hey Upal,

I wanted to confirm one thing, if you already have the blockheight can't you work out the no. of confirmations by latestblockheight - blockheight the transaction appeared in?
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!