user36307: -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?)

user9822: This is my interpretation from looking at the code.
First, -txindex is parsed, defaulting to false if it doesn't exist.
The argument is to -txindex interpreted as a boolean, which assumes no argument is the same as a true value (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.


36307: <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>
 9822: <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>
