4

I'm trying to do research on the age of transaction outputs at the time they are spent. I'm running bitcoind on my computer. I have transactions indexed with txindex=1. I want to take a given TXIN and get the block of the TXOUT it spends so I can calculate the age.

How do I get the block a given transaction is included in?

2
  • as far as i know bitcoind only stores information about addresses in your wallet. it does not create an index for every single address. there are blockchain explorers that do that however, such as Insight by BitPay. Commented Jun 10, 2015 at 19:35
  • If you set txindex=1 in the conf then it will index all transactions. Commented Jun 11, 2015 at 20:24

1 Answer 1

4

./src/bitcoin-cli getrawtransaction 4ef653dc90aa25e1a0cc8a45f0484524010e5cc77b8159df6916466c07036482 1 (mind the 1 at the end which means you wish verbose output)

... "blockhash" : "000000000000000009e865d07f75341a5f3dc15f0e149055a241eedd552c3b88", "confirmations" : 1, "time" : 1433965052, "blocktime" : 1433965052 }

2
  • How does this work though? Does bitcoin client build an index of all transactions in the block chain? Commented Dec 2, 2015 at 20:34
  • Yes. This only works for "all transactions" when -txindex is enabled. Commented Dec 14, 2015 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.