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

<p><code>
...
    "blockhash" : "000000000000000009e865d07f75341a5f3dc15f0e149055a241eedd552c3b88",
    "confirmations" : 1,
    "time" : 1433965052,
    "blocktime" : 1433965052
}
</code></p>

CC BY-SA 3.0
2015-12-02T20:34:56.473Z
How does this work though? Does bitcoin client build an index of all transactions in the block chain?
Andrew Savinykh
CC BY-SA 3.0
2015-12-14T12:22:29.803Z
Yes. This only works for "all transactions" when -txindex is enabled.
Jonas Schnelli
CC BY-SA 3.0
2015-06-10T19:39:51.627Z
2015-06-10T19:39:51.627Z
Jonas Schnelli
<p>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.</p>

<p>How do I get the block a given transaction is included in?</p>

CC BY-SA 3.0
2015-06-10T19:35:06.563Z
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.
Luca Matteis
CC BY-SA 3.0
2015-06-11T20:24:27.430Z
If you set txindex=1 in the conf then it will index all transactions.
user3601780
<transactions><bitcoind><json-rpc>
How do I find out what block a transaction is in?
user3601780
# How do I find out what block a transaction is in?

(Asked by: username_0 on 2015-06-10)

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?

**Tags:** transactions, bitcoind, json-rpc

> **Comments:**
> **username_1**: 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.  
> **username_0**: If you set txindex=1 in the conf then it will index all transactions.  

---

## 1 answers

### Answer by username_2 on 2015-06-10. Score: 4 | Accepted answer

`./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
}`

> **Comments:**
> **username_3**: How does this work though? Does bitcoin client build an index of all transactions in the block chain?  
> **username_2**: Yes. This only works for "all transactions" when -txindex is enabled.  

---

