<p>This is my interpretation from looking at the code.</p>

<p>First, <a href="https://github.com/bitcoin/bitcoin/blob/5d132e8b974652d96466a1b73ec1231614719fe2/src/validation.cpp#L4147" rel="nofollow noreferrer"><code>-txindex</code> is parsed</a>, defaulting to <a href="https://github.com/bitcoin/bitcoin/blob/214046f69b1978129030ba1f65007d57b29f0761/src/validation.h#L132" rel="nofollow noreferrer"><code>false</code> if it doesn't exist</a>.</p>

<p>The argument is to <code>-txindex</code> <a href="https://github.com/bitcoin/bitcoin/blob/37ffa16933953565dcab5c0d7e0ee1ebb6e349c3/src/util.cpp#L472" rel="nofollow noreferrer">interpreted as a boolean</a>, which assumes <a href="https://github.com/bitcoin/bitcoin/blob/37ffa16933953565dcab5c0d7e0ee1ebb6e349c3/src/util.cpp#L388" rel="nofollow noreferrer">no argument is the same as a true value</a> (or else a non-zero argument is true).</p>

<p>So you do not need to provide an argument to <code>-txindex</code>, but if you do, it should be non-zero.</p>

<ul>
<li>Don't provide <code>-txindex</code>: don't index</li>
<li>Provide <code>-txindex</code> with no argument: do index</li>
<li>Provide <code>-txindex=0</code>: don't index</li>
<li>Provide <code>-txindex=1</code> (or any other non-zero value): do index.</li>
</ul>

CC BY-SA 3.0
2017-12-20T16:48:48.553Z
Thanks, it was `InterpretBool` I didn't find.
davidbak
CC BY-SA 3.0
2017-12-20T15:42:01.167Z
2017-12-20T15:42:01.167Z
Adam Millerchip
<p><code>-txindex</code> is documented (in multiple places) to take no (numeric) argument and that "default: 0".</p>

<p>Does this mean that you have to say <code>-txindex=1</code> to set txindex, or does the mere appearance of <code>-txindex</code> on the command line set it to 1?</p>

<p>(IOW, is the value of the naked <code>-txindex</code> option 0 or 1?)</p>

<bitcoin-core>
Bitcoin core txindex option - does it take argument or not?
davidbak
# Bitcoin core txindex option - does it take argument or not?

(Asked by: username_0 on 2017-12-20)

`-txindex` is documented (in multiple places) to take no (numeric) argument and that "default: 0".

Does this mean that you have to say `-txindex=1` to set txindex, or does the mere appearance of `-txindex` on the command line set it to 1?

(IOW, is the value of the naked `-txindex` option 0 or 1?)

**Tags:** bitcoin-core


---

## 1 answers

### Answer by username_1 on 2017-12-20. Score: 4 | Accepted answer

This is my interpretation from looking at the code.

First, [`-txindex` is parsed](https://github.com/bitcoin/bitcoin/blob/5d132e8b974652d96466a1b73ec1231614719fe2/src/validation.cpp#L4147), defaulting to [`false` if it doesn't exist](https://github.com/bitcoin/bitcoin/blob/214046f69b1978129030ba1f65007d57b29f0761/src/validation.h#L132).

The argument is to `-txindex` [interpreted as a boolean](https://github.com/bitcoin/bitcoin/blob/37ffa16933953565dcab5c0d7e0ee1ebb6e349c3/src/util.cpp#L472), which assumes [no argument is the same as a true value](https://github.com/bitcoin/bitcoin/blob/37ffa16933953565dcab5c0d7e0ee1ebb6e349c3/src/util.cpp#L388) (or else a non-zero argument is true).

So you do not need to provide an argument to `-txindex`, but if you do, it should be non-zero.

* Don't provide `-txindex`: don't index
* Provide `-txindex` with no argument: do index
* Provide `-txindex=0`: don't index
* Provide `-txindex=1` (or any other non-zero value): do index.

> **Comments:**
> **username_0**: Thanks, it was `InterpretBool` I didn't find.  

---

