<p><code>getrawtransaction</code>'s behaviour has not changed since Bitcoin Core 0.8 (up until at least 0.14).</p>

<p>It will always work:</p>

<ul>
<li>For mempool (unconfirmed) transactions</li>
<li>For confirmed transactions that have unspent outputs left.</li>
</ul>

<p>So, <code>-txindex=1</code> is only needed in order to query for confirmed transactions of which all the outputs are spent. It also speeds up querying for confirmed transactions in general.</p>

CC BY-SA 3.0
2017-04-06T15:44:23.757Z
It's been a while since the question was asked, but i still get the -5 code for many transactions even after making the necessary changes in the conf file and reindexing multiple times. For example, 57d15d040e147a0276a5ec314f78559b370f360a4e2cef9194fa52c9f7bd6314 was the hash i was returned when sending 0.0001 to a certain address on testnet. Can you please explain why this is happening?
Shabahat M. Ayubi
CC BY-SA 3.0
2017-04-06T15:45:05.063Z
All the other 0.0001 valued transactions give the same error code.
Shabahat M. Ayubi
CC BY-SA 3.0
2017-03-01T07:55:12.917Z
2017-03-01T07:55:12.917Z
Pieter Wuille
<p>A few months back when I wanted to use <code>getrawtransaction</code> API call on any txid other than my bitcoin core wallet it would return an error. The error was resolved by adding txindex=1 to the conf file and restarting the daemon with -reindex option. 
Now while teaching the concepts to a colleague, I was hoping they would search for the solution when they faced a similar error and would update the conf file. However, the API called returned with the transaction details for any txid and there was no bitcoin.conf file created.</p>

<p>Has the implementation changed which I am not aware about? </p>

<reindex>
Is txindex=1 necessary in the latest versions?
Shabahat M. Ayubi
# Is txindex=1 necessary in the latest versions?

(Asked by: username_0 on 2017-03-01)

A few months back when I wanted to use `getrawtransaction` API call on any txid other than my bitcoin core wallet it would return an error. The error was resolved by adding txindex=1 to the conf file and restarting the daemon with -reindex option.
Now while teaching the concepts to a colleague, I was hoping they would search for the solution when they faced a similar error and would update the conf file. However, the API called returned with the transaction details for any txid and there was no bitcoin.conf file created.

Has the implementation changed which I am not aware about?

**Tags:** reindex


---

## 1 answers

### Answer by username_1 on 2017-03-01. Score: 3 | Accepted answer

`getrawtransaction`'s behaviour has not changed since Bitcoin Core 0.8 (up until at least 0.14).

It will always work:

* For mempool (unconfirmed) transactions
* For confirmed transactions that have unspent outputs left.

So, `-txindex=1` is only needed in order to query for confirmed transactions of which all the outputs are spent. It also speeds up querying for confirmed transactions in general.

> **Comments:**
> **username_0**: It's been a while since the question was asked, but i still get the -5 code for many transactions even after making the necessary changes in the conf file and reindexing multiple times. For example, 57d15d040e147a0276a5ec314f78559b370f360a4e2cef9194fa52c9f7bd6314 was the hash i was returned when sending 0.0001 to a certain address on testnet. Can you please explain why this is happening?  
> **username_0**: All the other 0.0001 valued transactions give the same error code.  

---

