<p><code>gettransaction</code> is a wallet RPC. It only works for transactions your wallet knows about. Presumably this is not the case for a transaction from 2013.</p>

<p><code>getrawtransaction</code> is a node RPC. It works for all transactions, but needs help to find them. One possibility is to enable the transaction index (put <code>txindex=1</code> in bitcoin.conf, or <code>-txindex</code> on the bitcoind command line). Another option is specifying which block the transaction is in.</p>

CC BY-SA 4.0
2019-09-23T16:57:35.890Z
There are 2 files : bitcoin.conf and bitcoind.conf.
In bitcoin.conf: it is all comments. Is that the right file that i should edit?
In some part it writes: 
# Enable pruning to reduce storage requirements by deleting old blocks. 
# This mode is incompatible with -txindex and -rescan.
# 0 = default (no pruning).
# 1 = allows manual pruning via RPC.
Should i add the line there?
Efe
CC BY-SA 4.0
2019-09-23T16:29:37.720Z
2019-09-23T16:29:37.720Z
Pieter Wuille
<p>For the answer to this comment </p>

<blockquote>
  <p>Can you give one example of how to do this in cmd as Pieter said :
  -txindex on the bitcoind command line</p>
</blockquote>

<p>I do an example for my configuration bitcoin core, I using the -txindex</p>

<p>the command for run bitcoin</p>

<pre><code>bitcoind -txindex
</code></pre>

<p>The essential bitcoin.conf configurations</p>

<pre><code>##
## bitcoin.conf configuration file. Lines beginning with # are comments.
##
server=1
rpcuser=YOUR_USER
rpcpassword=YOUR_PAS
</code></pre>

<p>the process bitcoind with the -txindex is longer because bitcoind indexes all block inside the DB, an example, I used an external HDD and in my cases, the process worked for one day </p>

<p>also when the bitcoind has finished you can run your command, so</p>

<pre><code>bitcoin-cli  getrawtransaction 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2
</code></pre>

<p>You will have this result</p>

<pre><code>0100000001186f9f998a5aa6f048e51dd8419a14d8a0f1a8a2836dd734d2804fe65fa35779000000008b483045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e381301410484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adfffffffff0260e31600000000001976a914ab68025513c3dbd2f7b92a94e0581f5d50f654e788acd0ef8000000000001976a9147f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a888ac00000000
</code></pre>

CC BY-SA 4.0
2019-09-23T22:51:30.657Z
2019-09-23T22:51:30.657Z
vincenzopalazzo
<p>I am running bitcoin-d (probably downloading the prev blocks) in a shell.
In another shell i am trying to get the information of a transaction (0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2) with bitcoin-cli. I can see that tx on blockchain.info but when i tried it with <strong>gettransaction</strong> and <strong>getrawtransaction</strong> it didn't work out. Does anyone know why is that?
screenshot below.
<a href="https://i.sstatic.net/DlEJm.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/DlEJm.png" alt="enter image description here"></a></p>

CC BY-SA 4.0
2019-09-23T16:25:51.743Z
Try to call the command `getrawtransaction` this is documentation [reference](https://bitcoincore.org/en/doc/0.18.0/rpc/rawtransactions/getrawtransaction/) if not work, can you public a minimal example for trying the same command?
vincenzopalazzo
CC BY-SA 4.0
2019-09-23T16:51:29.130Z
It says like that: Efe-MacBook-Pro:bitcoin efecini$ bitcoin-cli getrawtransaction 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2
error code: -5
error message:
No such mempool transaction. Use -txindex to enable blockchain transaction queries. Use gettransaction for wallet transactions.
Efe
CC BY-SA 4.0
2019-09-23T16:57:29.687Z
with the command getrawtransaction the your code worked follow pieter's instructions
vincenzopalazzo
CC BY-SA 4.0
2019-09-23T22:10:21.837Z
I restarted the os and typed bitcoind '-txindex=1'
And also add a newline 'txindex=1' in bitcoin.conf.(Also i cant find bitcoin.conf file after i changed it :( )
But stil i get :
error code: -5
error message:
No such mempool or blockchain transaction. Use gettransaction for wallet transactions.
Efe
CC BY-SA 4.0
2019-09-23T22:21:38.197Z
if you run the bitcoind with the --daemon it appare ok but with the -txindex=1 the bitcoin core the blockchain is rescanned so you attend the time for complete the process, it should be the problem. for the bitcoin.conf disappeared, only you can know what dark has happened :)
vincenzopalazzo
CC BY-SA 4.0
2019-09-23T22:37:49.127Z
One last thing : Can you give one example how to do this in cmd like Pieter said :  -txindex on the bitcoind command line
Efe
<transactions><bitcoind><blockchain.info>
Can't get the tx with gettransaction or getrawtransaction methods
Efe
# Can't get the tx with gettransaction or getrawtransaction methods

(Asked by: username_0 on 2019-09-23)

I am running bitcoin-d (probably downloading the prev blocks) in a shell.
In another shell i am trying to get the information of a transaction (0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2) with bitcoin-cli. I can see that tx on blockchain.info but when i tried it with **gettransaction** and **getrawtransaction** it didn't work out. Does anyone know why is that?
screenshot below.
[![enter image description here](https://i.sstatic.net/DlEJm.png)](https://i.sstatic.net/DlEJm.png)

**Tags:** transactions, bitcoind, blockchain.info

> **Comments:**
> **username_1**: Try to call the command `getrawtransaction` this is documentation [reference](https://bitcoincore.org/en/doc/0.18.0/rpc/rawtransactions/getrawtransaction/) if not work, can you public a minimal example for trying the same command?  
> **username_0**: It says like that: Efe-MacBook-Pro:bitcoin efecini$ bitcoin-cli getrawtransaction 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2 error code: -5 error message: No such mempool transaction. Use -txindex to enable blockchain transaction queries. Use gettransaction for wallet transactions.  
> **username_1**: with the command getrawtransaction the your code worked follow username_2's instructions  
> **username_0**: I restarted the os and typed bitcoind '-txindex=1' And also add a newline 'txindex=1' in bitcoin.conf.(Also i cant find bitcoin.conf file after i changed it :( ) But stil i get : error code: -5 error message: No such mempool or blockchain transaction. Use gettransaction for wallet transactions.  
> **username_1**: if you run the bitcoind with the --daemon it appare ok but with the -txindex=1 the bitcoin core the blockchain is rescanned so you attend the time for complete the process, it should be the problem. for the bitcoin.conf disappeared, only you can know what dark has happened :)  
> **username_0**: One last thing : Can you give one example how to do this in cmd like username_2 said :  -txindex on the bitcoind command line  

---

## 2 answers

### Answer by username_2 on 2019-09-23. Score: 4

`gettransaction` is a wallet RPC. It only works for transactions your wallet knows about. Presumably this is not the case for a transaction from 2013.

`getrawtransaction` is a node RPC. It works for all transactions, but needs help to find them. One possibility is to enable the transaction index (put `txindex=1` in bitcoin.conf, or `-txindex` on the bitcoind command line). Another option is specifying which block the transaction is in.

> **Comments:**
> **username_0**: There are 2 files : bitcoin.conf and bitcoind.conf. In bitcoin.conf: it is all comments. Is that the right file that i should edit? In some part it writes:  # Enable pruning to reduce storage requirements by deleting old blocks.  # This mode is incompatible with -txindex and -rescan. # 0 = default (no pruning). # 1 = allows manual pruning via RPC. Should i add the line there?  

---

### Answer by username_1 on 2019-09-23. Score: 1

For the answer to this comment

> Can you give one example of how to do this in cmd as username_2 said :
> -txindex on the bitcoind command line

I do an example for my configuration bitcoin core, I using the -txindex

the command for run bitcoin

```
bitcoind -txindex

```

The essential bitcoin.conf configurations

```
##
## bitcoin.conf configuration file. Lines beginning with # are comments.
##
server=1
rpcuser=YOUR_USER
rpcpassword=YOUR_PAS

```

the process bitcoind with the -txindex is longer because bitcoind indexes all block inside the DB, an example, I used an external HDD and in my cases, the process worked for one day

also when the bitcoind has finished you can run your command, so

```
bitcoin-cli  getrawtransaction 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2

```

You will have this result

```
0100000001186f9f998a5aa6f048e51dd8419a14d8a0f1a8a2836dd734d2804fe65fa35779000000008b483045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e381301410484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adfffffffff0260e31600000000001976a914ab68025513c3dbd2f7b92a94e0581f5d50f654e788acd0ef8000000000001976a9147f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a888ac00000000

```


---

