<p>By default <code>-txindex=0</code> Bitcoin Core doesn't maintain any transaction-level data except for those </p>

<ul>
<li>in the mempool or relay set</li>
<li>pertinent to addresses in your wallet </li>
<li>pertinent to your <a href="https://bitcoin.org/en/glossary/watch-only-address" rel="noreferrer">"watch-only"</a> addresses</li>
</ul>

<p>If "txindex" is set to true (1), Bitcoin Core maintains an index of all transactions that have ever happened, which you can query using the remote procedure call (RPC) method <a href="https://bitcoin.org/en/developer-reference#getrawtransaction" rel="noreferrer"><code>getrawtransaction</code></a> or the RESTful API call <a href="https://bitcoin.org/en/developer-reference#get-tx" rel="noreferrer">get-tx</a>.</p>

<p>Several popular wallet and "block explorer" programs require <code>-txindex=1</code>. Note that <code>txindex</code> does not alter the behavior of Bitcoin's peer-to-peer interface.</p>

CC BY-SA 3.0
2015-07-07T15:37:49.260Z
Funny because I Googled into this and found myself reading an answer that was flat-out wrong. To my surprise when I got to the end, I saw my own name! I just rewrote my answer.
Chris Arnesen
CC BY-SA 3.0
2015-08-01T20:30:08.607Z
Bitcoin core does maintain transaction-level data for all unspents, regardless of whether the address belongs to you or not. Otherwise it won't be able to validate incoming transactions.
k kurokawa
CC BY-SA 3.0
2015-08-02T21:34:59.747Z
@kaykurokawa : I don't know precisely what's included in the "relay set" but that's the terminology consistently used by the developer documentation on bitcoin.org. Of course it must include unspents, but what else is in there?
Chris Arnesen
CC BY-SA 3.0
2015-08-03T03:40:03.863Z
ah I see, I was not aware of that term.
k kurokawa
CC BY-SA 3.0
2017-11-16T18:29:35.153Z
@chrisamesen That's really cool- It didn't occur to me wiki information correction also works with your past and future selves.
cmc
CC BY-SA 3.0
2015-06-15T02:44:05.883Z
2017-02-02T14:40:55.077Z
2017-02-02T14:40:55.077Z
Chris Arnesen
<p>In addition, txindex=1 used to be required if you wanted to use LND (lightning network daemon). See <a href="https://github.com/lightningnetwork/lnd/pull/751" rel="noreferrer">https://github.com/lightningnetwork/lnd/pull/751</a></p>

CC BY-SA 4.0
2018-12-16T20:37:43.540Z
@Janus: I've rejected your edit since it changes the content of the answer completely. You should rather add a new answer to mention ElectrumX.
Murch
CC BY-SA 4.0
2018-04-06T18:58:48.853Z
2018-10-31T16:12:22.720Z
2018-10-31T16:12:22.720Z
Offer Markovich
<p>In addition to the other answers, <code>txindex=1</code> is required if you want to use your wallet with Counterparty.</p>

<p>See the installation instructions at <a href="https://github.com/CounterpartyXCP/counterparty-lib" rel="nofollow noreferrer">https://github.com/CounterpartyXCP/counterparty-lib</a></p>

CC BY-SA 3.0
2018-01-15T09:52:42.557Z
2018-01-15T09:52:42.557Z
alexg
<p>If you're using Bitcoin Core just for your own personal use, you probably don't need the <code>-txindex=1</code> option. But, if you're using Bitcoin core for development or blockchain analysis of some sort, you will need to set <code>-txindex=1</code> to be able to get transactions data for any transaction in the blockchain. </p>

<p>The tradeoff is just that keeping an index is slightly slower, but allows you to do things like:</p>

<pre><code>bitcoin-cli getrawtransaction aec2729f5e46750b310b6feadcf853098aa86df74f93322a701c29cd68b22568 
</code></pre>

<p>(where <code>aec2729f5e46750b310b6feadcf853098aa86df74f93322a701c29cd68b22568</code> is the ID of a transaction that does not affect your wallet at all).</p>

<p>Also, if you have been running your client for a while but haven't had <code>txindex=1</code> set, then it might take a few hours to build the index. If you want to rebuild, launch with the <code>-reindex</code> option.</p>

CC BY-SA 3.0
2015-01-24T16:32:38.223Z
♦ Thank you very much for your prompt reply. I understood it. I expected that I could save a lot of time to sync the blockchain but it would be not true as far as I read your answer.
zono
CC BY-SA 3.0
2017-04-03T13:42:43.980Z
Does setting txindex=1 or reindex=1 cause a new download?  The prod chain is so big, I would like to avoid that if possible.
Steve Hibbert
CC BY-SA 3.0
2017-04-03T13:52:07.820Z
@SteveHibbert no, it doesn't re-download the data, because you should already have the data on disk, it just reprocesses the data you have. It is still time consuming, though.
morsecoder
CC BY-SA 3.0
2017-04-03T15:17:09.470Z
@StephenM347 Great, thanks for that, much obliged.
Steve Hibbert
CC BY-SA 3.0
2015-01-24T16:23:43.803Z
2015-01-24T16:23:43.803Z
morsecoder
<p>I am reading <a href="http://chimera.labs.oreilly.com/books/1234000001802/ch03.html#_exploring_and_decoding_transactions">"Mastering Bitcoin" written by Andreas</a> and I found this explanation about "txindex option"</p>

<blockquote>
  <h3>Transaction Database Index and txindex Option</h3>
  
  <p>By default, Bitcoin Core builds a database containing only the
  transactions related to the user’s wallet. If you want to be able to
  access any transaction with commands like gettransaction, you need to
  configure Bitcoin Core to build a complete transaction index, which
  can be achieved with the txindex option. Set txindex=1 in the Bitcoin
  Core configuration file</p>
</blockquote>

<p>I am not sure what situations should I enable the option. In my understanding, I can set <code>txindex=0</code> if I use <code>bitcoind</code> as just a transmission tool of Bitcoin so that I can save data and time to sync the blockchain data. Otherwise, if I intend to make a blockexplore site like <a href="https://blockchain.info">Blockchain.info</a>, I need to set <code>txindex=1</code>.</p>

<p>Is my understanding of this correct?</p>

<bitcoin.conf><mastering-bitcoin><txindex>
What are pros and cons of txindex option?
zono
# What are pros and cons of txindex option?

(Asked by: username_0 on 2015-01-24)

I am reading ["Mastering Bitcoin" written by Andreas](http://chimera.labs.oreilly.com/books/1234000001802/ch03.html#_exploring_and_decoding_transactions) and I found this explanation about "txindex option"

> ### Transaction Database Index and txindex Option
>
> By default, Bitcoin Core builds a database containing only the
> transactions related to the user’s wallet. If you want to be able to
> access any transaction with commands like gettransaction, you need to
> configure Bitcoin Core to build a complete transaction index, which
> can be achieved with the txindex option. Set txindex=1 in the Bitcoin
> Core configuration file

I am not sure what situations should I enable the option. In my understanding, I can set `txindex=0` if I use `bitcoind` as just a transmission tool of Bitcoin so that I can save data and time to sync the blockchain data. Otherwise, if I intend to make a blockexplore site like [Blockchain.info](https://blockchain.info), I need to set `txindex=1`.

Is my understanding of this correct?

**Tags:** bitcoin.conf, mastering-bitcoin, txindex


---

## 4 answers

### Answer by username_7 on 2015-01-24. Score: 53 | Accepted answer

If you're using Bitcoin Core just for your own personal use, you probably don't need the `-txindex=1` option. But, if you're using Bitcoin core for development or blockchain analysis of some sort, you will need to set `-txindex=1` to be able to get transactions data for any transaction in the blockchain.

The tradeoff is just that keeping an index is slightly slower, but allows you to do things like:

```
bitcoin-cli getrawtransaction aec2729f5e46750b310b6feadcf853098aa86df74f93322a701c29cd68b22568 

```

(where `aec2729f5e46750b310b6feadcf853098aa86df74f93322a701c29cd68b22568` is the ID of a transaction that does not affect your wallet at all).

Also, if you have been running your client for a while but haven't had `txindex=1` set, then it might take a few hours to build the index. If you want to rebuild, launch with the `-reindex` option.

> **Comments:**
> **username_0**: ♦ Thank you very much for your prompt reply. I understood it. I expected that I could save a lot of time to sync the blockchain but it would be not true as far as I read your answer.  
> **username_8**: Does setting txindex=1 or reindex=1 cause a new download?  The prod chain is so big, I would like to avoid that if possible.  
> **username_7**: @username_8 no, it doesn't re-download the data, because you should already have the data on disk, it just reprocesses the data you have. It is still time consuming, though.  
> **username_8**: @StephenM347 Great, thanks for that, much obliged.  

---

### Answer by username_1 on 2015-06-15. Score: 18

By default `-txindex=0` Bitcoin Core doesn't maintain any transaction-level data except for those

* in the mempool or relay set
* pertinent to addresses in your wallet
* pertinent to your ["watch-only"](https://bitcoin.org/en/glossary/watch-only-address) addresses

If "txindex" is set to true (1), Bitcoin Core maintains an index of all transactions that have ever happened, which you can query using the remote procedure call (RPC) method [`getrawtransaction`](https://bitcoin.org/en/developer-reference#getrawtransaction) or the RESTful API call [get-tx](https://bitcoin.org/en/developer-reference#get-tx).

Several popular wallet and "block explorer" programs require `-txindex=1`. Note that `txindex` does not alter the behavior of Bitcoin's peer-to-peer interface.

> **Comments:**
> **username_1**: Funny because I Googled into this and found myself reading an answer that was flat-out wrong. To my surprise when I got to the end, I saw my own name! I just rewrote my answer.  
> **username_2**: Bitcoin core does maintain transaction-level data for all unspents, regardless of whether the address belongs to you or not. Otherwise it won't be able to validate incoming transactions.  
> **username_1**: @kaykurokawa : I don't know precisely what's included in the "relay set" but that's the terminology consistently used by the developer documentation on bitcoin.org. Of course it must include unspents, but what else is in there?  
> **username_2**: ah I see, I was not aware of that term.  
> **username_3**: @chrisamesen That's really cool- It didn't occur to me wiki information correction also works with your past and future selves.  

---

### Answer by username_4 on 2018-04-06. Score: 6

In addition, txindex=1 used to be required if you wanted to use LND (lightning network daemon). See <https://github.com/lightningnetwork/lnd/pull/751>

> **Comments:**
> **username_5**: @Janus: I've rejected your edit since it changes the content of the answer completely. You should rather add a new answer to mention ElectrumX.  

---

### Answer by username_6 on 2018-01-15. Score: 3

In addition to the other answers, `txindex=1` is required if you want to use your wallet with Counterparty.

See the installation instructions at <https://github.com/CounterpartyXCP/counterparty-lib>


---

