How to find a block containing a transaction using transaction hash only?

2

1

Well, the title says it all. I have a transaction hash and I want to find this transaction in the blockchain. I am working with bitcoinj.

I am probably missing something very obvious here, but I cannot find how to do it.

Flot2011

Posted 2014-06-10T16:53:02.550

Reputation: 131

Answers

1

The transaction does not know the block in which it was integrated.

https://en.bitcoin.it/wiki/Protocol_specification#tx

There are many services around like blockchain.info or blockexplorer.com which stores the blockchain and have indexed all transactions, which you can search.

Dennis Kriechel

Posted 2014-06-10T16:53:02.550

Reputation: 1 603

Some transactions are in multiple blocks, for instance: https://blockchain.info/tx/392655224c035f4ace1dfb3d95f86406bfc82e646b27b731faeab052209e0b0a

Willem Hengeveld 2014-06-10T19:10:14.600

The link only shows one transaction, and what you are suggesting is a double-spend. You cannot spend the same transaction outputs twice or more.T9b 2014-06-10T19:24:22.843

1

@T9b the link shows that it was included in the following blocks (one's an orphan, the other made it onto the main chain, both height 297359): https://blockchain.info/block-index/401024 https://blockchain.info/block-index/401025 So orphaned blocks are an exception to the rule, and probably not the point of the question.

Tim S. 2014-06-10T19:53:43.697

Maybe not the point of the question, but i am showing that there is not always a unique answer. ... Another one, this time in 2 very early mainchain blocks (height 91722 and 91880): https://blockchain.info/tx/e3bf3d07d4b0375638d5f1db5255fe07ba2c4cb067cd81b84ee974b6585fb468

Willem Hengeveld 2014-06-11T08:28:38.847

@WillemHengeveld how is that possible?Dennis Kriechel 2014-06-11T08:34:25.090

1

looking at http://blockexplorer.com/b/91880 there is a remark about a bug in the miner that mined that block.

Willem Hengeveld 2014-06-11T09:22:23.530

Does the p2p protocol support this?Jus12 2018-01-10T15:11:45.410